From f66f0a9288b1487ccb76d518c2b8c1384f6c5da0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 20:01:32 +0200 Subject: [PATCH] Apply example_ynh --- scripts/install | 47 ++++++++--------------------------------------- scripts/restore | 14 +++++++------- scripts/upgrade | 25 +++++++++++-------------- 3 files changed, 26 insertions(+), 60 deletions(-) diff --git a/scripts/install b/scripts/install index 1742320..5a99d22 100644 --- a/scripts/install +++ b/scripts/install @@ -125,16 +125,14 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC SETUP #================================================= -# PREPARE INSTALL +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Preparing install..." +ynh_script_progression --message="Adding a config file..." -config_file=$final_path/include/ost-config.php -cp -f ../conf/ost-sampleconfig.php "$config_file" +ynh_add_config --template="../conf/ost-sampleconfig.php" --destination="$final_path/include/ost-config.php" -admin_fname=$(ynh_user_get_info $admin 'firstname') -admin_lname=$(ynh_user_get_info $admin 'lastname') -admin_mail=$(ynh_user_get_info $admin 'mail') +chmod 400 "$final_path/include/ost-config.php" +chown $app:$app "$final_path/include/ost-config.php" #================================================= # BUILD PLUGINS @@ -179,18 +177,14 @@ rsync -a "../conf/i18n" "$final_path/include/." #================================================= ynh_script_progression --message="Setuping application with CURL..." -# Set right permissions for curl install -chown -R $app: $final_path - # Set the app as temporarily public for curl call ynh_script_progression --message="Configuring SSOwat..." # Making the app public for curl ynh_permission_update --permission="main" --add="visitors" -# Reload SSOwat config -yunohost app ssowatconf -# Reload Nginx -ynh_systemd_action --service_name=nginx --action=reload +admin_fname=$(ynh_user_get_info $admin 'firstname') +admin_lname=$(ynh_user_get_info $admin 'lastname') +admin_mail=$(ynh_user_get_info $admin 'mail') # Installation with curl ynh_script_progression --message="Finalizing installation..." @@ -199,17 +193,8 @@ ynh_local_curl "/setup/install.php" "s=install" "name=$app" "email=$app@$domain" # Remove the public access ynh_permission_update --permission="main" --remove="visitors" -#================================================= -# FINALIZE INSTALL -#================================================= -ynh_script_progression --message="Finalizing install..." - -# Removing setup folder ynh_secure_remove --file="$final_path/setup" -# Securing config file -chmod 0644 $config_file - #================================================= # SET THE CRON FILE #================================================= @@ -217,24 +202,8 @@ ynh_script_progression --message="Setting the cron file..." ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$config_file" - #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R $app: $final_path - #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/restore b/scripts/restore index e4dcf08..036881c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -85,6 +85,13 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC RESTORATION +#================================================= +# RESTORE THE CRON FILE +#================================================= +ynh_script_progression --message="Restoring the cron file..." + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -102,13 +109,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -#================================================= -# RESTORE THE CRON FILE -#================================================= -ynh_script_progression --message="Restoring the cron file..." - -ynh_restore_file --origin_path="/etc/cron.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 16f29bd..4eebc48 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -133,6 +133,16 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC UPGRADE +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a config file..." + +ynh_add_config --template="../conf/ost-sampleconfig.php" --destination="$final_path/include/ost-config.php" + +chmod 400 "$final_path/include/ost-config.php" +chown $app:$app "$final_path/include/ost-config.php" + #================================================= # BUILD PLUGINS #================================================= @@ -164,6 +174,7 @@ then #cp -f *.phar $final_path/include/plugins/. popd ynh_secure_remove --file="$final_path/include/plugins/build" + ynh_secure_remove --file="$final_path/setup" fi #================================================= @@ -173,20 +184,6 @@ ynh_script_progression --message="UPGRADING language..." rsync -a "../conf/i18n" "$final_path/include/." -#================================================= -# FINALIZE UPGRADE -#================================================= -ynh_script_progression --message="Finalizing install..." - -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - # Removing setup folder - ynh_secure_remove --file="$final_path/setup" - - # Securing config file - chmod 0644 $config_file -fi - #================================================= # SET THE CRON FILE #=================================================