From 117007dfa1027ebce98b4164f5420082c90e53ff Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Mon, 20 Nov 2023 14:06:28 -0800 Subject: [PATCH 01/16] add new ubuntu/debian versions, change php to 8.2 --- snipeit.sh | 660 +++++++++++++++++++++++++++-------------------------- 1 file changed, 331 insertions(+), 329 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 7479df357..784eaf393 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -419,214 +419,216 @@ set_dbpass () { case $distro in Debian) if [[ "$version" =~ ^11 ]]; then - # Install for Debian 11.x - set_fqdn - set_dbpass - tzone=$(cat /etc/timezone) + # Install for Debian 11.x + set_fqdn + set_dbpass + 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 "* 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 -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 "* Installing Apache httpd, PHP, MariaDB and other requirements." + PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip" + install_packages - echo "* Configuring Apache." - create_virtualhost - /usr/sbin/a2enmod rewrite - /usr/sbin/a2ensite $APP_NAME.conf - rename_default_vhost + echo "* Configuring Apache." + create_virtualhost + /usr/sbin/a2enmod rewrite + /usr/sbin/a2ensite $APP_NAME.conf + rename_default_vhost - set_hosts + set_hosts - install_snipeit + install_snipeit - echo "* Restarting Apache httpd." - /usr/sbin/service apache2 restart + echo "* Restarting Apache httpd." + /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/ + 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) + elif [[ "$version" =~ ^11 ]]; then + # Install for Debian 11.x + set_fqdn + set_dbpass + 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 "* 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 -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 "* Installing Apache httpd, PHP, MariaDB and other requirements." + PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip" + install_packages - echo "* Configuring Apache." - create_virtualhost - /usr/sbin/a2enmod rewrite - /usr/sbin/a2ensite $APP_NAME.conf - rename_default_vhost + echo "* Configuring Apache." + create_virtualhost + /usr/sbin/a2enmod rewrite + /usr/sbin/a2ensite $APP_NAME.conf + rename_default_vhost - set_hosts + set_hosts - install_snipeit + install_snipeit - echo "* Restarting Apache httpd." - /usr/sbin/service apache2 restart + echo "* Restarting Apache httpd." + /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/ + 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" =~ ^9 ]]; then - eol - exit 1 - else - echo "Unsupported Debian version. Version found: $version" - exit 1 - fi + elif [[ "$version" =~ ^10 ]]; then + # Install for Debian 10.x + set_fqdn + set_dbpass + 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-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip" + install_packages + + echo "* Configuring Apache." + create_virtualhost + /usr/sbin/a2enmod rewrite + /usr/sbin/a2ensite $APP_NAME.conf + rename_default_vhost + + set_hosts + + install_snipeit + + echo "* Restarting Apache httpd." + /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" =~ ^9 ]]; then + eol + exit 1 + else + echo "Unsupported Debian version. Version found: $version" + exit 1 + fi ;; Ubuntu) -if [ "${version//./}" -ge "2204" ]; then - # Install for Ubuntu 22.04 - set_fqdn - set_dbpass - tzone=$(cat /etc/timezone) + if [ "${version//./}" -ge "2204" ]; then + # Install for Ubuntu 22.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 -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 "* 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 + echo "* Configuring Apache." + create_virtualhost + log "phpenmod mcrypt" + log "phpenmod mbstring" + log "a2enmod rewrite" + log "a2ensite $APP_NAME.conf" + rename_default_vhost - set_hosts + set_hosts - echo "* Starting MariaDB." - log "systemctl start mariadb.service" + echo "* Starting MariaDB." + log "systemctl start mariadb.service" - install_snipeit + install_snipeit - echo "* Restarting Apache httpd." - log "systemctl restart apache2" + 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 "* 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 -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 "* 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 + echo "* Configuring Apache." + create_virtualhost + log "phpenmod mcrypt" + log "phpenmod mbstring" + log "a2enmod rewrite" + log "a2ensite $APP_NAME.conf" + rename_default_vhost - set_hosts + set_hosts - echo "* Starting MariaDB." - log "systemctl start mariadb.service" + echo "* Starting MariaDB." + log "systemctl start mariadb.service" - install_snipeit + install_snipeit - echo "* Restarting Apache httpd." - log "systemctl restart apache2" + 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//./}" == "1804" ]; then - # Install for Ubuntu 18.04+ - set_fqdn - set_dbpass - tzone=$(cat /etc/timezone) - - 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 "* 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" - - 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 - ;; + 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 + eol + exit 1 + else + echo "Unsupported Ubuntu version. Version found: $version" + exit 1 + fi + ;; 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 </etc/apt/sources.list.d/10-buster.list < Date: Thu, 30 Nov 2023 00:47:27 -0800 Subject: [PATCH 02/16] fix up ondrej repo --- snipeit.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 784eaf393..6c0eb7d5c 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -233,6 +233,9 @@ install_snipeit () { 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 + pushd $APP_PATH + git checkout jerm/snipeit-sh + popd echo "* Configuring .env file." cp "$APP_PATH/.env.example" "$APP_PATH/.env" @@ -544,12 +547,17 @@ case $distro in set_dbpass tzone=$(cat /etc/timezone) + echo "* Set up Ondrej PHP repository" + echo "# Odrej PHP repo for ability to choose non-distro PHP versions" > /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list + echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C + 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" + PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip" install_packages echo "* Configuring Apache." @@ -584,12 +592,16 @@ case $distro in set_dbpass tzone=$(cat /etc/timezone) + echo "* Set up Ondrej PHP repository" + echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C + 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" + PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php8.28.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip" install_packages echo "* Configuring Apache." @@ -641,13 +653,15 @@ Package: * Pin: release n=buster Pin-Priority: 750 EOL + echo "* Set up Ondrej PHP repository" + echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list 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.2 php7.2 php7.2-mcrypt php7.2-curl php7.2-mysql php7.2-gd php7.2-ldap php7.2-zip php7.2-mbstring php7.2-xml php7.2-bcmath curl git unzip" + PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip" install_packages echo "* Configuring Apache." @@ -918,8 +932,8 @@ echo " ***Open http://$fqdn to login to Snipe-IT.***" echo "" echo "" echo "* Cleaning up..." -rm -f snipeit.sh -rm -f install.sh +# rm -f snipeit.sh +# rm -f install.sh echo "* Installation log located in $APP_LOG." echo "* Finished!" sleep 1 From 5e539da3da97e0ed9573cffe12c90cf0f0ebc691 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 30 Nov 2023 01:28:49 -0800 Subject: [PATCH 03/16] Debian 12 --- snipeit.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 6c0eb7d5c..4503c10ec 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -421,8 +421,8 @@ set_dbpass () { case $distro in Debian) - if [[ "$version" =~ ^11 ]]; then - # Install for Debian 11.x + if [[ "$version" =~ ^12 ]]; then + # Install for Debian 12.x set_fqdn set_dbpass tzone=$(cat /etc/timezone) From d5881736cf0233fe857ddd1350370b4de8f0af95 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 30 Nov 2023 10:22:59 -0800 Subject: [PATCH 04/16] stop quoting run_as_app_user args because "$@" splits positional parameters, but quoting the args makes them one arg, which doesn't work --- snipeit.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 4503c10ec..11141361d 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -215,8 +215,8 @@ install_composer () { 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" + 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 @@ -262,7 +262,7 @@ install_snipeit () { echo "* Running composer." # We specify the path to composer because CentOS lacks /usr/local/bin in $PATH when using sudo if [[ "$distro" == "Debian" ]]; then - run_as_app_user "/usr/local/bin/composer install --no-dev --prefer-source --working-dir "$APP_PATH"" + 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 @@ -455,7 +455,7 @@ case $distro in 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" + run_as_app_user php $APP_PATH/artisan cache:clear chmod 775 -R $APP_PATH/storage/ elif [[ "$version" =~ ^11 ]]; then @@ -492,7 +492,7 @@ case $distro in 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" + run_as_app_user php $APP_PATH/artisan cache:clear chmod 775 -R $APP_PATH/storage/ elif [[ "$version" =~ ^10 ]]; then @@ -529,7 +529,7 @@ case $distro in 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" + run_as_app_user php $APP_PATH/artisan cache:clear chmod 775 -R $APP_PATH/storage/ elif [[ "$version" =~ ^9 ]]; then @@ -551,7 +551,7 @@ case $distro in echo "# Odrej PHP repo for ability to choose non-distro PHP versions" > /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C - + echo -n "* Updating installed packages." log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$! progress From 123d04ff7bc14438147e07333096af957ff6cec9 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 30 Nov 2023 11:28:13 -0800 Subject: [PATCH 05/16] split-out ubuntu 23* versions since 2023 didn't produce and LTS ubuntu versions the Ondrej repo we use for installing arbitrary PHP versions doesn't (easily) support non-LTS versions of ubuntu, which means that 23.04 and 23.10 are problematic using the repo However, these versions ship with php8.1 and php8.2 (respectively), so we don't even need the Ondrej repo for these, so we'll remove it In general, we'll only support LTS Ubuntu repos because of this, but if they happen to ship with our preferred PHP versions and otherwise work w/o heroics, we'll include nominal support in the script --- snipeit.sh | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 11141361d..659c47ac0 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -541,16 +541,52 @@ case $distro in fi ;; Ubuntu) - if [ "${version//./}" -ge "2204" ]; then + if [ "${version//./}" -ge "2304" ]; then # Install for Ubuntu 22.04 set_fqdn set_dbpass tzone=$(cat /etc/timezone) - echo "* Set up Ondrej PHP repository" - echo "# Odrej PHP repo for ability to choose non-distro PHP versions" > /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list - echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C + 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 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-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" + + 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//./}" -eq "2204" ]; then + # Install for Ubuntu 22.04 + set_fqdn + set_dbpass + tzone=$(cat /etc/timezone) + + echo "* Set up Ondrej PHP repository" + echo "# Odrej PHP repo for ability to choose non-distro PHP versions" > /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list + echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C echo -n "* Updating installed packages." log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$! From 066e40dada29a73f7aa53aaff34bb37802d99ada Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 30 Nov 2023 11:43:16 -0800 Subject: [PATCH 06/16] update Ubuntu versions comment in code block --- snipeit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snipeit.sh b/snipeit.sh index 659c47ac0..704371332 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -542,7 +542,7 @@ case $distro in ;; Ubuntu) if [ "${version//./}" -ge "2304" ]; then - # Install for Ubuntu 22.04 + # Install for Ubuntu 23.04 and 23.10 set_fqdn set_dbpass tzone=$(cat /etc/timezone) From 5489c50cc05351b023d20fba4dbd75ae38d4687c Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 30 Nov 2023 11:45:43 -0800 Subject: [PATCH 07/16] remove remaining 8.2 references in Ubuntu 23* block different vim config confusion made my regex misbehave :-/ --- snipeit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snipeit.sh b/snipeit.sh index 704371332..a41dd8802 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -552,7 +552,7 @@ case $distro in progress echo "* Installing Apache httpd, PHP, MariaDB and other requirements." - PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-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." From 4a290a85e6790560c9b199f6038003b78966251b Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Wed, 20 Dec 2023 18:13:36 -0800 Subject: [PATCH 08/16] awsl2 support, php8.2 support in centos/alma, new mysql user creation code --- snipeit.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index a41dd8802..e864818b9 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -21,7 +21,7 @@ # * 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 < 20.04 # # * Removed support for Ubuntu 21 (EOL) # # * Removed support for Debian < 9 (EOL) # # * Fixed permissions issue with Laravel cache # @@ -228,7 +228,7 @@ install_composer () { install_snipeit () { create_user echo "* Creating MariaDB Database/User." - mysql -u root --execute="CREATE DATABASE snipeit;GRANT ALL PRIVILEGES ON snipeit.* TO snipeit@localhost IDENTIFIED BY '$mysqluserpw';" + mysql -u root --execute="CREATE DATABASE snipeit_dbuser;CREATE USER snipeit_dbuser@localhost IDENTIFIED BY '$mysqluserpw'; GRANT ALL PRIVILEGES ON snipeit.* TO snipeit_dbuser@localhost;" 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=$! @@ -245,7 +245,7 @@ install_snipeit () { sed -i "s|^\\(APP_TIMEZONE=\\).*|\\1$tzone|" "$APP_PATH/.env" sed -i "s|^\\(DB_HOST=\\).*|\\1localhost|" "$APP_PATH/.env" sed -i "s|^\\(DB_DATABASE=\\).*|\\1snipeit|" "$APP_PATH/.env" - sed -i "s|^\\(DB_USERNAME=\\).*|\\1snipeit|" "$APP_PATH/.env" + sed -i "s|^\\(DB_USERNAME=\\).*|\\1snipeit_dbuser|" "$APP_PATH/.env" sed -i "s|^\\(DB_PASSWORD=\\).*|\\1'$mysqluserpw'|" "$APP_PATH/.env" sed -i "s|^\\(APP_URL=\\).*|\\1http://$fqdn|" "$APP_PATH/.env" @@ -728,6 +728,42 @@ EOL if [[ "$version" =~ ^6 ]]; then eol exit 1 + elif [[ "$version" =~ ^2 || "$distro" == "amzn" ]]; then + # Install for amazon linux 2 + set_fqdn + set_dbpass + tzone=$(timedatectl | gawk -F'[: ]' ' $9 ~ /zone/ {print $11}'); + + amazon-linux-extras install -y php8.2 + + 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" =~ ^7 ]]; then # Install for CentOS/Redhat 7 set_fqdn @@ -813,13 +849,17 @@ EOL set_selinux elif [[ "$version" =~ ^9 ]]; then - # Install for CentOS/Redhat 9 + # Install for CentOS/Alma/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=$! + log "yum -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm" & pid=$ + progress + log "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8" + log "dnf -y module enable php:remi-8.2" & pid=$! progress echo "* Installing Apache httpd, PHP, MariaDB, and other requirements." From 47eb0c34a21c3b498ff8ff8147ee42024b78ef40 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 4 Jan 2024 16:03:22 -0800 Subject: [PATCH 09/16] remove fedora surpport, add amazon and alma --- snipeit.sh | 64 ++++-------------------------------------------------- 1 file changed, 4 insertions(+), 60 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index e864818b9..0b8c91444 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -149,16 +149,6 @@ install_packages () { fi done; ;; - Fedora) - for p in $PACKAGES; do - if dnf list installed "$p" >/dev/null 2>&1; then - echo " * $p already installed" - else - echo " * Installing $p" - log "dnf -y install $p" - fi - done; - ;; esac } @@ -342,7 +332,7 @@ 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, Debian, and Ubuntu!" echo "" echo " Installation log located: $APP_LOG" echo "" @@ -366,17 +356,15 @@ case $distro in apache_group=www-data apachefile=/etc/apache2/sites-available/$APP_NAME.conf ;; - *centos*|*redhat*|*ol*|*rhel*|*rocky*) + *amzn*|*redhat*|*alma*|*rhel*|*rocky*) echo " The installer has detected $distro version $version." distro=Centos apache_group=apache apachefile=/etc/httpd/conf.d/$APP_NAME.conf ;; *fedora*) - echo " The installer has detected $distro version $version." - distro=Fedora - apache_group=apache - apachefile=/etc/httpd/conf.d/$APP_NAME.conf + echo " The installer does not support Fedora" + exit 1 ;; *) echo " The installer was unable to determine your OS. Exiting for safety. Exiting for safety." @@ -900,50 +888,6 @@ EOL exit 1 fi ;; - 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="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." - 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 Fedora version. Version found: $version" - exit 1 - fi - ;; *) echo "Your OS was not detected correctly." exit 1 From 322c8c1cf3c2ce30df771168471c7d5408847637 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 4 Jan 2024 16:42:43 -0800 Subject: [PATCH 10/16] install php-sodium on al2. fix snipeit database name --- snipeit.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 0b8c91444..999cc6dc5 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -218,7 +218,7 @@ install_composer () { install_snipeit () { create_user echo "* Creating MariaDB Database/User." - mysql -u root --execute="CREATE DATABASE snipeit_dbuser;CREATE USER snipeit_dbuser@localhost IDENTIFIED BY '$mysqluserpw'; GRANT ALL PRIVILEGES ON snipeit.* TO snipeit_dbuser@localhost;" + mysql -u root --execute="CREATE DATABASE snipeit;CREATE USER snipeit_dbuser@localhost IDENTIFIED BY '$mysqluserpw'; GRANT ALL PRIVILEGES ON snipeit.* TO snipeit_dbuser@localhost;" 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=$! @@ -725,7 +725,7 @@ EOL amazon-linux-extras install -y php8.2 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" + 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 php-sodium" install_packages echo "* Configuring Apache." From 358d9ec06d526fb9849ed056fbd3d05802256939 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 4 Jan 2024 16:55:30 -0800 Subject: [PATCH 11/16] fix enterprise linux version in remi repo for v9 distros --- snipeit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snipeit.sh b/snipeit.sh index 999cc6dc5..552078035 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -846,7 +846,7 @@ EOL log "dnf -y install wget epel-release" & pid=$! log "yum -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm" & pid=$ progress - log "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8" + log "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9" log "dnf -y module enable php:remi-8.2" & pid=$! progress From 6fcb3d3d5e67ba6e4515dc685c55800452905838 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Thu, 4 Jan 2024 18:46:31 -0800 Subject: [PATCH 12/16] re-add missing progress bar to ensure correct command ordering --- snipeit.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snipeit.sh b/snipeit.sh index 552078035..0ae1e712a 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -844,7 +844,8 @@ EOL echo "* Adding EPEL-release repository." log "dnf -y install wget epel-release" & pid=$! - log "yum -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm" & pid=$ + progress + log "yum -y install https://rpms.remirepo.net/enterprise/remi-release-9.rpm" & pid=$! progress log "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el9" log "dnf -y module enable php:remi-8.2" & pid=$! From cdfc198f2821a372748ee55abfb29ccd05eb460f Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Fri, 5 Jan 2024 00:06:00 -0800 Subject: [PATCH 13/16] update changelog --- snipeit.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snipeit.sh b/snipeit.sh index 0ae1e712a..fd58e6fad 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -18,6 +18,9 @@ # Updated Snipe-IT Install Script # # Update created by Aaron Myers # # Change log # +# * add support for php8.2, awslinux2, alma 8/9 # +# * fix rocky8/9 support +# * remove Fedora support because short timelines # # * Added support for CentOS/Rocky 9 # # * Fixed CentOS 7 repository for PHP 7.4 # # * Removed support for CentOS 6 # From 585d7d0b87edd9dd7b6b79bebcfddd8bfcc91860 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Fri, 5 Jan 2024 12:09:03 -0800 Subject: [PATCH 14/16] replace some tabs with spaces. don't @ me --- snipeit.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index fd58e6fad..ba298c2ed 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -619,9 +619,9 @@ case $distro in set_dbpass tzone=$(cat /etc/timezone) - echo "* Set up Ondrej PHP repository" - echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C + echo "* Set up Ondrej PHP repository" + echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C echo -n "* Updating installed packages." log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$! @@ -680,8 +680,8 @@ Package: * Pin: release n=buster Pin-Priority: 750 EOL - echo "* Set up Ondrej PHP repository" - echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list + echo "* Set up Ondrej PHP repository" + echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu $codename main" >> /etc/apt/sources.list.d/ppa_ondrej_php_$codename.list echo -n "* Updating installed packages." log "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade" & pid=$! From 6129f4722f23ac4652aadc40d254a91188251f1b Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Mon, 8 Jan 2024 10:08:52 -0800 Subject: [PATCH 15/16] Oops! Don't checkout my custom branch using master until we make the switch to main. As master will keep working after we switch branches, main will _not_ work _until_ we switch, and if for some reason we have to delay the branch migration, this will remain broken until we fix it. --- snipeit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snipeit.sh b/snipeit.sh index ba298c2ed..97ed25643 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -227,7 +227,7 @@ install_snipeit () { log "git clone https://github.com/snipe/snipe-it $APP_PATH" & pid=$! progress pushd $APP_PATH - git checkout jerm/snipeit-sh + git checkout master popd echo "* Configuring .env file." From a3811371cc15f4459ad1c0d6165072a052abfe61 Mon Sep 17 00:00:00 2001 From: Jeremy Price Date: Mon, 8 Jan 2024 11:41:30 -0800 Subject: [PATCH 16/16] remove removal of installation scripts --- snipeit.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/snipeit.sh b/snipeit.sh index 97ed25643..06cb332f0 100755 --- a/snipeit.sh +++ b/snipeit.sh @@ -955,9 +955,6 @@ echo "" echo " ***Open http://$fqdn to login to Snipe-IT.***" echo "" echo "" -echo "* Cleaning up..." -# rm -f snipeit.sh -# rm -f install.sh echo "* Installation log located in $APP_LOG." echo "* Finished!" sleep 1