From 9aa846d0f76e661ab9a3a761274178a9e8c48bc6 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 26 Nov 2020 18:54:25 +0530 Subject: [PATCH 1/7] fix save option --- sources/allnotes.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 sources/allnotes.json diff --git a/sources/allnotes.json b/sources/allnotes.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/sources/allnotes.json @@ -0,0 +1 @@ +[] \ No newline at end of file From 64739fc51f52a4254cb41f10626172d0b2ed9f96 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 26 Nov 2020 22:27:28 +0530 Subject: [PATCH 2/7] added php --- scripts/_common.sh | 2 +- scripts/backup | 6 ++++++ scripts/install | 25 ++++++++++++++++++++++++- scripts/remove | 19 +++++++++++++++++++ scripts/restore | 18 +++++++++++++----- scripts/upgrade | 32 ++++++++++++++++++++++++++++++-- 6 files changed, 93 insertions(+), 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..30b0afa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,7 +3,7 @@ #================================================= # COMMON VARIABLES #================================================= - +YNH_PHP_VERSION="7.3" #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index e9b4a77..3f9ef00 100644 --- a/scripts/backup +++ b/scripts/backup @@ -42,6 +42,12 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# BACKUP THE PHP-FPM CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 9ff9fc3..06cd3cc 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,11 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= @@ -63,11 +68,29 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=1 + +# Create a system user +ynh_system_user_create --username=$app + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring PHP-FPM..." + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + #================================================= # SECURE FILES AND DIRECTORIES #================================================= -chown -R www-data: $final_path +# Set right permissions for curl install +chown -R $app: $final_path #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 55b082a..28bb30b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -27,6 +27,15 @@ ynh_script_progression --message="Removing ChtickyNotes main directory..." --wei # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Removing php-fpm configuration..." --weight=1 + +# Remove the dedicated php-fpm config +ynh_remove_fpm_config + + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -35,6 +44,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_script_progression --message="Removing the dedicated system user..." --weight=1 + +# Delete a system user +ynh_system_user_delete --username=$app + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 38cd912..9ae435f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -51,27 +51,35 @@ ynh_script_progression --message="Restoring ChtickyNotes main directory..." --we ynh_restore_file --origin_path="$final_path" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app + #================================================= # RESTORE USER RIGHTS #================================================= # Restore permissions on app files -chown -R www-data: $final_path +chown -R $app: $final_path #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description "A short description of the app" --log "/var/log/$app/$app.log" +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +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 73862e1..7f89bf7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -60,13 +60,29 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading PHP-FPM configuration..." + +# Create a dedicated php-fpm config +ynh_add_fpm_config + + #================================================= # SECURE FILES AND DIRECTORIES #================================================= -mkdir -p $final_path cp -a ../sources/* $final_path -chown -R www-data: $final_path +chown -R $app: $final_path #================================================= # NGINX CONFIGURATION @@ -76,6 +92,18 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +fi + #================================================= # RELOAD NGINX #================================================= From 8b9bb7de105703279ce94de7fc25ad35c1f9dbc3 Mon Sep 17 00:00:00 2001 From: anmol26s Date: Thu, 26 Nov 2020 22:40:59 +0530 Subject: [PATCH 3/7] php fix --- scripts/install | 8 ++++---- scripts/upgrade | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index 06cd3cc..50d83cc 100644 --- a/scripts/install +++ b/scripts/install @@ -79,11 +79,11 @@ ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." + +# Create a dedicated php-fpm config +ynh_add_fpm_config --usage=low --footprint=low -# Create a dedicated PHP-FPM config -ynh_add_fpm_config -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SECURE FILES AND DIRECTORIES diff --git a/scripts/upgrade b/scripts/upgrade index 7f89bf7..29c6049 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -71,11 +71,10 @@ ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." - -# Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_script_progression --message="Configuring PHP-FPM..." +# Create a dedicated PHP-FPM config +ynh_add_fpm_config --usage=low --footprint=low #================================================= # SECURE FILES AND DIRECTORIES From b2d5a6853e2a200557f59776a2ef7cbcd97893ea Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Nov 2020 22:45:44 +0100 Subject: [PATCH 4/7] Add missiong PHP variable --- scripts/restore | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/restore b/scripts/restore index 9ae435f..15ed727 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED From 7a106f4cc3c26c4c237f2a2ffe8e941d9868421b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Nov 2020 22:50:04 +0100 Subject: [PATCH 5/7] Add missing PHP variable --- scripts/backup | 1 + scripts/restore | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 3f9ef00..2533458 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,6 +24,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP diff --git a/scripts/restore b/scripts/restore index 15ed727..72db01d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -78,7 +78,7 @@ ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." --weight=1 +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 From ef470028746091c8af5c947d5e7cc73081ace8a3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Nov 2020 22:51:22 +0100 Subject: [PATCH 6/7] remove --time --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 72db01d..080f407 100644 --- a/scripts/restore +++ b/scripts/restore @@ -55,7 +55,7 @@ ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) ynh_system_user_create --username=$app From 9b205f24ca09a744a6ad5a61211fd7bad1357ecf Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Thu, 26 Nov 2020 23:26:50 +0100 Subject: [PATCH 7/7] Add is_public --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 29c6049..1a6fccb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #=================================================