From 481c0c5ce62caa9c79a6bd536f390f3814128b3a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 23 Mar 2021 20:16:47 +0100 Subject: [PATCH] Various fix --- manifest.json | 12 ------------ scripts/_common.sh | 2 +- scripts/backup | 2 +- scripts/change_url | 5 +++-- scripts/install | 14 +++++++------- scripts/remove | 2 +- scripts/restore | 8 ++++---- scripts/upgrade | 14 +++++++------- 8 files changed, 24 insertions(+), 35 deletions(-) diff --git a/manifest.json b/manifest.json index 0c5b69a..b3f59d0 100644 --- a/manifest.json +++ b/manifest.json @@ -24,29 +24,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Distbin", - "fr": "Choisissez un nom de domaine pour Distbin" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Distbin", - "fr": "Choisissez un chemin pour Distbin" - }, "example": "/distbin", "default": "/distbin" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true } ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 810d633..0d2ca6e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ # dependencies used by the app pkg_dependencies="ca-certificates curl sudo" -nodejs_version=10 +NODEJS_VERSION=10 #================================================= # PERSONAL HELPERS diff --git a/scripts/backup b/scripts/backup index 2d2d5ef..5146c2b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers diff --git a/scripts/change_url b/scripts/change_url index cb80a0e..b934598 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,15 +33,16 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script diff --git a/scripts/install b/scripts/install index 4007e59..1005197 100644 --- a/scripts/install +++ b/scripts/install @@ -65,7 +65,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies -ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -81,7 +81,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -90,7 +90,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username="$app" --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # SPECIFIC SETUP @@ -120,13 +120,13 @@ chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts - sudo -u $app $ynh_node_load_PATH $ynh_npm run build + ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts + ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm run build cp package* dist/ popd pushd $final_path/dist - sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production + ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production popd #================================================= @@ -152,7 +152,7 @@ ynh_add_config --template="../conf/.env" --destination="$final_path/.env" ynh_script_progression --message="Securing files and directories..." # Set permissions to app files -chown -R "$app":"$app" "$final_path" +chown -R $app:$app $final_path #================================================= # SETUP LOGROTATE diff --git a/scripts/remove b/scripts/remove index ca83f0c..cd37d47 100644 --- a/scripts/remove +++ b/scripts/remove @@ -26,7 +26,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then ynh_script_progression --message="Removing $app service integration..." diff --git a/scripts/restore b/scripts/restore index 3556fb1..78afd1b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -46,7 +46,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -71,7 +71,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files -chown -R $app:$app "$final_path" +chown -R $app:$app $final_path #================================================= # CREATE LOG FOLDER @@ -90,7 +90,7 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies -ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index cd015c3..6f1a9c4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,9 +48,9 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # restore it if the upgrade fails ynh_restore_upgradebackup - ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -90,7 +90,7 @@ ynh_add_nginx_config ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION #================================================= # CREATE DEDICATED USER @@ -130,13 +130,13 @@ chown -R "$app":"$app" "$final_path" pushd $final_path ynh_use_nodejs - sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts - sudo -u $app $ynh_node_load_PATH $ynh_npm run build + ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts + ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm run build cp package* dist/ popd pushd $final_path/dist - sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production + ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production popd #================================================= @@ -148,9 +148,9 @@ ynh_script_progression --message="Upgrading systemd configuration..." ynh_add_systemd_config #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying config file..." +ynh_script_progression --message="Updating a config file..." ynh_add_config --template="../conf/.env" --destination="$final_path/.env"