diff --git a/VERSION b/VERSION index 36c64ea..1010473 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.01.04 +1.02 diff --git a/debian-installer.sh b/debian-installer.sh index dc51355..aec0384 100644 --- a/debian-installer.sh +++ b/debian-installer.sh @@ -1,6 +1,6 @@ #!/bin/bash -INSTALLERVERSION="1.01.04" +INSTALLERVERSION="1.02" if [[ $(whoami) != "root" ]]; then echo "You must be root to run this script!" @@ -1091,7 +1091,7 @@ p=$(head -1 position.temp) if [[ $p -lt 2 ]]; then echo "Installing tools needed to complete the installation..." - apt -y install wget curl rsync screen wget sudo unzip > /dev/null 2>> installer-errors.log || failMsg "apt failed to install dependancies..." + apt -y install wget curl rsync screen wget sudo unzip jq > /dev/null 2>> installer-errors.log || failMsg "apt failed to install dependancies..." ((p++)) echo "$p" > position.temp fi @@ -1120,20 +1120,36 @@ if [[ $p -lt 4 ]]; then fi if [[ $p -lt 5 ]]; then + echo "Testing that Apache2 is accessible from the web..." + a2ensite default-ssl.conf > /dev/null 2>> installer-errors.log && systemctl reload apache2 > /dev/null 2>> installer-errors.log || failMsg "Apache2 failed to activate default SSL configuration..." + json=$(curl -s "http://api.zaks.web.za/testhttp") + httpresult=$(echo "$json" | jq -r .http.result) + httpsresult=$(echo "$json" | jq -r .https.result) + if [[ "$httpresult" != "OK" ]] || [[ "$httpsresult" != "OK" ]]; then + failMsg "HTTP=$httpresult HTTPS=$httpsresult" + fi + echo "HTTP $httpresult" + echo "HTTPS $httpsresult" + a2dissite default-ssl.conf > /dev/null 2>> installer-errors.log && systemctl reload apache2 > /dev/null 2>> installer-errors.log || failMsg "Apache2 failed to deactivate default SSL configuration..." + ((p++)) + echo "$p" > position.temp +fi + +if [[ $p -lt 6 ]]; then echo "Configuring Apache2 VHost file..." doVHost || failMsg "Apache2 failed to configure..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 6 ]]; then +if [[ $p -lt 7 ]]; then echo "Requesting SSL Certicate from Let's Encrypt..." certbot -n -m $EMAIL --agree-tos --apache -d $FQDN > /dev/null 2>> installer-errors.log || failMsg "Certbot failed to get an SSL Certicate from Let's Encrypt..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 7 ]]; then +if [[ $p -lt 8 ]]; then if [[ "$DBHOST" == "localhost" ]]; then echo "Installing MariaDB (MySQL)..." apt -y install mariadb-server mariadb-client > /dev/null 2>> installer-errors.log || failMsg "apt failed to install MariaDB..." @@ -1157,7 +1173,7 @@ if [[ $p -lt 7 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 8 ]]; then +if [[ $p -lt 9 ]]; then if [[ "$DBHOST" == "localhost" ]]; then echo "Securing MariaDB (MySQL)..." doMariaDB || failMsg "Securing MariaDB failed..." @@ -1168,7 +1184,7 @@ if [[ $p -lt 8 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 9 ]]; then +if [[ $p -lt 10 ]]; then if [[ "$DBHOST" == "localhost" ]]; then echo "Creating MySQL database for Nextcloud..." echo "CREATE DATABASE $DBNAME; CREATE USER $DBUSER@localhost IDENTIFIED BY '$DBPASS'; GRANT ALL PRIVILEGES ON $DBNAME.* TO $DBUSER@localhost; FLUSH PRIVILEGES;" | mysql > /dev/null 2>> installer-errors.log || failMsg "MariaDB failed to setup database for Nextcloud..." @@ -1179,7 +1195,7 @@ if [[ $p -lt 9 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 10 ]]; then +if [[ $p -lt 11 ]]; then echo "Adding Sury PHP Repo to Debian..." curl -sSL https://packages.sury.org/php/README.txt | bash -x > /dev/null 2>> installer-errors.log || failMsg "Sury PHP Repo failed to add to Debian..." apt update > /dev/null 2>> installer-errors.log || failMsg "apt failed to download Sury repo data..." @@ -1187,35 +1203,35 @@ if [[ $p -lt 10 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 11 ]]; then +if [[ $p -lt 12 ]]; then echo "Installing PHP8.3-FPM and CLI with all recommended extensions..." apt -y install php8.3-{ctype,curl,dom,gd,common,mysql,mbstring,opcache,posix,simplexml,xmlreader,xmlwriter,xmlrpc,xml,cli,zip,bz2,fpm,intl,ldap,smbclient,ftp,imap,bcmath,gmp,exif,apcu,memcached,redis,imagick} libapache2-mod-php8.3 libapache2-mod-fcgid libxml2 > /dev/null 2>> installer-errors.log || failMsg "apt failed to install PHP..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 12 ]]; then +if [[ $p -lt 13 ]]; then echo "Creating custom PHP config specific for Nextcloud..." doPHP || failMsg "Custom PHP config failed..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 13 ]]; then +if [[ $p -lt 14 ]]; then echo "Installing coTURN server for Nextcloud Talk..." apt -y install coturn > /dev/null 2>> installer-errors.log || failMsg "apt failed to Install coTURN..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 14 ]]; then +if [[ $p -lt 15 ]]; then echo "Configuring coTURN server for Nextcloud Talk..." doTURN || failMsg "apt failed to Install coTURN..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 15 ]]; then +if [[ $p -lt 16 ]]; then if [[ $AUTOSWAP = "true" ]]; then echo "Installing SWAP memory management tool..." doSWAP || failMsg "SWAP memory management tool failed to install..." @@ -1226,7 +1242,7 @@ if [[ $p -lt 15 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 16 ]]; then +if [[ $p -lt 17 ]]; then echo "Downloading and unpacking latest version of Nextcloud..." wget "https://download.nextcloud.com/server/releases/latest.zip" || failMsg "Nextcloud failed to download..." mkdir nextcloud @@ -1240,7 +1256,7 @@ if [[ $p -lt 16 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 17 ]]; then +if [[ $p -lt 18 ]]; then echo "Installing Nextcloud... this could take a while..." oldpath=$(pwd) cd "/var/www/$NCWWW" @@ -1254,14 +1270,14 @@ if [[ $p -lt 17 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 18 ]]; then +if [[ $p -lt 19 ]]; then echo "Removing any redundant packages..." apt -y autoremove > /dev/null 2>> installer-errors.log || failMsg "APT failed to remove redundant packages..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 19 ]]; then +if [[ $p -lt 20 ]]; then echo "Writing the Installation Report and cleaning up..." doREPORT rm -f position.temp