Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
snipe 2023-01-10 02:08:23 -08:00
commit 17c308f3ca
48 changed files with 373 additions and 309 deletions

View file

@ -26,7 +26,7 @@ jobs:
language: [ 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.3.0
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL

View file

@ -32,7 +32,7 @@ jobs:
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.3.0
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI

View file

@ -41,7 +41,7 @@ jobs:
steps:
# https://github.com/actions/checkout
- name: Checkout codebase
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.3.0
# https://github.com/docker/setup-buildx-action
- name: Setup Docker Buildx

View file

@ -41,7 +41,7 @@ jobs:
steps:
# https://github.com/actions/checkout
- name: Checkout codebase
uses: actions/checkout@v3.1.0
uses: actions/checkout@v3.3.0
# https://github.com/docker/setup-buildx-action
- name: Setup Docker Buildx

View file

@ -6,5 +6,5 @@ return array (
'prerelease_version' => '',
'hash_version' => 'g799c9c910',
'full_hash' => 'v6.0.14-117-g799c9c910',
'branch' => 'develop',
'branch' => 'master',
);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/js/dist/all.js vendored

Binary file not shown.

Binary file not shown.

View file

@ -1,24 +1,24 @@
{
"/js/build/app.js": "/js/build/app.js?id=f05cc05b9000ba73e1949bcf137d4301",
"/css/dist/skins/skin-blue.css": "/css/dist/skins/skin-blue.css?id=f677207c6cf9678eb539abecb408c374",
"/css/build/overrides.css": "/css/build/overrides.css?id=0465141b9ecb0662ba6790c1460f391f",
"/css/build/app.css": "/css/build/app.css?id=c3a896cab26e2093f8be24336b7db1b9",
"/css/build/AdminLTE.css": "/css/build/AdminLTE.css?id=dc383f8560a8d4adb51d44fb4043e03b",
"/css/dist/skins/skin-orange.css": "/css/dist/skins/skin-orange.css?id=6f0563e726c2fe4fab4026daaa5bfdf2",
"/css/dist/skins/skin-orange-dark.css": "/css/dist/skins/skin-orange-dark.css?id=f343f659ca1d45534d2c2c3cc30fb619",
"/css/dist/skins/skin-blue-dark.css": "/css/dist/skins/skin-blue-dark.css?id=57e634d63101d3613f4c73aaa2e3f50a",
"/css/dist/skins/skin-yellow-dark.css": "/css/dist/skins/skin-yellow-dark.css?id=5120ce6a4b70d11bbc84a5125aa31949",
"/css/dist/skins/skin-yellow.css": "/css/dist/skins/skin-yellow.css?id=7b315b9612b8fde8f9c5b0ddb6bba690",
"/css/dist/skins/skin-purple-dark.css": "/css/dist/skins/skin-purple-dark.css?id=713b1205aa2d7c9db282f8cd5754c0e4",
"/css/dist/skins/skin-purple.css": "/css/dist/skins/skin-purple.css?id=6fe68325d5356197672c27bc77cedcb4",
"/css/dist/skins/skin-red-dark.css": "/css/dist/skins/skin-red-dark.css?id=6ea1eecb7f939256c373c92f58749e72",
"/css/dist/skins/skin-black-dark.css": "/css/dist/skins/skin-black-dark.css?id=1c0f59079342d1a10099bf41d2e46f59",
"/css/dist/skins/skin-black.css": "/css/dist/skins/skin-black.css?id=76482123f6c70e866d6b971ba91de7bb",
"/css/dist/skins/skin-green-dark.css": "/css/dist/skins/skin-green-dark.css?id=c0d21166315b7c2cdd4819fa4a5e4d1e",
"/css/dist/skins/skin-green.css": "/css/dist/skins/skin-green.css?id=0a82a6ae6bb4e58fe62d162c4fb50397",
"/css/dist/skins/skin-contrast.css": "/css/dist/skins/skin-contrast.css?id=8e538625ebd4b8096e150d1aa483547b",
"/css/dist/skins/skin-red.css": "/css/dist/skins/skin-red.css?id=44bf834f2110504a793dadec132a5898",
"/css/dist/all.css": "/css/dist/all.css?id=ef030b613d45620b907cf0184a14e868",
"/js/build/app.js": "/js/build/app.js?id=d9c0da9015392f9beb559c4b0b9935b2",
"/css/dist/skins/skin-blue.css": "/css/dist/skins/skin-blue.css?id=392cc93cfc0be0349bab9697669dd091",
"/css/build/overrides.css": "/css/build/overrides.css?id=63aaaefb7d139347dfe0717663bc85ec",
"/css/build/app.css": "/css/build/app.css?id=c1a860573a0f304db91d6a3d3f387114",
"/css/build/AdminLTE.css": "/css/build/AdminLTE.css?id=f25c77ed07053646a42e9c19923d24fa",
"/css/dist/skins/skin-orange.css": "/css/dist/skins/skin-orange.css?id=268041e902b019730c23ee3875838005",
"/css/dist/skins/skin-orange-dark.css": "/css/dist/skins/skin-orange-dark.css?id=c3aebf96518113fe22517a67c6ec1dc1",
"/css/dist/skins/skin-blue-dark.css": "/css/dist/skins/skin-blue-dark.css?id=bf6f6c2270110b3b29f2f3af7e07636d",
"/css/dist/skins/skin-yellow-dark.css": "/css/dist/skins/skin-yellow-dark.css?id=b23ea958779a62474f398ffab9da7ba1",
"/css/dist/skins/skin-yellow.css": "/css/dist/skins/skin-yellow.css?id=fc7adb943668ac69fe4b646625a7571f",
"/css/dist/skins/skin-purple-dark.css": "/css/dist/skins/skin-purple-dark.css?id=5f7e5307fa12a54195d2000b5b5b5076",
"/css/dist/skins/skin-purple.css": "/css/dist/skins/skin-purple.css?id=cf6c8c340420724b02d6e787ef9bded5",
"/css/dist/skins/skin-red-dark.css": "/css/dist/skins/skin-red-dark.css?id=0f4baf95eb4bb23cf837007e61cb666e",
"/css/dist/skins/skin-black-dark.css": "/css/dist/skins/skin-black-dark.css?id=067d7b5d630f23d68ea3b1122527cb04",
"/css/dist/skins/skin-black.css": "/css/dist/skins/skin-black.css?id=1f33ca3d860461c1127ec465ab3ebb6b",
"/css/dist/skins/skin-green-dark.css": "/css/dist/skins/skin-green-dark.css?id=8f449de09e00c15481b144b44b1a7185",
"/css/dist/skins/skin-green.css": "/css/dist/skins/skin-green.css?id=b48f4d8af0e1ca5621c161e93951109f",
"/css/dist/skins/skin-contrast.css": "/css/dist/skins/skin-contrast.css?id=fc501683e0cb04a8717593610d215baf",
"/css/dist/skins/skin-red.css": "/css/dist/skins/skin-red.css?id=b9a74ec0cd68f83e7480d5ae39919beb",
"/css/dist/all.css": "/css/dist/all.css?id=62814c5dd9ee8f9d76a24272b590131c",
"/css/blue.png": "/css/blue.png?id=e83a6c29e04fe851f2122815b2e4b150",
"/css/blue@2x.png": "/css/blue@2x.png?id=51135dd4d24f88f5de0b2414bd51dac5",
"/css/dist/signature-pad.css": "/css/dist/signature-pad.css?id=6a89d3cd901305e66ced1cf5f13147f7",
@ -34,20 +34,20 @@
"/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=ee4896df8b8f008ce73a9a0c2549aefd",
"/js/build/vendor.js": "/js/build/vendor.js?id=47ecbb4bb3b0e02315f391caadbdf971",
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=14d9a2affec7b066d20fcba2e6e67ad2",
"/js/dist/all.js": "/js/dist/all.js?id=4f9355ac85d380301f6f62e55b1a6e5e",
"/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=0a82a6ae6bb4e58fe62d162c4fb50397",
"/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=c0d21166315b7c2cdd4819fa4a5e4d1e",
"/css/dist/skins/skin-black.min.css": "/css/dist/skins/skin-black.min.css?id=76482123f6c70e866d6b971ba91de7bb",
"/css/dist/skins/skin-black-dark.min.css": "/css/dist/skins/skin-black-dark.min.css?id=1c0f59079342d1a10099bf41d2e46f59",
"/css/dist/skins/skin-blue.min.css": "/css/dist/skins/skin-blue.min.css?id=f677207c6cf9678eb539abecb408c374",
"/css/dist/skins/skin-blue-dark.min.css": "/css/dist/skins/skin-blue-dark.min.css?id=57e634d63101d3613f4c73aaa2e3f50a",
"/css/dist/skins/skin-yellow.min.css": "/css/dist/skins/skin-yellow.min.css?id=7b315b9612b8fde8f9c5b0ddb6bba690",
"/css/dist/skins/skin-yellow-dark.min.css": "/css/dist/skins/skin-yellow-dark.min.css?id=5120ce6a4b70d11bbc84a5125aa31949",
"/css/dist/skins/skin-red.min.css": "/css/dist/skins/skin-red.min.css?id=44bf834f2110504a793dadec132a5898",
"/css/dist/skins/skin-red-dark.min.css": "/css/dist/skins/skin-red-dark.min.css?id=6ea1eecb7f939256c373c92f58749e72",
"/css/dist/skins/skin-purple.min.css": "/css/dist/skins/skin-purple.min.css?id=6fe68325d5356197672c27bc77cedcb4",
"/css/dist/skins/skin-purple-dark.min.css": "/css/dist/skins/skin-purple-dark.min.css?id=713b1205aa2d7c9db282f8cd5754c0e4",
"/css/dist/skins/skin-orange.min.css": "/css/dist/skins/skin-orange.min.css?id=6f0563e726c2fe4fab4026daaa5bfdf2",
"/css/dist/skins/skin-orange-dark.min.css": "/css/dist/skins/skin-orange-dark.min.css?id=f343f659ca1d45534d2c2c3cc30fb619",
"/css/dist/skins/skin-contrast.min.css": "/css/dist/skins/skin-contrast.min.css?id=8e538625ebd4b8096e150d1aa483547b"
"/js/dist/all.js": "/js/dist/all.js?id=56e75b479d84630e693031efed58e1ad",
"/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=b48f4d8af0e1ca5621c161e93951109f",
"/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=8f449de09e00c15481b144b44b1a7185",
"/css/dist/skins/skin-black.min.css": "/css/dist/skins/skin-black.min.css?id=1f33ca3d860461c1127ec465ab3ebb6b",
"/css/dist/skins/skin-black-dark.min.css": "/css/dist/skins/skin-black-dark.min.css?id=067d7b5d630f23d68ea3b1122527cb04",
"/css/dist/skins/skin-blue.min.css": "/css/dist/skins/skin-blue.min.css?id=392cc93cfc0be0349bab9697669dd091",
"/css/dist/skins/skin-blue-dark.min.css": "/css/dist/skins/skin-blue-dark.min.css?id=bf6f6c2270110b3b29f2f3af7e07636d",
"/css/dist/skins/skin-yellow.min.css": "/css/dist/skins/skin-yellow.min.css?id=fc7adb943668ac69fe4b646625a7571f",
"/css/dist/skins/skin-yellow-dark.min.css": "/css/dist/skins/skin-yellow-dark.min.css?id=b23ea958779a62474f398ffab9da7ba1",
"/css/dist/skins/skin-red.min.css": "/css/dist/skins/skin-red.min.css?id=b9a74ec0cd68f83e7480d5ae39919beb",
"/css/dist/skins/skin-red-dark.min.css": "/css/dist/skins/skin-red-dark.min.css?id=0f4baf95eb4bb23cf837007e61cb666e",
"/css/dist/skins/skin-purple.min.css": "/css/dist/skins/skin-purple.min.css?id=cf6c8c340420724b02d6e787ef9bded5",
"/css/dist/skins/skin-purple-dark.min.css": "/css/dist/skins/skin-purple-dark.min.css?id=5f7e5307fa12a54195d2000b5b5b5076",
"/css/dist/skins/skin-orange.min.css": "/css/dist/skins/skin-orange.min.css?id=268041e902b019730c23ee3875838005",
"/css/dist/skins/skin-orange-dark.min.css": "/css/dist/skins/skin-orange-dark.min.css?id=c3aebf96518113fe22517a67c6ec1dc1",
"/css/dist/skins/skin-contrast.min.css": "/css/dist/skins/skin-contrast.min.css?id=fc501683e0cb04a8717593610d215baf"
}

View file

@ -19,7 +19,7 @@
@foreach ($field->formatFieldValuesAsArray() as $key => $value)
<div>
<label>
<input type="checkbox" value="{{ $value }}" name="{{ $field->db_column_name() }}[]" class="minimal" {{ isset($item) ? (in_array($value, array_map('trim', explode(',', $item->{$field->db_column_name()}))) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : (in_array($key, array_map('trim', explode(',', $field->defaultValue($model->id)))) ? ' checked="checked"' : '')) }}>
<input type="checkbox" value="{{ $value }}" name="{{ $field->db_column_name() }}[]" class="minimal" {{ isset($item) ? (in_array($value, array_map('trim', explode(',', $item->{$field->db_column_name()}))) ? ' checked="checked"' : '') : (Request::old($field->db_column_name()) != '' ? ' checked="checked"' : (in_array($key, array_map('trim', explode(',', $field->defaultValue($model->id)))) ? ' checked="checked"' : '')) }}>
{{ $value }}
</label>
</div>

View file

@ -14,6 +14,20 @@
# #
# Feel free to modify, but please give #
# credit where it's due. Thanks! #
# #
# Updated Snipe-IT Install Script #
# Update created by Aaron Myers #
# Change log #
# * Added support for CentOS/Rocky 9 #
# * Fixed CentOS 7 repository for PHP 7.4 #
# * Removed support for CentOS 6 #
# * Removed support for Ubuntu < 18.04 #
# * Removed support for Ubuntu 21 (EOL) #
# * Removed support for Debian < 9 (EOL) #
# * Fixed permissions issue with Laravel cache #
# * Moved OS check to start of script #
# * Fixed timezone awk #
# * Minor display and logging improvements #
######################################################
# Parse arguments
@ -68,6 +82,8 @@ clear
readonly APP_USER="snipeitapp"
readonly APP_NAME="snipeit"
readonly APP_PATH="/var/www/html/$APP_NAME"
readonly APP_LOG="/var/log/snipeit-install.log"
readonly COMPOSER_PATH="/home/$APP_USER"
progress () {
spin[0]="-"
@ -93,9 +109,17 @@ log () {
fi
}
eol () {
if [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]] || [[ "$distro" == "Raspbian" ]] ; then
echo -e "\e[31m** \n $distro version $version ($codename) has reached end of life (EOL) and is not supported\n**\e[0m"
else
echo "$distro version $version has reached end of life (EOL) and is not supported"
fi
}
install_packages () {
case $distro in
ubuntu|debian)
Ubuntu|Debian)
for p in $PACKAGES; do
if dpkg -s "$p" >/dev/null 2>&1; then
echo " * $p already installed"
@ -105,7 +129,7 @@ install_packages () {
fi
done;
;;
raspbian)
Raspbian)
for p in $PACKAGES; do
if dpkg -s "$p" >/dev/null 2>&1; then
echo " * $p already installed"
@ -115,7 +139,7 @@ install_packages () {
fi
done;
;;
centos)
Centos)
for p in $PACKAGES; do
if yum list installed "$p" >/dev/null 2>&1; then
echo " * $p already installed"
@ -125,7 +149,7 @@ install_packages () {
fi
done;
;;
fedora)
Fedora)
for p in $PACKAGES; do
if dnf list installed "$p" >/dev/null 2>&1; then
echo " * $p already installed"
@ -156,18 +180,18 @@ create_virtualhost () {
create_user () {
echo "* Creating Snipe-IT user."
if [[ "$distro" == "ubuntu" ]] || [[ "$distro" == "debian" ]] || [[ "$distro" == "raspbian" ]] ; then
adduser --quiet --disabled-password --gecos 'Snipe-IT User' "$APP_USER"
if [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]] || [[ "$distro" == "Raspbian" ]] ; then
/usr/sbin/adduser --quiet --disabled-password --gecos 'Snipe-IT User' "$APP_USER"
su -c "/usr/sbin/usermod -a -G "$apache_group" "$APP_USER""
else
adduser "$APP_USER"
usermod -a -G "$apache_group" "$APP_USER"
fi
usermod -a -G "$apache_group" "$APP_USER"
}
run_as_app_user () {
if ! hash sudo 2>/dev/null; then
su -c "$@" $APP_USER
su - $APP_USER -c "$@"
else
sudo -i -u $APP_USER "$@"
fi
@ -176,31 +200,39 @@ run_as_app_user () {
install_composer () {
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
run_as_app_user php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(run_as_app_user php -r "echo hash_file('SHA384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid composer installer signature'
run_as_app_user rm composer-setup.php
exit 1
if [[ "$distro" == "Debian" ]]; then
wget -q -O $COMPOSER_PATH/composer-setup.php https://getcomposer.org/installer && chown $APP_USER:$APP_USER $COMPOSER_PATH/composer-setup.php
ACTUAL_SIGNATURE="$(sha384sum $COMPOSER_PATH/composer-setup.php | awk '{ print $1 }')"
else
run_as_app_user php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(run_as_app_user php -r "echo hash_file('SHA384', 'composer-setup.php');")"
fi
run_as_app_user php composer-setup.php
run_as_app_user rm composer-setup.php
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
>?&2 echo 'ERROR: Invalid composer installer signature'
exit 1
fi
if [[ "$distro" == "Debian" ]]; then
run_as_app_user "php $COMPOSER_PATH/composer-setup.php"
run_as_app_user "rm $COMPOSER_PATH/composer-setup.php"
else
run_as_app_user php composer-setup.php
run_as_app_user rm composer-setup.php
fi
mv "$(eval echo ~$APP_USER)"/composer.phar /usr/local/bin/composer
}
install_snipeit () {
create_user
echo "* Creating MariaDB Database/User."
echo "* Please Input your MariaDB root password:"
mysql -u root -p --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
mysql -u root --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';"
echo "* Cloning Snipe-IT from github to the web directory."
log "git clone https://github.com/snipe/snipe-it $APP_PATH"
echo -e "\n\n* Cloning Snipe-IT from github to the web directory."
log "git clone https://github.com/snipe/snipe-it $APP_PATH" & pid=$!
progress
echo "* Configuring .env file."
cp "$APP_PATH/.env.example" "$APP_PATH/.env"
@ -218,7 +250,7 @@ install_snipeit () {
install_composer
echo "* Setting permissions."
for chmod_dir in "$APP_PATH/storage" "$APP_PATH/public/uploads"; do
for chmod_dir in "$APP_PATH/storage" "$APP_PATH/public/uploads" "$APP_PATH/bootstrap/cache"; do
chmod -R 775 "$chmod_dir"
done
@ -226,9 +258,15 @@ install_snipeit () {
echo "* Running composer."
# We specify the path to composer because CentOS lacks /usr/local/bin in $PATH when using sudo
run_as_app_user /usr/local/bin/composer install --no-dev --prefer-source --working-dir "$APP_PATH"
if [[ "$distro" == "Debian" ]]; then
run_as_app_user "/usr/local/bin/composer install --no-dev --prefer-source --working-dir "$APP_PATH""
else
echo "* This can take 5 minutes or more. Tail $APP_LOG for more full command output." & pid=$!
progress
log "run_as_app_user /usr/local/bin/composer install --no-dev --prefer-source --working-dir "$APP_PATH""
fi
sudo chgrp -R "$apache_group" "$APP_PATH/vendor"
chgrp -R "$apache_group" "$APP_PATH/vendor"
echo "* Generating the application key."
log "php $APP_PATH/artisan key:generate --force"
@ -237,7 +275,7 @@ install_snipeit () {
log "php $APP_PATH/artisan migrate --force"
echo "* Creating scheduler cron."
(run_as_app_user crontab -l ; echo "* * * * * /usr/bin/php $APP_PATH/artisan schedule:run >> /dev/null 2>&1") | run_as_app_user crontab -
(echo "* * * * * /usr/bin/php $APP_PATH/artisan schedule:run >> /dev/null 2>&1") | run_as_app_user crontab -
}
set_firewall () {
@ -301,37 +339,39 @@ echo '
'
echo ""
echo " Welcome to Snipe-IT Inventory Installer for CentOS, Rocky, Fedora, Debian and Ubuntu!"
echo " Welcome to Snipe-IT Inventory Installer for CentOS, Rocky, Fedora, Debian, and Ubuntu!"
echo ""
echo " Installation log located: $APP_LOG"
echo ""
shopt -s nocasematch
case $distro in
*ubuntu*)
echo " The installer has detected $distro version $version codename $codename."
distro=ubuntu
distro=Ubuntu
apache_group=www-data
apachefile=/etc/apache2/sites-available/$APP_NAME.conf
;;
*Raspbian*)
*raspbian*)
echo " The installer has detected $distro version $version codename $codename."
distro=raspbian
distro=Raspbian
apache_group=www-data
apachefile=/etc/apache2/sites-available/$APP_NAME.conf
;;
*Debian|debian*)
echo " The installer has detected $distro version $version codename $codename."
distro=debian
distro=Debian
apache_group=www-data
apachefile=/etc/apache2/sites-available/$APP_NAME.conf
;;
*centos*|*redhat*|*ol*|*rhel*|*rocky*)
echo " The installer has detected $distro version $version."
distro=centos
distro=Centos
apache_group=apache
apachefile=/etc/httpd/conf.d/$APP_NAME.conf
;;
*fedora*)
echo " The installer has detected $distro version $version."
distro=fedora
distro=Fedora
apache_group=apache
apachefile=/etc/httpd/conf.d/$APP_NAME.conf
;;
@ -342,40 +382,46 @@ case $distro in
esac
shopt -u nocasematch
echo -n " Q. What is the FQDN of your server? ($(hostname --fqdn)): "
read -r fqdn
if [ -z "$fqdn" ]; then
readonly fqdn="$(hostname --fqdn)"
fi
echo " Setting to $fqdn"
echo ""
set_fqdn () {
echo -n " Q. What is the FQDN of your server? ($(hostname --fqdn)): "
read -r fqdn
if [ -z "$fqdn" ]; then
readonly fqdn="$(hostname --fqdn)"
fi
echo " Setting to $fqdn"
echo ""
}
ans=default
until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do
echo -n " Q. Do you want to automatically create the database user password? (y/n) "
read -r setpw
set_dbpass () {
ans=default
until [[ $ans == "yes" ]] || [[ $ans == "no" ]]; do
echo -n " Q. Do you want to automatically create the SnipeIT database user password? (y/n) "
read -r setpw
case $setpw in
[yY] | [yY][Ee][Ss] )
mysqluserpw="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c16; echo)"
echo ""
ans="yes"
;;
[nN] | [n|N][O|o] )
echo -n " Q. What do you want your snipeit user password to be?"
read -rs mysqluserpw
echo ""
ans="no"
;;
*) echo " Invalid answer. Please type y or n"
;;
esac
done
case $setpw in
[yY] | [yY][Ee][Ss] )
mysqluserpw="$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c16; echo)"
echo ""
ans="yes"
;;
[nN] | [n|N][O|o] )
echo -n " Q. What do you want your snipeit user password to be?"
read -rs mysqluserpw
echo ""
ans="no"
;;
*) echo " Invalid answer. Please type y or n"
;;
esac
done
}
case $distro in
debian)
Debian)
if [[ "$version" =~ ^11 ]]; then
# Install for Debian 11.x
set_fqdn
set_dbpass
tzone=$(cat /etc/timezone)
echo "* Adding PHP repository."
@ -393,21 +439,26 @@ case $distro in
echo "* Configuring Apache."
create_virtualhost
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
rename_default_vhost
/usr/sbin/a2enmod rewrite
/usr/sbin/a2ensite $APP_NAME.conf
rename_default_vhost
set_hosts
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
echo "* Restarting Apache httpd."
log "service apache2 restart"
/usr/sbin/service apache2 restart
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
run_as_app_user "php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
elif [[ "$version" =~ ^10 ]]; then
# Install for Debian 10.x
set_fqdn
set_dbpass
tzone=$(cat /etc/timezone)
echo "* Adding PHP repository."
@ -419,99 +470,41 @@ case $distro in
log "apt-get update && apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php7.3 php7.3 php7.3-mcrypt php7.3-curl php7.3-mysql php7.3-gd php7.3-ldap php7.3-zip php7.3-mbstring php7.3-xml php7.3-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
create_virtualhost
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
rename_default_vhost
set_hosts
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
echo "* Restarting Apache httpd."
log "service apache2 restart"
elif [[ "$version" =~ ^9 ]]; then
# Install for Debian 9.x
tzone=$(cat /etc/timezone)
echo "* Adding PHP repository."
log "apt-get install -y apt-transport-https"
log "wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg"
echo "deb https://packages.sury.org/php/ $codename main" > /etc/apt/sources.list.d/php.list
echo -n "* Updating installed packages."
log "apt-get update && apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php7.4 php7.4 php7.4-mcrypt php7.4-curl php7.4-mysql php7.4-gd php7.4-ldap php7.4-zip php7.4-mbstring php7.4-xml php7.4-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
create_virtualhost
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
rename_default_vhost
/usr/sbin/a2enmod rewrite
/usr/sbin/a2ensite $APP_NAME.conf
rename_default_vhost
set_hosts
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
echo "* Restarting Apache httpd."
log "service apache2 restart"
elif [[ "$version" =~ ^8 ]]; then
# Install for Debian 8.x
tzone=$(cat /etc/timezone)
/usr/sbin/service apache2 restart
echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-get install -y software-properties-common apt-transport-https"
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db"
log "add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/debian $codename main'"
log "wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg"
echo "deb https://packages.sury.org/php/ $codename main" > /etc/apt/sources.list.d/php.list
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
run_as_app_user "php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
echo -n "* Updating installed packages."
log "apt-get update && apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="mariadb-server mariadb-client php7.4 php7.4-mcrypt php7.4-curl php7.4-mysql php7.4-gd php7.4-ldap php7.4-zip php7.4-mbstring php7.4-xml php7.4-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
create_virtualhost
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
rename_default_vhost
set_hosts
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
echo "* Restarting Apache httpd."
log "service apache2 restart"
elif [[ "$version" =~ ^9 ]]; then
eol
exit 1
else
echo "Unsupported Debian version. Version found: $version"
exit 1
fi
;;
ubuntu)
if [ "${version//./}" -ge "1804" ]; then
# Install for Ubuntu 18.04
Ubuntu)
if [ "${version//./}" -ge "2204" ]; then
# Install for Ubuntu 22.04
set_fqdn
set_dbpass
tzone=$(cat /etc/timezone)
echo -n "* Updating installed packages."
@ -519,7 +512,7 @@ case $distro in
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip"
PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@ -528,36 +521,76 @@ case $distro in
log "phpenmod mbstring"
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
rename_default_vhost
rename_default_vhost
set_hosts
echo "* Starting MariaDB."
log "systemctl start mariadb.service"
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
echo "* Restarting Apache httpd."
log "systemctl restart apache2"
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
log "run_as_app_user php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
elif [ "${version//./}" == "2110" ]; then
# Ubuntu 21.10 is no longer supported
echo "Unsupported Ubuntu version. Version found: $version"
exit 1
elif [ "${version//./}" == "2004" ]; then
# Install for Ubuntu 20.04
set_fqdn
set_dbpass
tzone=$(cat /etc/timezone)
echo -n "* Updating installed packages."
log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
create_virtualhost
log "phpenmod mcrypt"
log "phpenmod mbstring"
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
rename_default_vhost
set_hosts
echo "* Starting MariaDB."
log "systemctl start mariadb.service"
install_snipeit
echo "* Restarting Apache httpd."
log "systemctl restart apache2"
elif [ "$version" == "16.04" ]; then
# Install for Ubuntu 16.04
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
log "run_as_app_user php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
elif [ "${version//./}" == "1804" ]; then
# Install for Ubuntu 18.04+
set_fqdn
set_dbpass
tzone=$(cat /etc/timezone)
echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-get install -y software-properties-common"
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8"
log "add-apt-repository 'deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu $codename main'"
echo -n "* Updating installed packages."
log "apt-get update"
log "DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$!
progress
log "add-apt-repository -y ppa:ondrej/php"
echo -n "* Updating installed packages."
log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php7.4 php7.4 php7.4-mcrypt php7.4-curl php7.4-mysql php7.4-gd php7.4-ldap php7.4-zip php7.4-mbstring php7.4-xml php7.4-bcmath curl git unzip"
PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@ -566,64 +599,32 @@ case $distro in
log "phpenmod mbstring"
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
rename_default_vhost
set_hosts
echo "* Starting MariaDB."
log "service mysql start"
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
log "systemctl start mariadb.service"
install_snipeit
echo "* Restarting Apache httpd."
log "service apache2 restart"
elif [ "$version" == "14.04" ]; then
# Install for Ubuntu 14.04
tzone=$(cat /etc/timezone)
log "systemctl restart apache2"
echo "* Adding MariaDB and ppa:ondrej/php repositories."
log "apt-get install -y software-properties-common"
log "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db"
log "add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu $codename main'"
log "add-apt-repository ppa:ondrej/php -y"
echo -n "* Updating installed packages."
log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="mariadb-server mariadb-client php7.4 php7.4-mcrypt php7.4-curl php7.4-mysql php7.4-gd php7.4-ldap php7.4-zip php7.4-mbstring php7.4-xml php7.4-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
create_virtualhost
log "phpenmod mcrypt"
log "phpenmod mbstring"
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
set_hosts
echo "* Starting MariaDB."
log "service mysql start"
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
echo "* Restarting Apache httpd."
log "service apache2 restart"
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
log "run_as_app_user php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
else
echo "Unsupported Ubuntu version. Version found: $version"
exit 1
fi
;;
raspbian)
Raspbian)
if [[ "$version" =~ ^10 ]]; then
# Install for Raspbian 9.x
set_fqdn
set_dbpass
tzone=$(cat /etc/timezone)
cat >/etc/apt/sources.list.d/10-buster.list <<EOL
deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi
@ -671,66 +672,25 @@ EOL
exit 1
fi
;;
centos)
Centos)
if [[ "$version" =~ ^6 ]]; then
# Install for CentOS/Redhat 6.x
tzone=$(grep ZONE /etc/sysconfig/clock | tr -d '"' | sed 's/ZONE=//g');
echo "* Adding IUS, epel-release and MariaDB repositories."
mariadbRepo=/etc/yum.repos.d/MariaDB.repo
touch "$mariadbRepo"
{
echo "[mariadb]"
echo "name = MariaDB"
echo "baseurl = http://yum.mariadb.org/10.0/centos6-amd64"
echo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB"
echo "gpgcheck=1"
echo "enable=1"
} >> "$mariadbRepo"
log "yum -y install wget epel-release"
log "yum -y install https://centos6.iuscommunity.org/ius-release.rpm"
log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY"
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="httpd mariadb-server git unzip php71u php71u-mysqlnd php71u-bcmath php71u-cli php71u-common php71u-embedded php71u-gd php71u-mbstring php71u-mcrypt php71u-ldap php71u-json php71u-simplexml php71u-process"
install_packages
echo "* Configuring Apache."
create_virtualhost
echo "* Setting MariaDB to start on boot and starting MariaDB."
log "chkconfig mysql on"
log "/sbin/service mysql start"
set_hosts
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
if /sbin/service iptables status >/dev/null 2>&1; then
echo "* Configuring iptables."
iptables -I INPUT 1 -p tcp -m tcp --dport 80 -j ACCEPT
iptables -I INPUT 1 -p tcp -m tcp --dport 443 -j ACCEPT
service iptables save
fi
echo "* Setting Apache httpd to start on boot and starting service."
log "chkconfig httpd on"
log "/sbin/service httpd start"
eol
exit 1
elif [[ "$version" =~ ^7 ]]; then
# Install for CentOS/Redhat 7
set_fqdn
set_dbpass
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
echo "* Adding IUS, epel-release and MariaDB repositories."
log "yum -y install wget epel-release"
log "yum -y install https://centos7.iuscommunity.org/ius-release.rpm"
log "rpm --import /etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY"
echo "* Adding Remi and EPEL-Release repositories."
log "yum -y install wget epel-release yum-utils" & pid=$!
progress
log "yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm" & pid=$!
progress
log "yum-config-manager --enable remi-php74"
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="httpd mariadb-server git unzip php71u php71u-mysqlnd php71u-bcmath php71u-cli php71u-common php71u-embedded php71u-gd php71u-mbstring php71u-mcrypt php71u-ldap php71u-json php71u-simplexml php71u-process"
PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-mcrypt php-ldap php-json php-simplexml php-process php-zip"
install_packages
echo "* Configuring Apache."
@ -742,30 +702,121 @@ EOL
log "systemctl enable mariadb.service"
log "systemctl start mariadb.service"
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
set_firewall
echo "* Setting Apache httpd to start on boot and starting service."
log "systemctl enable httpd.service"
log "systemctl restart httpd.service"
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
log "run_as_app_user php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
set_selinux
elif [[ "$version" =~ ^8 ]]; then
# Install for CentOS/Redhat 8
set_fqdn
set_dbpass
tzone=$(timedatectl | grep "Time zone" | awk 'BEGIN { FS"("}; {print $3}');
echo "* Adding Remi and EPEL-Release repositories."
log "yum -y install wget epel-release yum-utils" & pid=$!
progress
log "yum -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm" & pid=$!
progress
log "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8"
log "dnf -y module enable php:remi-7.4" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-mcrypt php-ldap php-json php-simplexml php-process php-zip"
install_packages
echo "* Configuring Apache."
create_virtualhost
set_hosts
echo "* Setting MariaDB to start on boot and starting MariaDB."
log "systemctl enable mariadb.service"
log "systemctl start mariadb.service"
install_snipeit
set_firewall
echo "* Setting Apache httpd to start on boot and starting service."
log "systemctl enable httpd.service"
log "systemctl restart httpd.service"
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
log "run_as_app_user php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
set_selinux
elif [[ "$version" =~ ^9 ]]; then
# Install for CentOS/Redhat 9
set_fqdn
set_dbpass
tzone=$(timedatectl | grep "Time zone" | awk 'BEGIN { FS"("}; {print $3}');
echo "* Adding EPEL-release repository."
log "dnf -y install wget epel-release" & pid=$!
progress
echo "* Installing Apache httpd, PHP, MariaDB, and other requirements."
PACKAGES="httpd mariadb-server git unzip php-mysqlnd php-bcmath php-cli php-embedded php-gd php-mbstring php-ldap php-simplexml php-process php-sodium php-pecl-zip php-fpm"
install_packages
echo "* Configuring Apache."
create_virtualhost
set_hosts
echo "* Setting MariaDB to start on boot and starting MariaDB."
log "systemctl enable mariadb.service"
log "systemctl start mariadb.service"
install_snipeit
set_firewall & pid=$!
progress
echo "* Setting Apache httpd to start on boot and starting service."
log "systemctl enable httpd.service"
log "systemctl restart httpd.service"
echo "* Setting php-fpm to start on boot and starting service."
log "systemctl enable php-fpm.service"
log "systemctl restart php-fpm.service"
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
log "run_as_app_user php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
set_selinux
else
echo "Unsupported CentOS version. Version found: $version"
exit 1
fi
;;
fedora)
if [ "$version" -ge 26 ]; then
# Install for Fedora 26+
tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
Fedora)
if [[ "$version" =~ ^36 ]]; then
# Install for Fedora 36+
set_fqdn
set_dbpass
tzone=$(timedatectl | grep "Time zone" | awk 'BEGIN { FS"("}; {print $3}');
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-cli php-common php-embedded php-gd php-mbstring php-mcrypt php-ldap php-json php-simplexml"
PACKAGES="wget httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-cli php-common php-embedded php-gd php-mbstring php-mcrypt php-ldap php-simplexml php-process php-sodium php-pecl-zip php-fpm"
install_packages
echo "* Configuring Apache."
@ -777,27 +828,39 @@ EOL
log "systemctl enable mariadb.service"
log "systemctl start mariadb.service"
echo "* Securing MariaDB."
/usr/bin/mysql_secure_installation
install_snipeit
set_firewall
set_selinux
set_firewall & pid=$!
progress
echo "* Setting Apache httpd to start on boot and starting service."
log "systemctl enable httpd.service"
log "systemctl restart httpd.service"
echo "* Setting php-fpm to start on boot and starting service."
log "systemctl enable php-fpm.service"
log "systemctl restart php-fpm.service"
echo "* Clearing cache and setting final permissions."
chmod 777 -R $APP_PATH/storage/framework/cache/
log "run_as_app_user php $APP_PATH/artisan cache:clear"
chmod 775 -R $APP_PATH/storage/
set_selinux
else
echo "Unsupported Fedora version. Version found: $version"
exit 1
fi
;;
*)
echo "Your OS was not detected correctly."
exit 1
esac
setupmail=default
until [[ $setupmail == "yes" ]] || [[ $setupmail == "no" ]]; do
echo -n " Q. Do you want to configure mail server settings? (y/n) "
echo " Q. Do you want to configure mail server settings now? This can be done later too. "
echo -n " * You will need mail server address, port, user and password among other items. (y/n) "
read -r setupmail
case $setupmail in
@ -855,5 +918,6 @@ echo ""
echo "* Cleaning up..."
rm -f snipeit.sh
rm -f install.sh
echo "* Installation log located in $APP_LOG."
echo "* Finished!"
sleep 1