From 6a8d5282efb28741bf41032682fe8421cfb84fbb Mon Sep 17 00:00:00 2001 From: Earl Ramirez Date: Tue, 6 Apr 2021 06:06:53 +0200 Subject: [PATCH] Add support for Debian 10 (#7414) --- snipeit.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index d6d65619b8..76b784c052 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -156,8 +156,8 @@ create_virtualhost () { create_user () { echo "* Creating Snipe-IT user." - if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] || [ "$distro" == "raspbian" ] ; then - adduser --quiet --disabled-password --gecos '""' "$APP_USER" + if [[ "$distro" == "ubuntu" ]] || [[ "$distro" == "debian" ]] || [[ "$distro" == "raspbian" ]] ; then + adduser --quiet --disabled-password --gecos 'Snipe-IT User' "$APP_USER" else adduser "$APP_USER" fi @@ -265,7 +265,13 @@ set_hosts () { echo >> /etc/hosts "127.0.0.1 $(hostname) $fqdn" } -if [[ -f /etc/lsb-release || -f /etc/debian_version ]]; then +rename_default_vhost () { + log "mv /etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled/111-default.conf" + log "mv /etc/apache2/sites-enabled/snipeit.conf /etc/apache2/sites-enabled/000-snipeit.conf" +} + + +if [[ -f /etc/debian_version || -f /etc/lsb-release ]]; then distro="$(lsb_release -is)" version="$(lsb_release -rs)" codename="$(lsb_release -cs)" @@ -311,7 +317,7 @@ case $distro in apache_group=www-data apachefile=/etc/apache2/sites-available/$APP_NAME.conf ;; - *debian*) + *Debian|debian*) echo " The installer has detected $distro version $version codename $codename." distro=debian apache_group=www-data @@ -330,7 +336,7 @@ case $distro in apachefile=/etc/httpd/conf.d/$APP_NAME.conf ;; *) - echo " The installer was unable to determine your OS. Exiting for safety." + echo " The installer was unable to determine your OS. Exiting for safety. Exiting for safety." exit 1 ;; esac @@ -368,7 +374,39 @@ done case $distro in debian) - if [[ "$version" =~ ^9 ]]; then + if [[ "$version" =~ ^10 ]]; then + # Install for Debian 10.x + tzone=$(cat /etc/timezone) + + echo "* Adding PHP repository." + log "apt-get install -y apt-transport-https lsb-release ca-certificates" + 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.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) @@ -389,6 +427,7 @@ case $distro in create_virtualhost log "a2enmod rewrite" log "a2ensite $APP_NAME.conf" + rename_default_vhost set_hosts @@ -422,6 +461,7 @@ case $distro in create_virtualhost log "a2enmod rewrite" log "a2ensite $APP_NAME.conf" + rename_default_vhost set_hosts @@ -456,8 +496,7 @@ case $distro in log "phpenmod mbstring" log "a2enmod rewrite" log "a2ensite $APP_NAME.conf" - log "mv /etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled/111-default.conf" - log "mv /etc/apache2/sites-enabled/snipeit.conf /etc/apache2/sites-enabled/000-snipeit.conf" + rename_default_vhost set_hosts