From eed550223cd678571c4d50218231f4827d7011ac Mon Sep 17 00:00:00 2001 From: Papa Dragon Date: Tue, 28 Feb 2023 21:14:38 +0100 Subject: [PATCH] We try to clean things if the install fails (additions to "die" function) --- contrib/autoinstall/autoinstall.sh | 46 +++++++++++++++++++++++++-- contrib/autoinstall/scripts/debian.sh | 2 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/contrib/autoinstall/autoinstall.sh b/contrib/autoinstall/autoinstall.sh index 721422e9b..773e4b937 100755 --- a/contrib/autoinstall/autoinstall.sh +++ b/contrib/autoinstall/autoinstall.sh @@ -86,6 +86,41 @@ function check_sanity { } function die { + # We remove the website's apache conf files if they exist + if [ ! -z $vhost_added ] + then + a2dissite $domain_name.conf* + rm -f /etc/apache2/sites-available/$domain_name* + systemctl reload apache2 + fi + # We remove the website's nginx conf files if they exist + if [ ! -z $nginx_conf ] + then + rm -f /etc/nginx/sites-available/$domain_name* /etc/nginx/sites-enabled/$domain_name* + systemctl reload nginx + fi + # We delete database and database user if they exist + if [ ! -z $db_installed ] + then + mysql -h localhost -u root $opt_mysqlpass -e "DROP DATABASE $website_db_name; DROP USER $website_db_user@localhost;" + fi + # We remove the addons if they were downloaded + if [ ! -z $addons_installed ] + then + rm -rf $install_path/extend/addon/zaddons + rm -rf $install_path/addon/* + fi + # We remove the website's daily update script if it exists + if [ ! -z $daily_update_exists ] + then + rm -f /var/www/$daily_update + fi + # We remove .htconfig.php if it exists + if [ -f $install_path/.htconfig.php ] + then + rm -f $install_path/.htconfig.php ] + fi + echo -n -e '\e[1;31m' echo "ERROR: $1" > /dev/null 1>&2 echo -e '\e[0m' @@ -309,7 +344,14 @@ function install_website { if [ $repository = "streams" ] then print_info "Streams" - util/add_addon_repo https://codeberg.org/streams/streams-addons.git zaddons + if [ ! -d $install_path/extend/addon/zaddons ] + then + util/add_addon_repo https://codeberg.org/streams/streams-addons.git zaddons + else + print_warn "Streams addons already present, we'll remove them" + rm -rf $install_path/extend/addon/zaddons + rm -rf $install_path/addon/* + fi # elif [ $repository = "fork_1" ] # then # print_info "Fork_1" @@ -330,7 +372,7 @@ function install_website { chown -R www-data:www-data $install_path chown root:www-data $install_path/ print_info "installed addons" - db_installed=yes + addons_installed=yes } function configure_daily_update { diff --git a/contrib/autoinstall/scripts/debian.sh b/contrib/autoinstall/scripts/debian.sh index 0f3021c3c..279f21cdb 100644 --- a/contrib/autoinstall/scripts/debian.sh +++ b/contrib/autoinstall/scripts/debian.sh @@ -104,7 +104,7 @@ function vhost_le { print_info "run certbot ..." certbot --apache -w $install_path -d $domain_name -m $le_email --agree-tos --non-interactive --redirect --hsts --uir service apache2 restart - vhost_le_confgured=yes + vhost_le_configured=yes } function install_mysql {