From a5c254dde3372ad6ba5da0e7fbb56cbd74c39105 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 28 Sep 2022 03:49:45 +0200 Subject: [PATCH] Apply last example_ynh --- conf/app.src | 2 +- conf/systemd.service | 4 ++-- ...panel.toml.exemple => config_panel.toml.example | 0 scripts/_common.sh | 8 ++++---- scripts/backup | 3 +++ scripts/change_url | 3 +-- scripts/install | 10 +++++----- scripts/remove | 8 ++++---- scripts/restore | 14 +++++++------- scripts/upgrade | 9 ++++----- 10 files changed, 31 insertions(+), 30 deletions(-) rename config_panel.toml.exemple => config_panel.toml.example (100%) diff --git a/conf/app.src b/conf/app.src index 51159f6..1328508 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,7 @@ SOURCE_URL=https://github.com/ether/etherpad-lite/archive/1.8.18.tar.gz SOURCE_SUM=67ccc0bac94e146b26fbddcf8330e0f543a4ff82213c420a376644614a7ff2c4 SOURCE_SUM_PRG=sha256sum -ARCH_FORMAT=tar.gz +SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_FILENAME= SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 6c5ff08..863f647 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -15,7 +15,7 @@ StandardError=inherit Restart=always # Sandboxing options to harden security -# Depending on specificities of your service/app, you may need to tweak these +# Depending on specificities of your service/app, you may need to tweak these # .. but this should be a good baseline # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html NoNewPrivileges=yes @@ -42,7 +42,7 @@ CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW -CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG +CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG [Install] WantedBy=multi-user.target diff --git a/config_panel.toml.exemple b/config_panel.toml.example similarity index 100% rename from config_panel.toml.exemple rename to config_panel.toml.example diff --git a/scripts/_common.sh b/scripts/_common.sh index 85ecdc7..9d6ae90 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -35,10 +35,6 @@ ep_font_size_version=0.4.44 # PERSONAL HELPERS #================================================= -#================================================= -# FUTUR OFFICIAL HELPERS -#================================================= - #================================================= # EXPERIMENTAL HELPERS #================================================= @@ -400,3 +396,7 @@ ynh_app_changelog () { echo "No significative changes from the changelog..." > "${final_changelog}_lite" fi } + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 42d7600..73519a8 100644 --- a/scripts/backup +++ b/scripts/backup @@ -14,6 +14,9 @@ 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 diff --git a/scripts/change_url b/scripts/change_url index 07725a9..fecc25e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -45,7 +45,6 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma # 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" @@ -124,7 +123,7 @@ ynh_systemd_action --service_name=$app --action=restart --line_match="You can ac #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index d0db0b6..b092207 100644 --- a/scripts/install +++ b/scripts/install @@ -18,7 +18,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -42,7 +42,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=1 if [ "${#password}" -lt 8 ] || [ "${#password}" -gt 30 ] then @@ -109,7 +109,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_script_progression --message="Creating a MySQL database..." +ynh_script_progression --message="Creating a MySQL database..." --weight=1 db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name @@ -144,7 +144,7 @@ ynh_add_nginx_config #================================================= # HANDLE LOG FILES AND LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." --weight=1 # Create log directory mkdir -p /var/log/$app @@ -250,7 +250,7 @@ popd if [ $mypads -eq 1 ] then - ynh_script_progression --message="Some hacks..." + ynh_script_progression --message="Some hacks..." --weight=1 # Add a link to Etherpad to allow anonymous pads creation from MyPads. ynh_replace_string --match_string="^ *\"DESCRIPTION\": .*" --replace_string="&Pads anonymes" --target_file=$final_path/node_modules/ep_mypads/static/l10n/fr.json diff --git a/scripts/remove b/scripts/remove index a95f897..676b806 100755 --- a/scripts/remove +++ b/scripts/remove @@ -47,7 +47,7 @@ ynh_remove_systemd_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate @@ -63,7 +63,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -79,7 +79,7 @@ ynh_remove_nginx_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." --weight=1 if [ "$export" != "none" ] then @@ -102,7 +102,7 @@ ynh_remove_fail2ban_config #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." +ynh_script_progression --message="Removing various files..." --weight=1 # Remove the log files ynh_secure_remove --file="/var/log/$app" diff --git a/scripts/restore b/scripts/restore index 6a72769..3f33f3e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -40,7 +40,7 @@ password=$(ynh_app_setting_get --app=$app --key=password) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -99,7 +99,7 @@ ynh_use_nodejs #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server 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" @@ -124,7 +124,7 @@ chown $app -R /var/log/$app #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet @@ -132,14 +132,14 @@ systemctl enable $app.service --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="Collaborative editor" --log="/var/log/$app/etherpad.log" @@ -155,7 +155,7 @@ ynh_systemd_action --service_name=$app --action=restart --line_match="You can ac #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --action=reload --service_name=nginx diff --git a/scripts/upgrade b/scripts/upgrade index 52a2f53..cb2e0c5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,7 +45,7 @@ pad_config_show_markdown=$(ynh_app_setting_get --app=$app --key=pad_config_show_ #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." +ynh_script_progression --message="Checking version..." --weight=1 # Wait for etherpad to be fully started ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" @@ -60,7 +60,6 @@ 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 } @@ -180,7 +179,7 @@ ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." +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 --home_dir="$final_path" @@ -392,7 +391,7 @@ ynh_use_logrotate --non-append --specific_user=$app/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="Collaborative editor" --log="/var/log/$app/etherpad.log" @@ -414,7 +413,7 @@ ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failrege #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload