diff --git a/VERSION b/VERSION index 5cc4789..f1ad6a7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.02.02 +1.03 diff --git a/debian-installer.sh b/debian-installer.sh index 1f95e34..a1c1442 100644 --- a/debian-installer.sh +++ b/debian-installer.sh @@ -1,6 +1,6 @@ #!/bin/bash -INSTALLERVERSION="1.02.02" +INSTALLERVERSION="1.03" if [[ $(whoami) != "root" ]]; then echo "You must be root to run this script!" @@ -891,6 +891,7 @@ function downloadUpdate { function failMsg { echo "ERROR: $1" >&2 + echo "ERROR: $1" 2>> installer-errors.log exit 1 } @@ -1146,13 +1147,29 @@ if [[ $p -lt 6 ]]; then fi if [[ $p -lt 7 ]]; then + echo "Testing your domain $FQDN resolves to your server..." + json=$(curl -s "http://api.zaks.web.za/testhttp?address=$FQDN&https=false") + if [[ "$(echo "$json" | jq -r .status)" == "400" ]]; then + failMsg "$(echo "$json" | jq -r .data)" + fi + httpresult=$(echo "$json" | jq -r .http.result) + httpmessage=$(echo "$json" | jq -r .http.message) + if [[ "$httpresult" != "OK" ]]; then + failMsg "$httpmessage" + fi + echo "HTTP $httpresult" + ((p++)) + echo "$p" > position.temp +fi + +if [[ $p -lt 8 ]]; 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 8 ]]; then +if [[ $p -lt 9 ]]; 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..." @@ -1176,7 +1193,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 "Securing MariaDB (MySQL)..." doMariaDB || failMsg "Securing MariaDB failed..." @@ -1187,7 +1204,7 @@ if [[ $p -lt 9 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 10 ]]; then +if [[ $p -lt 11 ]]; 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..." @@ -1198,7 +1215,7 @@ if [[ $p -lt 10 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 11 ]]; then +if [[ $p -lt 12 ]]; 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..." @@ -1206,35 +1223,35 @@ if [[ $p -lt 11 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 12 ]]; then +if [[ $p -lt 13 ]]; 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 13 ]]; then +if [[ $p -lt 14 ]]; then echo "Creating custom PHP config specific for Nextcloud..." doPHP || failMsg "Custom PHP config failed..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 14 ]]; then +if [[ $p -lt 15 ]]; 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 15 ]]; then +if [[ $p -lt 16 ]]; then echo "Configuring coTURN server for Nextcloud Talk..." doTURN || failMsg "apt failed to Install coTURN..." ((p++)) echo "$p" > position.temp fi -if [[ $p -lt 16 ]]; then +if [[ $p -lt 17 ]]; then if [[ $AUTOSWAP = "true" ]]; then echo "Installing SWAP memory management tool..." doSWAP || failMsg "SWAP memory management tool failed to install..." @@ -1245,7 +1262,7 @@ if [[ $p -lt 16 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 17 ]]; then +if [[ $p -lt 18 ]]; 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 @@ -1259,7 +1276,7 @@ if [[ $p -lt 17 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 18 ]]; then +if [[ $p -lt 19 ]]; then echo "Installing Nextcloud... this could take a while..." oldpath=$(pwd) cd "/var/www/$NCWWW" @@ -1273,14 +1290,14 @@ if [[ $p -lt 18 ]]; then echo "$p" > position.temp fi -if [[ $p -lt 19 ]]; then +if [[ $p -lt 20 ]]; 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 20 ]]; then +if [[ $p -lt 21 ]]; then echo "Writing the Installation Report and cleaning up..." doREPORT rm -f position.temp