diff --git a/scripts/change_url b/scripts/change_url index 690b1ba..b61cc1e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_change_url_nginx_config diff --git a/scripts/install b/scripts/install index bb35bdd..ded9798 100644 --- a/scripts/install +++ b/scripts/install @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" @@ -22,27 +22,30 @@ chmod -R u+rwX $install_dir/{cache/,data/,pagecache/,tmp/} chown -R $app:www-data "$install_dir" #================================================= -# PHP-FPM CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." - # Create a dedicated NGINX config ynh_add_nginx_config +# Use logrotate to manage application logfile(s) +touch "$install_dir/data/log.txt" +ynh_use_logrotate "$install_dir/data/log.txt" --specific_user=$app +chown $app:www-data "$install_dir/data/log.txt" + +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="$install_dir/data/log.txt" --failregex="\s-\s\s-\sLogin failed for user.*$" + #================================================= # SPECIFIC SETUP #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." +ynh_script_progression --message="Adding a configuration file..." --weight=1 # Get the timezone timezone=$(cat /etc/timezone) @@ -68,26 +71,6 @@ fi ynh_add_config --template="../conf/config.json.php" --destination="$install_dir/data/config.json.php" chmod 700 "$install_dir/data/config.json.php" -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." - -# Use logrotate to manage application logfile(s) -touch "$install_dir/data/log.txt" -ynh_use_logrotate "$install_dir/data/log.txt" --specific_user=$app -chown $app:www-data "$install_dir/data/log.txt" - -#================================================= -# SETUP FAIL2BAN -#================================================= -ynh_script_progression --message="Configuring Fail2Ban..." - -# Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="$install_dir/data/log.txt" --failregex="\s-\s\s-\sLogin failed for user.*$" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 2a465b1..cbf88da 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" @@ -23,41 +23,28 @@ chown -R $app:www-data "$install_dir" chmod 700 "$install_dir/data/config.json.php" #================================================= -# RESTORE FAIL2BAN CONFIGURATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the Fail2Ban configuration..." +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_systemd_action --action=restart --service_name=fail2ban -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 4e7d128..f574c9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ upgrade_type=$(ynh_check_app_version_changed) if [ "$upgrade_type" == "UPGRADE_APP" ] || [ "$upgrade_type" == "UPGRADE_FORCED" ] # we should do that during a force upgrade too (as it could lead to a version upgrade for instance) then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=1 # Create a temporary directory tmpdir="$(mktemp -d)" @@ -46,28 +46,16 @@ chown -R $app:www-data "$install_dir" chmod 700 "$install_dir/data/config.json.php" #================================================= -# PHP-FPM CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - # Use logrotate to manage app-specific logfile(s) # Temporary fix for .txt log file and ynh_use_logrotate if [ -d "$install_dir/data/log.txt" ] @@ -79,11 +67,6 @@ chown $app:www-data "$install_dir/data/log.txt" ynh_use_logrotate --non-append --specific_user=$app -#================================================= -# UPGRADE FAIL2BAN -#================================================= -ynh_script_progression --message="Reconfiguring Fail2Ban..." - # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="$install_dir/data/log.txt" --failregex="\s-\s\s-\sLogin failed for user.*$"