From 35cdfc767997b7a4379532bcda18f0189ae4a858 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 31 Aug 2024 03:55:56 +0200 Subject: [PATCH] [autopatch] Automatic patch attempt for helpers 2.1 --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + conf/systemd.service | 4 ++-- doc/.DS_Store | Bin 6148 -> 0 bytes manifest.toml | 3 ++- scripts/_common.sh | 14 +---------- scripts/backup | 23 ++++++------------ scripts/change_url | 24 ++++++------------- scripts/install | 48 ++++++++++++++++---------------------- scripts/remove | 18 +++++---------- scripts/restore | 41 ++++++++++++++------------------ scripts/upgrade | 54 +++++++++++++++---------------------------- 12 files changed, 82 insertions(+), 148 deletions(-) delete mode 100644 .DS_Store delete mode 100644 doc/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 0dbd5676346d414160c77ada3446210c2a30f8f0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK&1%~~5Z<-jRGXThKn^MNAjlyXA8fZcSK&B06&flNAKKKFDp3oB)=08_Fb2^F z=mRv@CV7vf578Ity)(P(Qsd+nN-;Aq`_0bI%(9=v{xHUPcM`T3vl(L+C}KrGbC2LS z>Y7xH2a#iqd>kY)fZnfQycSK4|B(Uwc2yQK$vy?MzrSA+=S8#mlUJ&>CtFV~u`TLi zN7OI8k(_yjUrh3@pAGF7UK~b&pAF)$81OgZok@5TI>8IFF;* z(B3hH}=GlQhg#yeY2iGrt%?9dY1BrD9T8VrcKr=bcWw;k;_M z77b^9bkqd&aIsB?hb`37!2N;Hmsh6dROh1EX z8NG}mBnF59VqgOpFk74TYy;LpOCSb_fyZS4_Xh_Q(KT3VR9go$czwk28X^kV_?AF) z47vtOjW7bjbt<4v<>raObvpPR6XzN%HR^Q6)yz=G%*@RTg{#@Y@2GIbU5(Td1H`~8 z16AF%@%%q|`2D|{L_K1F7}zKVc&+F4y09d3wyrG>&sqocBPa^Sl^Xw~fT50Jh{dCL cA5;nW9W(%4gQZ6BfY3!i(LfC`@J|`|4e!fe?*IS* diff --git a/.gitignore b/.gitignore index e1ee914..d8b1eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ *.sw[op] *.test +.DS_Store diff --git a/conf/systemd.service b/conf/systemd.service index 27d7082..e517813 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,10 +6,10 @@ After=network.target Type=simple User=__APP__ Group=__APP__ -Environment=__YNH_NODE_LOAD_PATH__ +Environment=PATH=__PATH_WITH_NODEJS__ Environment=NODE_ENV=production WorkingDirectory=__INSTALL_DIR__ -ExecStart=__YNH_NODE__ __INSTALL_DIR__/server +ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/server Restart=always # Sandboxing options to harden security diff --git a/doc/.DS_Store b/doc/.DS_Store deleted file mode 100644 index 7a36e1b684d2e640d7748ba0c6c1a4c8649c46b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!A=4(5S;?*5@O_FBFDXW;{a&jWU@g#cr#g}2Q{!O8`%W6hFv7OV)i%mkNg6E z$CFcK50)S|b`*naa09dGmxgu6S2=$XLNzQl(g&HG(2x1t3 zgk&k29siL5+Pf0&*)5D9!1BF+u|J6){Gs$Q;=_L!hH+A>eTrPZu(7#i6|rnvH|{`A z+{8=9aoZbRQR~c02EMV+r5w&}&%X$RNw>UvEThB=qhO?x!+wAv*Oy_`my@;}NBvlh z=>NE zI~psN`{<6Mp^WY@VwOG2Vq^xG0cK#$7%<12Ra&!k@p6~}X5jY>(D`7a5;_Jmjq2#Y zihdudzd%TWHoYYXZG(=%Oe6N72%U db.sql +ynh_psql_dump_db > db.sql #================================================= # 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/change_url b/scripts/change_url index 8123f1e..63e8858 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,42 +1,32 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd +ynh_systemctl --service=$app --action="stop" --log_path=systemd #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="HTTP Server:" +ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="HTTP Server:" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index cf1fa10..5e8ef50 100644 --- a/scripts/install +++ b/scripts/install @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -16,74 +10,72 @@ source /usr/share/yunohost/helpers ldap_user="svc_${app}_ldap" ldap_password=$(ynh_string_random --length=8) -ynh_app_setting_set --app="$app" --key=ldap_user --value="$ldap_user" -ynh_app_setting_set --app="$app" --key=ldap_password --value="$ldap_password" +ynh_app_setting_set --key=ldap_user --value="$ldap_user" +ynh_app_setting_set --key=ldap_password --value="$ldap_password" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing NodeJS..." +ynh_script_progression "Installing NodeJS..." -ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version" -ynh_use_nodejs +ynh_nodejs_install #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." +ynh_script_progression "Creating a PostgreSQL database..." -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name +ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$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 | chmod -R o-rwx "$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 "$app:$app" "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." +ynh_script_progression "Adding $app's configuration..." -ynh_add_config --template="config.sample.yml" --destination="$install_dir/config.yml" +ynh_config_add --template="config.sample.yml" --destination="$install_dir/config.yml" -chmod 400 "$install_dir/config.yml" -chown "$app:$app" "$install_dir/config.yml" +#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 400 "$install_dir/config.yml" +#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 | chown "$app:$app" "$install_dir/config.yml" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" --description="$app daemon for Wiki.js" --log="/var/log/$app/$app.log" #================================================= # CREATE LDAP USER #================================================= -ynh_script_progression --message="Creating LDAP user..." +ynh_script_progression "Creating LDAP user..." yunohost user create "$ldap_user" --fullname "SvcWikijsLdap" --domain "$domain" --password "$ldap_password" -q 0 #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." # Start a systemd service -ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="HTTP Server:" +ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="HTTP Server:" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 6d2a91b..5682a66 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,11 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -16,19 +10,19 @@ source /usr/share/yunohost/helpers #================================================= # 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..." +if ynh_hide_warnings yunohost service status $app >/dev/null; then + ynh_script_progression "Removing $app service integration..." yunohost service remove "$app" fi # Remove the dedicated systemd config -ynh_remove_systemd_config +ynh_config_remove_systemd # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove metapackage and its dependencies -ynh_remove_nodejs +ynh_nodejs_remove yunohost user delete $ldap_user --purge @@ -36,4 +30,4 @@ yunohost user delete $ldap_user --purge # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 2d6a1d9..802a1a4 100644 --- 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 @@ -13,38 +7,37 @@ source /usr/share/yunohost/helpers #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling NodeJS..." +ynh_script_progression "Reinstalling NodeJS..." # Define and install dependencies -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs +ynh_nodejs_install #================================================= # 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" - -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$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 | chmod -R o-rwx "$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 "$app:$app" "$install_dir" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." +ynh_script_progression "Restoring the PostgreSQL database..." -ynh_psql_execute_as_root --sql="CREATE EXTENSION IF NOT EXISTS pg_trgm;" --database=$db_name -ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" +ynh_psql_db_shell <<< "CREATE EXTENSION IF NOT EXISTS pg_trgm;" + +ynh_psql_db_shell " < "./db.sql"" #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +ynh_restore "/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet yunohost service add "$app" --description="$app daemon for Wiki.js" --log="/var/log/$app/$app.log" @@ -53,14 +46,14 @@ yunohost user create "$ldap_user" --fullname "SvcWikijsLdap" --domain "$domain" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="HTTP Server:" +ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="HTTP Server:" -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 6a8e0c3..42d0406 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,33 +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..." +ynh_script_progression "Stopping $app's systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd +ynh_systemctl --service=$app --action="stop" --log_path=systemd #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression "Ensuring downward compatibility..." # If ldap_user doesn't exist, retrieve it or create it if [[ -z "${ldap_user:-}" ]]; then @@ -41,52 +27,50 @@ fi #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." +ynh_script_progression "Upgrading dependencies..." -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_use_nodejs +ynh_nodejs_install #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." +ynh_script_progression "Upgrading source files..." -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config.yml .ssh data" - -chmod -R o-rwx "$install_dir" -chown -R "$app:$app" "$install_dir" +ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="config.yml .ssh data" +#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 | chmod -R o-rwx "$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 "$app:$app" "$install_dir" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." +ynh_script_progression "Updating configuration..." -ynh_add_config --template="config.sample.yml" --destination="$install_dir/config.yml" +ynh_config_add --template="config.sample.yml" --destination="$install_dir/config.yml" -chmod 400 "$install_dir/config.yml" -chown "$app:$app" "$install_dir/config.yml" +#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 400 "$install_dir/config.yml" +#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 | chown "$app:$app" "$install_dir/config.yml" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated systemd config -ynh_add_systemd_config +ynh_config_add_systemd yunohost service add "$app" --description="$app daemon for Wiki.js" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression "Starting $app's systemd service..." -ynh_systemd_action --service_name="$app" --action="start" --log_path=systemd --line_match="HTTP Server:" +ynh_systemctl --service="$app" --action="start" --log_path=systemd --wait_until="HTTP Server:" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression "Upgrade of $app completed"