Skip to content

A free open source IT asset/license management system

Fixed #11225: run_as_app_user unknown operand Fixed #10581: installer does not work on CentOS7 Fixed #10105: php not found, composer failed Fixed #9035: CentOS 7 IUS repos missing

Aaron2c7364bdfe50
diff --git a/snipeit.sh b/snipeit.sh
index ab190aac9c..7479df3576 100755
--- a/snipeit.sh
+++ b/snipeit.sh
@@ -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
+
+ if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
+ >?&2 echo 'ERROR: Invalid composer installer signature'
+ exit 1
fi
- run_as_app_user php composer-setup.php
- run_as_app_user rm composer-setup.php
+ 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 ""
-
-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_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 ""
+}
-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
+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 $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)
-
- 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
+ /usr/sbin/service apache2 restart
- echo -n "* Updating installed packages."
- log "apt-get update && apt-get -y upgrade" & pid=$!
- progress
+ 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 "* 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,38 @@ 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"
- elif [ "$version" == "16.04" ]; then
- # Install for Ubuntu 16.04
- 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'"
- log "add-apt-repository -y ppa:ondrej/php"
+ 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="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,35 +561,36 @@ 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 "* 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 -n "* Updating installed packages."
- log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$!
+ log "apt-get update"
+ log "DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$!
progress
+ log "add-apt-repository -y ppa:ondrej/php"
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"
+ 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."
@@ -603,27 +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"
+ 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/
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,68 @@ 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"
+ 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 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."
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
+ echo "* Setting MariaDB to start on boot and starting MariaDB."
+ log "systemctl enable mariadb.service"
+ log "systemctl start mariadb.service"
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
+ set_firewall
echo "* Setting Apache httpd to start on boot and starting service."
- log "chkconfig httpd on"
- log "/sbin/service httpd start"
- elif [[ "$version" =~ ^7 ]]; then
- # Install for CentOS/Redhat 7
- tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}');
+ 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 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 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 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 +745,78 @@ 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" =~ ^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