From 28a8b0ed852acf791d30c0f096d34ef7965d4a50 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 02:58:19 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- manifest.toml | 3 ++- scripts/_common.sh | 14 +------------- scripts/backup | 17 ++++------------- scripts/config | 19 +++++-------------- scripts/install | 39 ++++++++++++++++----------------------- scripts/remove | 12 +++--------- scripts/restore | 27 +++++++++------------------ scripts/upgrade | 28 ++++++---------------------- 8 files changed, 46 insertions(+), 113 deletions(-) diff --git a/manifest.toml b/manifest.toml index 9ec9dd4..a0a7017 100644 --- a/manifest.toml +++ b/manifest.toml @@ -16,7 +16,8 @@ admindoc = "https://www.samba.org/samba/docs/" code = "https://git.samba.org/?p=samba.git;a=summary" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.18" +helpers_version = "2.1" architectures = "all" multi_instance = false diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..3d7f008 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,17 +1,5 @@ #!/bin/bash #================================================= -# COMMON VARIABLES -#================================================= - -#================================================= -# PERSONAL HELPERS -#================================================= - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS +# COMMON VARIABLES AND CUSTOM HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index d2db266..cd689f8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,34 +1,25 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # 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 -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$data_dir" --is_big +ynh_backup "$data_dir" #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/config b/scripts/config index 55f35ed..e7ce35a 100644 --- a/scripts/config +++ b/scripts/config @@ -8,18 +8,12 @@ # (validation of several interdependent fields, specific getter/setter for a value, # display dynamic informations or choices, pre-loading of config type .cube... ). -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source /usr/share/yunohost/helpers -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors -data_dir=$(ynh_app_setting_get --app=$app --key=data_dir) -install_dir=$(ynh_app_setting_get --app=$app --key=install_dir) +data_dir=$(ynh_app_setting_get --key=data_dir) +install_dir=$(ynh_app_setting_get --key=install_dir) #================================================= # recreate the smb.conf from smb.conf.d @@ -35,7 +29,6 @@ EOF cat $install_dir/smb.conf.d/*.conf >> $install_dir/smb.conf } - #================================================= # SPECIFIC SETTERS FOR TOML SHORT KEYS #================================================= @@ -56,7 +49,7 @@ set__directories() { # Create the directory mkdir -p $data_dir/$directory - chmod 750 "$data_dir/$directory" + #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$data_dir/$directory" chmod -R o-rwx "$data_dir/$directory" chown -R root:root "$data_dir/$directory" setfacl -R -m g:samba.$directory:rwx,d:g:samba.$directory:rwx $data_dir/$directory @@ -85,7 +78,7 @@ END # Remove configuration for unlisted directories for directory in $(find $install_dir/smb.conf.d/ -maxdepth 1 -type f -not -name '0-global.conf' -exec basename {} \;); do if ! [[ "${directory%.conf}" =~ $(echo "^($(echo $directories | sed 's/,\| /|/g'))$") ]]; then - ynh_secure_remove "$install_dir/smb.conf.d/$directory" + ynh_safe_rm "$install_dir/smb.conf.d/$directory" fi done @@ -123,7 +116,5 @@ set__unbrowseable() { write_smb_conf } -#================================================= -# GENERIC FINALIZATION #================================================= ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index 4edf583..29eac98 100755 --- a/scripts/install +++ b/scripts/install @@ -1,30 +1,24 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression "Storing installation settings..." -ynh_app_setting_set --app=$app --key=directories --value=share -ynh_app_setting_set --app=$app --key=advanced --value=0 -ynh_app_setting_set --app=$app --key=readonly_dir --value='' -ynh_app_setting_set --app=$app --key=unbrowseable --value='' +ynh_app_setting_set --key=directories --value=share +ynh_app_setting_set --key=advanced --value=0 +ynh_app_setting_set --key=readonly_dir --value='' +ynh_app_setting_set --key=unbrowseable --value='' #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 +ynh_script_progression "Creating a data directory..." -chmod 750 "$data_dir/share" +#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$data_dir/share" chmod -R o-rwx "$data_dir/share" chown -R root:root "$data_dir/share" setfacl -R -m g:samba.share:rwx,d:g:samba.share:rwx $data_dir/share @@ -32,14 +26,15 @@ setfacl -R -m g:samba.share:rwx,d:g:samba.share:rwx $data_dir/share #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding $app's configuration..." mkdir -p $install_dir/smb.conf.d -ynh_add_config --template="global-smb.conf" --destination="$install_dir/smb.conf.d/0-global.conf" -ynh_add_config --template="share-smb.conf" --destination="$install_dir/smb.conf.d/share.conf" +ynh_config_add --template="global-smb.conf" --destination="$install_dir/smb.conf.d/0-global.conf" +ynh_config_add --template="share-smb.conf" --destination="$install_dir/smb.conf.d/share.conf" cat > $install_dir/smb.conf </dev/null +if ynh_hide_warnings yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." --weight=1 + ynh_script_progression "Removing $app service integration..." yunohost service remove smbd fi @@ -26,4 +20,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index ba15529..f45a3c1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - # 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 @@ -15,25 +9,24 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression "Restoring the app main directory..." -ynh_restore_file --origin_path="$install_dir" - -chown -R root:root "$install_dir" +ynh_restore "$install_dir" +#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R root:root "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression "Restoring the data directory..." -ynh_restore_file --origin_path="$data_dir" --not_mandatory +ynh_restore "$data_dir" chown -R root:root "$data_dir" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." # Don't add --needs_exposed_ports 445 , we don't want a remote diagnosis here yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports $port @@ -41,14 +34,12 @@ yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smb #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=10 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=smbd --action="start" +ynh_systemctl --service=smbd --action="start" -#================================================= -# GENERIC FINALIZATION #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 31da8bf..3dffc33 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,35 +1,19 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=4 +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=smbd --action="stop" +ynh_systemctl --service=smbd --action="stop" -#================================================= -# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression "Integrating service in YunoHost..." # Don't add --needs_exposed_ports 445 , we don't want a remote diagnosis here yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smbd.log" --needs_exposed_ports $port @@ -37,12 +21,12 @@ yunohost service add smbd --description="Samba service" --log="/var/log/smbd/smb #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name=smbd --action="start" +ynh_systemctl --service=smbd --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"