From 358c41c4897cd652463e889ab212947f3d50a24e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Sep 2020 18:03:25 +0200 Subject: [PATCH 1/7] Fix restore script --- conf/config.js | 16 ++-------------- conf/nginx.conf | 2 +- scripts/backup | 2 -- scripts/install | 8 +++----- scripts/restore | 11 +++++++++-- scripts/upgrade | 7 +++---- 6 files changed, 18 insertions(+), 28 deletions(-) diff --git a/conf/config.js b/conf/config.js index ba29d25..0825b96 100644 --- a/conf/config.js +++ b/conf/config.js @@ -1,17 +1,10 @@ { - - "host": "127.0.0.1", - + "host": "127.0.0.1", "port": __PORT__, - "keyLength": 10, - "maxLength": 400000, - "staticMaxAge": 86400, - "recompressStaticAssets": true, - "logging": [ { "level": "verbose", @@ -19,11 +12,9 @@ "colorize": true } ], - "keyGenerator": { "type": "phonetic" }, - "rateLimits": { "categories": { "normal": { @@ -32,14 +23,11 @@ } } }, - "storage": { "type": "file", "path": "__YNH_DATA_PATH__" }, - "documents": { "about": "./about.md" - } - + } } diff --git a/conf/nginx.conf b/conf/nginx.conf index 0579767..abd8968 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,7 +5,7 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - proxy_pass http://localhost:__PORT__; + proxy_pass http://127.0.0.1:__PORT__; proxy_set_header Host $host; proxy_buffering off; diff --git a/scripts/backup b/scripts/backup index e75918d..fef7284 100755 --- a/scripts/backup +++ b/scripts/backup @@ -46,8 +46,6 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP #================================================= # BACKUP LOGROTATE #================================================= diff --git a/scripts/install b/scripts/install index ab1fb44..5bf3377 100755 --- a/scripts/install +++ b/scripts/install @@ -121,9 +121,6 @@ data_path="/home/yunohost.app/${app}" # Create app folders mkdir -p "$data_path" -# Give permission to the datadir -chown -R $app:$app "$data_path" - #================================================= # CONFIGURE HASTE #================================================= @@ -149,7 +146,6 @@ ynh_replace_string --match_string="__YNH_HASTE_URL__" --replace_string="${domain ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/haste.sh" cp ../conf/haste.sh /usr/bin/$app -chmod +x /usr/bin/$app #================================================= # GENERIC FINALIZATION @@ -158,7 +154,9 @@ chmod +x /usr/bin/$app #================================================= chown -R root: $final_path -chown -R $app "$final_path/static" +chown -R $app: "$final_path/static" +chown -R $app: "$data_path" +chmod +x /usr/bin/$app #================================================= # HANDLE LOG FILES AND SETUP LOGROTATE diff --git a/scripts/restore b/scripts/restore index d408ca5..fc99240 100755 --- a/scripts/restore +++ b/scripts/restore @@ -85,13 +85,20 @@ systemctl enable $app.service ynh_restore_file "/home/yunohost.app/$app" +#================================================= +# RESTORE BINARY +#================================================= + +ynh_restore_file --origin_path="/usr/bin/$app" + #================================================= # SECURE FILES AND DIRECTORIES #================================================= chown -R root: $final_path -chown -R $app "$final_path/static" -chown -R $app "/home/yunohost.app/$app" +chown -R $app: "$final_path/static" +chown -R $app: "/home/yunohost.app/$app" +chmod +x /usr/bin/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/scripts/upgrade b/scripts/upgrade index cfd132d..4db3213 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -171,8 +171,6 @@ ynh_replace_string --match_string="__YNH_HASTE_URL__" --replace_string="${domain cp ../conf/haste.sh /usr/bin/$app -chmod +x /usr/bin/$app - #================================================= # GENERIC FINALIZATION #================================================= @@ -180,8 +178,9 @@ chmod +x /usr/bin/$app #================================================= chown -R root: $final_path -chown -R $app "$final_path/static" -chown -R $app "$data_path" +chown -R $app: "$final_path/static" +chown -R $app: "$data_path" +chmod +x /usr/bin/$app #================================================= # START SYSTEMD SERVICE From 9240267ad4929ca3579c4e156bbe799f7961f406 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Sep 2020 18:42:57 +0200 Subject: [PATCH 2/7] fix --- scripts/backup | 7 ++++--- scripts/restore | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/backup b/scripts/backup index fef7284..6220ac4 100755 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,10 @@ 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 @@ -32,8 +35,6 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= ynh_print_info --message="Declaring files to be backed up..." -#================================================= -# STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index fc99240..2f880fb 100755 --- a/scripts/restore +++ b/scripts/restore @@ -111,7 +111,7 @@ yunohost service add $app --description "Haste is an open-source pastebin softwa #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="haste@0.1.0 start" #================================================= # RESTORE THE LOGROTATE CONFIGURATION @@ -122,7 +122,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX #================================================= ynh_script_progression --message="Reloading NGINX web server..." --weight=1 From ac7eb007f13db68bf4492a05a604adba0acafdad Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Sep 2020 19:08:32 +0200 Subject: [PATCH 3/7] Update restore --- scripts/restore | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 2f880fb..283d0d1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,6 +91,15 @@ ynh_restore_file "/home/yunohost.app/$app" ynh_restore_file --origin_path="/usr/bin/$app" +#================================================= +# ADD SYSTEMD SERVICE +#================================================= + +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" + +ynh_add_systemd_config + #================================================= # SECURE FILES AND DIRECTORIES #================================================= @@ -111,7 +120,7 @@ yunohost service add $app --description "Haste is an open-source pastebin softwa #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="haste@0.1.0 start" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RESTORE THE LOGROTATE CONFIGURATION From 6c4a5a37705bc98af9d2c49d3e9b93c05e5f32e8 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Sep 2020 19:28:04 +0200 Subject: [PATCH 4/7] Revert "Update restore" This reverts commit ac7eb007f13db68bf4492a05a604adba0acafdad. --- scripts/restore | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/scripts/restore b/scripts/restore index 283d0d1..2f880fb 100755 --- a/scripts/restore +++ b/scripts/restore @@ -91,15 +91,6 @@ ynh_restore_file "/home/yunohost.app/$app" ynh_restore_file --origin_path="/usr/bin/$app" -#================================================= -# ADD SYSTEMD SERVICE -#================================================= - -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service" - -ynh_add_systemd_config - #================================================= # SECURE FILES AND DIRECTORIES #================================================= @@ -120,7 +111,7 @@ yunohost service add $app --description "Haste is an open-source pastebin softwa #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="haste@0.1.0 start" #================================================= # RESTORE THE LOGROTATE CONFIGURATION From 832c9716d68a33d1a7d62826e4a4f53dfd01b2d5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Sep 2020 20:58:26 +0200 Subject: [PATCH 5/7] Update restore --- scripts/restore | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/restore b/scripts/restore index 2f880fb..f643cc6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -61,7 +61,7 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC RESTORE @@ -71,14 +71,6 @@ ynh_system_user_create --username=$app ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 - -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service - #================================================= # RESTORE VARIOUS FILES #================================================= @@ -106,12 +98,20 @@ chmod +x /usr/bin/$app yunohost service add $app --description "Haste is an open-source pastebin software" --log "/var/log/$app/$app.log" +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 + +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +systemctl enable $app.service + #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="haste@0.1.0 start" +ynh_systemd_action --service_name=$app --action="start" #--log_path="/var/log/$app/$app.log" #================================================= # RESTORE THE LOGROTATE CONFIGURATION From 01b1971950e0e7e1d09b4f259736c3f263bb8296 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Sep 2020 21:02:36 +0200 Subject: [PATCH 6/7] Update restore --- scripts/restore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/restore b/scripts/restore index f643cc6..11accd7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -92,6 +92,14 @@ chown -R $app: "$final_path/static" chown -R $app: "/home/yunohost.app/$app" chmod +x /usr/bin/$app +#================================================= +# RESTORE HANDLE LOG FILES +#================================================= + +mkdir -p /var/log/$app +touch /var/log/$app/$app.log +chown $app -R /var/log/$app + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= From a1f36e1d76ce0bdfe4ed14a6085212507584ecee Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 6 Sep 2020 21:27:15 +0200 Subject: [PATCH 7/7] Cleaning up --- scripts/backup | 5 +---- scripts/restore | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/backup b/scripts/backup index 6220ac4..60b4845 100755 --- a/scripts/backup +++ b/scripts/backup @@ -13,10 +13,7 @@ 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 diff --git a/scripts/restore b/scripts/restore index 11accd7..f2cff50 100755 --- a/scripts/restore +++ b/scripts/restore @@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -119,7 +116,7 @@ systemctl enable $app.service #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" #--log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RESTORE THE LOGROTATE CONFIGURATION