From 6861e926e4610e3149bc455736143c20d302e962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 13 Mar 2024 00:11:05 +0100 Subject: [PATCH] Small cleanup of version 2 --- scripts/_common.sh | 2 ++ scripts/backup | 2 -- scripts/change_url | 2 -- scripts/install | 22 +++++++--------------- scripts/remove | 6 ++---- scripts/restore | 28 +++++++++------------------- scripts/upgrade | 38 ++++++++++---------------------------- 7 files changed, 30 insertions(+), 70 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6ef0bd5..e3f872c 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,8 @@ # COMMON VARIABLES #================================================= +timezone="$(cat /etc/timezone)" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 6e6e2e6..f02ce67 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index 9f98084..f982d21 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 544898b..bfb90b7 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,12 +7,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -timezone="$(cat /etc/timezone)" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -24,17 +16,17 @@ ynh_script_progression --message="Setting up source files..." --weight=2 ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" -chmod -R g+w $install_dir/app/config/ -chmod -R g+w $install_dir/media/files/ -chmod -R g+w $install_dir/media/images/ -chmod -R g+w $install_dir/translations/ +chmod -R g+w "$install_dir/app/config/" +chmod -R g+w "$install_dir/media/files/" +chmod -R g+w "$install_dir/media/images/" +chmod -R g+w "$install_dir/translations/" #================================================= -# PHP-FPM CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config diff --git a/scripts/remove b/scripts/remove index a18a484..3a4f117 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,9 +8,9 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE NGINX CONFIGURATION +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index da7640f..35b2589 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,12 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -timezone="$(cat /etc/timezone)" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -24,24 +16,24 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" -chmod -R g+w $install_dir/app/config/ -chmod -R g+w $install_dir/media/files/ -chmod -R g+w $install_dir/media/images/ -chmod -R g+w $install_dir/translations/ +chmod -R g+w "$install_dir/app/config/" +chmod -R g+w "$install_dir/media/files/" +chmod -R g+w "$install_dir/media/images/" +chmod -R g+w "$install_dir/translations/" #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=2 -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql #================================================= -# RESTORE THE PHP-FPM CONFIGURATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 +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" @@ -50,14 +42,12 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX 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="php$phpversion-fpm" --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f3837c7..556aa0f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,42 +7,26 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -timezone="$(cat /etc/timezone)" - -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 - - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" -fi +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" -chmod -R g+w $install_dir/app/config/ -chmod -R g+w $install_dir/media/files/ -chmod -R g+w $install_dir/media/images/ -chmod -R g+w $install_dir/translations/ +chmod -R g+w "$install_dir/app/config/" +chmod -R g+w "$install_dir/media/files/" +chmod -R g+w "$install_dir/media/images/" +chmod -R g+w "$install_dir/translations/" #================================================= -# PHP-FPM CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config