From c65667e92831d3eabbfbb00fed409c8e528813e3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 00:07:07 +0200 Subject: [PATCH 1/9] Apply example_ynh --- README.md | 4 +-- check_process | 4 +++ manifest.json | 14 +-------- scripts/backup | 2 +- scripts/change_url | 20 ++++++------- scripts/install | 47 ++++++++++++------------------ scripts/remove | 6 ++-- scripts/restore | 40 ++++++++++++-------------- scripts/upgrade | 72 ++++++++++++++++++++++------------------------ 9 files changed, 92 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index 269bcab..367fc22 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ LDAP is supported but HTTP auth is not supported? #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mobilizon/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mobilizon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mobilizon.svg)](https://ci-apps.yunohost.org/ci/apps/mobilizon/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mobilizon.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mobilizon/) ## Links diff --git a/check_process b/check_process index e5b7362..a759273 100644 --- a/check_process +++ b/check_process @@ -26,6 +26,8 @@ upgrade=1 from_commit=8d20652e67015a535b2063edc54379604a7d932d # 1.0.7~ynh1 upgrade=1 from_commit=cba843be0d7e00d7d7290f0d0da95807711a96d4 + # 1.1.0~ynh1 + upgrade=1 from_commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e backup_restore=1 multi_instance=1 port_already_use=0 @@ -46,3 +48,5 @@ Notification=all name=1.0.6-2021-02-23~ynh1 ; commit=cba843be0d7e00d7d7290f0d0da95807711a96d4 name=1.0.7~ynh1 + ; commit=5780e424cf3217bf9d25e5b24beb51f52b6b777e + name=1.1.0~ynh1 diff --git a/manifest.json b/manifest.json index f2d2032..32946ff 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A decentralized and federated platform to organize events", "fr": "Une plateforme décentralisée et fédérée pour organiser des événements" }, - "version": "1.1.0~ynh1", + "version": "1.1.0~ynh2", "url": "https://joinmobilizon.org/", "license": "AGPL-3.0-or-later", "maintainer": { @@ -24,28 +24,16 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Mobilizon", - "fr": "Choisissez un nom de domaine pour Mobilizon" - }, "example": "example.com" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "johndoe" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true }, { diff --git a/scripts/backup b/scripts/backup index 9fcc981..77494ff 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 bb7b90a..9da4262 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL 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 @@ -45,7 +45,7 @@ ynh_clean_setup () { # 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 @@ -79,23 +79,23 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -134,7 +134,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 0bf2ab1..0651f09 100644 --- a/scripts/install +++ b/scripts/install @@ -79,14 +79,20 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key='https://dl.yarnpkg.com/debian/pubkey.gpg' -#================================================= -# INSTALL EXTRA DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing extra dependencies ..." - lsb_name="$(lsb_release --codename --short)" ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc' +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + +yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0 +yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -113,25 +119,18 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/$app" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - -yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0 -yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email - #================================================= # SPECIFIC SETUP #================================================= @@ -196,20 +195,12 @@ ynh_store_file_checksum --file="$config" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R "$app":"$app" "$final_path" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Mobilizon" +yunohost service add $app --description="$app daemon for Mobilizon" #================================================= # START SYSTEMD SERVICE @@ -235,7 +226,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 6cdb5c4..d8b4be0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,7 +28,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..." @@ -71,9 +71,9 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= diff --git a/scripts/restore b/scripts/restore index 27f2602..9e43b6e 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 @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -52,10 +52,21 @@ 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" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + +yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0 +yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -63,24 +74,9 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path - -yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0 -yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R "$app":"$app" "$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -124,7 +120,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Mobilizon" +yunohost service add $app --description="$app daemon for Mobilizon" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 93e2956..8ef3c90 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,7 +62,7 @@ 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 () { - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup ynh_clean_check_starting } @@ -111,6 +111,14 @@ if ynh_version_gt "1.0.0~ynh1" "${previous_version}" ; then ynh_store_file_checksum --file="$config" fi +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -144,12 +152,16 @@ then ynh_secure_remove --file="$tmpdir" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -169,25 +181,8 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION lsb_name="$(lsb_release --codename --short)" ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions.com/debian $lsb_name contrib" --package="$extra_pkg_dependencies" --key='https://packages.erlang-solutions.com/debian/erlang_solutions.asc' -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # SPECIFIC UPGRADE -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Modifying a config file..." - -config="$final_path/$app/config/prod.secret.exs" -ynh_backup_if_checksum_is_different --file="$config" -chmod o-rwx $config - #================================================= # MAKE SETUP #================================================= @@ -223,14 +218,6 @@ if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then popd fi -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$config" - #================================================= # SETUP SYSTEMD #================================================= @@ -239,22 +226,31 @@ ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Modifying a config file..." + +config="$final_path/$app/config/prod.secret.exs" +ynh_backup_if_checksum_is_different --file="$config" +chmod o-rwx $config + +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= +ynh_script_progression --message="Storing the config file checksum..." + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$config" + #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R "$app":"$app" "$final_path" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Mobilizon" +yunohost service add $app --description="$app daemon for Mobilizon" #================================================= # START SYSTEMD SERVICE @@ -266,7 +262,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload From c7092125cdfa1930ac68a5d4ad0a4a04a9c3904e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 16:59:16 +0200 Subject: [PATCH 2/9] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index a759273..4291d97 100644 --- a/check_process +++ b/check_process @@ -31,7 +31,7 @@ backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email=yalh@yahoo.com Notification=all From 090571cb81fd2cb1c3c5606ad20b795ff308c980 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 20:13:19 +0200 Subject: [PATCH 3/9] Apply example_ynh --- check_process | 8 ++++---- scripts/change_url | 3 +++ scripts/install | 13 ++----------- scripts/upgrade | 32 ++++++++++++++------------------ 4 files changed, 23 insertions(+), 33 deletions(-) diff --git a/check_process b/check_process index 4291d97..6d0f1f5 100644 --- a/check_process +++ b/check_process @@ -15,13 +15,13 @@ setup_public=1 upgrade=1 # 0.1.0-2019-05-15~ynh1 - # upgrade=1 from_commit=185cc16e516076e340cca149e8e9140a8762e22e + #upgrade=1 from_commit=185cc16e516076e340cca149e8e9140a8762e22e # 0.1.0-2019-12-28~ynh1 - # upgrade=1 from_commit=6b77f268d4e7e2cd525e11e11f3ed5a5162d0bd2 + #upgrade=1 from_commit=6b77f268d4e7e2cd525e11e11f3ed5a5162d0bd2 # 1.0.0~ynh1 - # upgrade=1 from_commit=ac87692da6eaff71f40e3069c7bc6129eddba5e6 + #upgrade=1 from_commit=ac87692da6eaff71f40e3069c7bc6129eddba5e6 # 1.0.3~ynh1 - # upgrade=1 from_commit=8413ab8bd3aca3e2f6c431153dd9dfab37860956 + #upgrade=1 from_commit=8413ab8bd3aca3e2f6c431153dd9dfab37860956 # 1.0.6-2021-02-23~ynh1 upgrade=1 from_commit=8d20652e67015a535b2063edc54379604a7d932d # 1.0.7~ynh1 diff --git a/scripts/change_url b/scripts/change_url index 9da4262..708ede5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -121,6 +121,9 @@ ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" - # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" +chmod 400 "$config" +chown $app:$app "$config" + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index 0651f09..acbe31d 100644 --- a/scripts/install +++ b/scripts/install @@ -138,9 +138,6 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Installing dependencies and building app..." --weight=5 -# Give permission to the final_path -chown -R "$app":"$app" "$final_path" - config="$final_path/$app/config/prod.secret.exs" pushd $final_path/$app/js @@ -177,6 +174,8 @@ pushd $final_path/$app sudo -u "$app" MIX_ENV=prod mix mobilizon.users.new "$admin_email" --admin --password "$password" popd +ynh_store_file_checksum --file="$config" + #================================================= # SETUP SYSTEMD #================================================= @@ -185,14 +184,6 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$config" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8ef3c90..295a561 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,6 +45,13 @@ previous_version="${version}" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + if ! ynh_permission_exists --permission="admin"; then # Create the required permissions ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin @@ -171,11 +178,7 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then - ynh_script_progression --message="Mobilizon v1.0.3: Remove previous NodeJS" - ynh_remove_nodejs -fi - +ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$NODEJS_VERSION lsb_name="$(lsb_release --codename --short)" @@ -187,9 +190,6 @@ ynh_install_extra_app_dependencies --repo="deb http://packages.erlang-solutions. # MAKE SETUP #================================================= -# Give permission to the final_path -chown -R "$app":"$app" "$final_path" - pushd $final_path/$app/js ynh_use_nodejs ynh_script_progression --message="Installing NodeJS dependencies (this is going to take a while...)" @@ -227,22 +227,18 @@ ynh_script_progression --message="Upgrading systemd configuration..." ynh_add_systemd_config #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Updating a config file..." config="$final_path/$app/config/prod.secret.exs" + ynh_backup_if_checksum_is_different --file="$config" -chmod o-rwx $config - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$config" +chmod 400 "$config" +chown $app:$app "$config" + #================================================= # GENERIC FINALIZATION #================================================= From 06e5bc9648ab15f26b545917e3f625e471d8f4d2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 20:36:45 +0200 Subject: [PATCH 4/9] Fix rights --- scripts/install | 5 ++++- scripts/restore | 2 +- scripts/upgrade | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index acbe31d..717ca3d 100644 --- a/scripts/install +++ b/scripts/install @@ -121,7 +121,7 @@ ynh_setup_source --dest_dir="$final_path/$app" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -176,6 +176,9 @@ popd ynh_store_file_checksum --file="$config" +chmod 400 "$config" +chown $app:$app "$config" + #================================================= # SETUP SYSTEMD #================================================= diff --git a/scripts/restore b/scripts/restore index 9e43b6e..476f305 100644 --- a/scripts/restore +++ b/scripts/restore @@ -76,7 +76,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 295a561..27e6dcc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,9 +69,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 @@ -161,7 +161,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -218,14 +218,6 @@ if ynh_version_gt "1.0.3~ynh1" "${previous_version}" ; then popd fi -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # UPDATE A CONFIG FILE #================================================= @@ -239,6 +231,14 @@ ynh_store_file_checksum --file="$config" chmod 400 "$config" chown $app:$app "$config" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= From b0dbbd9d33bf6ca71af4b2ec8560f7e7bb8c7c8f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Apr 2021 01:12:51 +0200 Subject: [PATCH 5/9] Typo --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 476f305..6dc6edc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -132,7 +132,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --lin #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX #================================================= ynh_script_progression --message="Reloading NGINX web server..." From 57ab776a878832a25e742e16226e997331813c6f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 14 Apr 2021 20:55:05 +0200 Subject: [PATCH 6/9] fix cp --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 27e6dcc..c23edbb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -138,7 +138,7 @@ then tmpdir="$(mktemp -d)" # Backup the config file in the temp dir - cp -a "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs" + cp -af "$final_path/$app/config/prod.secret.exs" "$tmpdir/prod.secret.exs" # Backup upload dir rsync -a "$final_path/$app/uploads" "$tmpdir/." @@ -150,7 +150,7 @@ then ynh_setup_source --dest_dir="$final_path/$app" # Restore the config file - cp -a "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs" + cp -af "$tmpdir/prod.secret.exs" "$final_path/$app/config/prod.secret.exs" # Restore upload dir rsync -a "$tmpdir/uploads" "$final_path/$app/." From 84e0ab07fbdc0f790ee586659434b5740414c4cb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 15 Apr 2021 20:28:34 +0200 Subject: [PATCH 7/9] Fix chmod --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 717ca3d..693d89b 100644 --- a/scripts/install +++ b/scripts/install @@ -119,7 +119,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/$app" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index 6dc6edc..e311b12 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,7 +74,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index c23edbb..dfc0d30 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -159,7 +159,7 @@ then ynh_secure_remove --file="$tmpdir" fi -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" From 031b817ba680249bb2286b33b3068e4c02c7fad1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 15:33:08 +0200 Subject: [PATCH 8/9] Fix rights --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 708ede5..d4b8f51 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -122,7 +122,7 @@ ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" - ynh_store_file_checksum --file="$config" chmod 400 "$config" -chown $app:$app "$config" +chown $app:www-data "$config" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 693d89b..fa95c95 100644 --- a/scripts/install +++ b/scripts/install @@ -177,7 +177,7 @@ popd ynh_store_file_checksum --file="$config" chmod 400 "$config" -chown $app:$app "$config" +chown $app:www-data "$config" #================================================= # SETUP SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index dfc0d30..322413a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -229,7 +229,7 @@ ynh_backup_if_checksum_is_different --file="$config" ynh_store_file_checksum --file="$config" chmod 400 "$config" -chown $app:$app "$config" +chown $app:www-data "$config" #================================================= # SETUP SYSTEMD From 1da86b50f865a6d3c2fb929b22442ed810768b52 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:31:38 +0200 Subject: [PATCH 9/9] Fix recursive chmod --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index fa95c95..c593c68 100644 --- a/scripts/install +++ b/scripts/install @@ -119,7 +119,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/$app" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index e311b12..6dc6edc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,7 +74,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 322413a..83bfe98 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -159,7 +159,7 @@ then ynh_secure_remove --file="$tmpdir" fi -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path"