From fef61b5470e62402f527750fd1a0821b7e7333e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 16 Oct 2022 14:09:33 +0200 Subject: [PATCH] Testing (#37) * Fix check_process warning * Update change_url * Update manifest.json * Fix linter warning * Update remove * Set badge in SVG * Use SVG for badge * Finding an available port * Patch (#21) * Fix linter warnings * Small fixes * Cleaning up * Update manifest.json * Cleaning up * Fix badges * [autopatch] Update issue and PR templates (#25) Co-authored-by: Yunohost-Bot <> * Add templates * Fix * Update restore * Fix * Update install * Fix * Update check_process * Patch (#27) * Fix * Auto-update README * Update systemd.service * Update nginx.conf Co-authored-by: Yunohost-Bot <> * Update manifest.json * 4.3 * Fix ynh_npm * Add purge option * Auto-update README * Update version (#30) * update * Auto-update README Co-authored-by: Yunohost-Bot <> * Upgrade (#32) * Fix * Auto-update README Co-authored-by: yunohost-bot * Update _common.sh (#34) * Update _common.sh * Fix * cleaning up * Update manifest.json * Auto-update README * Auto-update README * set relative path for --keep opt * Auto-update README * Update manifest.json * Auto-update README * Upgrade to upstream * Auto-update README * Reorder script * Update restore Co-authored-by: Alexandre Aubin Co-authored-by: YunoHost Bot Co-authored-by: Yunohost-Bot <> Co-authored-by: yunohost-bot Co-authored-by: yalh76 --- README.md | 3 +-- README_fr.md | 3 +-- conf/app.src | 4 ++-- manifest.json | 2 +- scripts/install | 18 ++++++++--------- scripts/restore | 34 ++++++++++++++----------------- scripts/upgrade | 53 ++++++++++++++++++++++++------------------------- 7 files changed, 55 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 865ec6e..18d7bf5 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Haste is an open-source pastebin software written in node.js, which is easily installable in any network. YunoHost Project uses Haste as pastebin for log sharing: [paste.yunohost.org](https://paste.yunohost.org/) -**Shipped version:** 0.1.0~ynh12 - +**Shipped version:** 0.1.0~ynh13 **Demo:** http://hastebin.com/ diff --git a/README_fr.md b/README_fr.md index b485d60..0ca82a2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -18,8 +18,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Haste est un logiciel pastebin open-source écrit en node.js, facilement installable sur n'importe quel réseau. Le projet YunoHost utilise Haste comme pastebin pour le partage de log : [paste.yunohost.org](https://paste.yunohost.org/) -**Version incluse :** 0.1.0~ynh12 - +**Version incluse :** 0.1.0~ynh13 **Démo :** http://hastebin.com/ diff --git a/conf/app.src b/conf/app.src index c2f6e6f..280fea2 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/seejohnrun/haste-server/archive/72863858338a57d54eb9dee55530e90ebbc22453.tar.gz -SOURCE_SUM=0a9cfd42748e4410a3aa340d99ed6473962a013e9d5607b86121c32d5e0a5dd8 +SOURCE_URL=https://github.com/seejohnrun/haste-server/archive/7c65fb2f9b2e4b292e03c5d70957431bcc27d2c0.tar.gz +SOURCE_SUM=8d420e2b47a640b38230114551ddffe86489cb6607af0659740385e6a9e36ebd SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 586c845..e68fac5 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Open-source pastebin allowing to upload texts", "fr": "Pastebin open-source permettant de mettre en ligne du texte" }, - "version": "0.1.0~ynh12", + "version": "0.1.0~ynh13", "url": "http://hastebin.com/", "upstream": { "license": "MIT", diff --git a/scripts/install b/scripts/install index db3dbb8..aadca27 100755 --- a/scripts/install +++ b/scripts/install @@ -56,6 +56,14 @@ ynh_script_progression --message="Finding an available port..." --weight=2 port=$(ynh_find_port --port=7777) ynh_app_setting_set --app=$app --key=port --value=$port +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -73,14 +81,6 @@ 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=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # SPECIFIC SETUP #================================================= @@ -115,7 +115,7 @@ popd ynh_script_progression --message="Creating the data directory..." --weight=1 # Define app's data directory -data_path="/home/yunohost.app/${app}" +data_path=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=data_path --value=$data_path # Create app folders diff --git a/scripts/restore b/scripts/restore index 3ff4e61..9fe4ea3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,16 +33,18 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path || ynh_die "There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS #================================================= -# RESTORE THE NGINX CONFIGURATION +# RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR @@ -51,13 +53,16 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC RESTORE @@ -88,15 +93,6 @@ chown -R $app:www-data "$data_path" ynh_script_progression --message="Restoring various files..." --weight=1 ynh_restore_file --origin_path="/usr/bin/$app" - -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" -chown -R $app: "$data_path" chmod +x /usr/bin/$app #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index cb8eb0a..86f523a 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,6 +27,27 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -52,28 +73,15 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= -# STOP SYSTEMD SERVICE +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -95,14 +103,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # SPECIFIC UPGRADE #================================================= @@ -135,8 +135,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" - +env_path="$PATH" ynh_add_systemd_config #=================================================