From e58116982f6c035d94ac03ef9c7bd41f3f2a2689 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 01:14:00 +0200 Subject: [PATCH 1/8] Apply example_ynh --- README.md | 4 ++-- check_process | 4 ++++ manifest.json | 2 +- scripts/change_url | 2 +- scripts/install | 35 +++++++++++++++++------------------ scripts/restore | 28 ++++++++++++---------------- scripts/upgrade | 33 ++++++++++++++++----------------- 7 files changed, 53 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index bb148c0..54b4bf6 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ The app can be used by multiple users, anonymously. #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/distbin%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/distbin/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/distbin%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/distbin/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/distbin.svg)](https://ci-apps.yunohost.org/ci/apps/distbin/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/distbin.svg)](https://ci-apps-arm.yunohost.org/ci/apps/distbin/) ## Limitations diff --git a/check_process b/check_process index f2ab4ae..0fefea2 100644 --- a/check_process +++ b/check_process @@ -24,6 +24,8 @@ upgrade=1 from_commit=f7bc083d037eb771afeddc2237a24505a5ef1c68 # 1.3.0~ynh6 upgrade=1 from_commit=cdec64125b179f6b19470ceb8379225ed03c10a8 + # 1.3.0~ynh7 + upgrade=1 from_commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a backup_restore=1 multi_instance=1 port_already_use=0 @@ -40,3 +42,5 @@ Notification=all name=1.3.0~ynh5 ; commit=cdec64125b179f6b19470ceb8379225ed03c10a8 name=1.3.0~ynh6 + ; commit=481c0c5ce62caa9c79a6bd536f390f3814128b3a + name=1.3.0~ynh7 diff --git a/manifest.json b/manifest.json index b3f59d0..cbe0799 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Distributed pastebin with ActivityPub.", "fr": "Pastebin distribué utilisant le protocole ActivityPub." }, - "version": "1.3.0~ynh7", + "version": "1.3.0~ynh8", "url": "https://distbin.com/", "license": "Apache-2.0", "maintainer": { diff --git a/scripts/change_url b/scripts/change_url index b934598..ad048fb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,7 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= -# 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)..." diff --git a/scripts/install b/scripts/install index 1005197..59fb4d4 100644 --- a/scripts/install +++ b/scripts/install @@ -67,6 +67,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -76,6 +84,10 @@ 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" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -84,14 +96,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # 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" - #================================================= # SPECIFIC SETUP #================================================= @@ -138,22 +142,17 @@ ynh_script_progression --message="Configuring a systemd service..." ynh_add_systemd_config #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Adding a config file..." ynh_add_config --template="../conf/.env" --destination="$final_path/.env" +chmod 400 "$final_path/some_config_file" +chown $app:$app "$final_path/some_config_file" + #================================================= # 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 - #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/restore b/scripts/restore index 78afd1b..29499be 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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 @@ -50,6 +50,14 @@ 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" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -57,21 +65,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 - -#================================================= -# 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" #================================================= # CREATE LOG FOLDER diff --git a/scripts/upgrade b/scripts/upgrade index 6f1a9c4..6081aa1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take ynh_backup_before_upgrade ynh_clean_setup () { ynh_clean_check_starting - # 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 @@ -64,6 +64,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped Distbin Service" +#================================================= +# 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 #================================================= @@ -76,6 +84,10 @@ then ynh_setup_source --dest_dir="$final_path" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -92,14 +104,6 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -#================================================= -# 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 #================================================= @@ -154,16 +158,11 @@ ynh_script_progression --message="Updating a config file..." ynh_add_config --template="../conf/.env" --destination="$final_path/.env" +chmod 400 "$final_path/some_config_file" +chown $app:$app "$final_path/some_config_file" + #================================================= # 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 - #================================================= # SETUP LOGROTATE #================================================= From 174c2fbfdf082f2f9c9ffc47c8cc0dec36859641 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 01:57:27 +0200 Subject: [PATCH 2/8] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 59fb4d4..f1b2dc9 100644 --- a/scripts/install +++ b/scripts/install @@ -148,8 +148,8 @@ ynh_script_progression --message="Adding a config file..." ynh_add_config --template="../conf/.env" --destination="$final_path/.env" -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" #================================================= # GENERIC FINALIZATION From 9464b0504d8a1dd752703e57deb2cceec3f94b12 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 01:57:32 +0200 Subject: [PATCH 3/8] Update upgrade --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 6081aa1..593a74a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -158,8 +158,8 @@ ynh_script_progression --message="Updating a config file..." ynh_add_config --template="../conf/.env" --destination="$final_path/.env" -chmod 400 "$final_path/some_config_file" -chown $app:$app "$final_path/some_config_file" +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" #================================================= # GENERIC FINALIZATION From 9f4e21589629b300c4f2833d7033fbed006c42e8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 20:18:30 +0200 Subject: [PATCH 4/8] Fix rights --- scripts/install | 20 +++++++++----------- scripts/restore | 2 +- scripts/upgrade | 20 +++++++++----------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/scripts/install b/scripts/install index f1b2dc9..58c5750 100644 --- a/scripts/install +++ b/scripts/install @@ -86,7 +86,7 @@ ynh_setup_source --dest_dir="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -120,8 +120,6 @@ mkdir -p "$final_path/distbin-db/inbox" #================================================= ynh_script_progression --message="Installing Distbin..." -chown -R "$app":"$app" "$final_path" - pushd $final_path ynh_use_nodejs ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts @@ -133,14 +131,6 @@ pushd $final_path/dist ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production popd -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # ADD A CONFIGURATION #================================================= @@ -151,6 +141,14 @@ ynh_add_config --template="../conf/.env" --destination="$final_path/.env" chmod 400 "$final_path/.env" chown $app:$app "$final_path/.env" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 29499be..b8501d6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -67,7 +67,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" #================================================= # CREATE LOG FOLDER diff --git a/scripts/upgrade b/scripts/upgrade index 593a74a..75fcdf5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -86,7 +86,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 @@ -130,8 +130,6 @@ fi #================================================= ynh_script_progression --message="Making upgrade..." -chown -R "$app":"$app" "$final_path" - pushd $final_path ynh_use_nodejs ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts @@ -143,14 +141,6 @@ pushd $final_path/dist ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH $ynh_npm install --ignore-scripts --production popd -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # UPDATE A CONFIG FILE #================================================= @@ -161,6 +151,14 @@ ynh_add_config --template="../conf/.env" --destination="$final_path/.env" chmod 400 "$final_path/.env" chown $app:$app "$final_path/.env" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= From 43ecb59ac36941b55eed51e5f588e05e2d1b1033 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Apr 2021 01:13:34 +0200 Subject: [PATCH 5/8] Typo --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index b8501d6..df37250 100644 --- a/scripts/restore +++ b/scripts/restore @@ -123,7 +123,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX #================================================= ynh_script_progression --message="Reloading NGINX web server..." From 283967936cc498480e1da97c01631b0aec7c9f73 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 14 Apr 2021 20:36:26 +0200 Subject: [PATCH 6/8] Fix rights --- scripts/install | 6 +++++- scripts/upgrade | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 58c5750..937f27a 100644 --- a/scripts/install +++ b/scripts/install @@ -115,6 +115,10 @@ mkdir -p "$final_path/distbin-db" mkdir -p "$final_path/distbin-db/activities" mkdir -p "$final_path/distbin-db/inbox" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # INSTALLING DISTBIN #================================================= @@ -124,7 +128,7 @@ pushd $final_path ynh_use_nodejs 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/ + sudo -u $app cp -af package* dist/ popd pushd $final_path/dist diff --git a/scripts/upgrade b/scripts/upgrade index 75fcdf5..dbb4f0e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -125,6 +125,10 @@ if [ -d "$DIRECTORY" ]; then mv "$final_path/db" "$final_path/distbin-db" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:$app "$final_path" + #================================================= # MAKE UPGRADE #================================================= @@ -134,7 +138,7 @@ pushd $final_path ynh_use_nodejs 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/ + sudo -u $app cp -af package* dist/ popd pushd $final_path/dist From 36ea616c1b4f4a22679d9efdd6d2e979efd51321 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 15 Apr 2021 20:27:54 +0200 Subject: [PATCH 7/8] Fix chmod --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 937f27a..ef89768 100644 --- a/scripts/install +++ b/scripts/install @@ -84,7 +84,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" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" @@ -115,7 +115,7 @@ mkdir -p "$final_path/distbin-db" mkdir -p "$final_path/distbin-db/activities" mkdir -p "$final_path/distbin-db/inbox" -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 df37250..872d259 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,7 +65,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 dbb4f0e..b4ee13b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,7 +84,7 @@ then ynh_setup_source --dest_dir="$final_path" fi -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" @@ -125,7 +125,7 @@ if [ -d "$DIRECTORY" ]; then mv "$final_path/db" "$final_path/distbin-db" fi -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" From a0448dfac5c19f9de80b21f93cec6d9d3667f910 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:31:08 +0200 Subject: [PATCH 8/8] Fix recursive chmod --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index ef89768..937f27a 100644 --- a/scripts/install +++ b/scripts/install @@ -84,7 +84,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" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" @@ -115,7 +115,7 @@ mkdir -p "$final_path/distbin-db" mkdir -p "$final_path/distbin-db/activities" mkdir -p "$final_path/distbin-db/inbox" -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 872d259..df37250 100644 --- a/scripts/restore +++ b/scripts/restore @@ -65,7 +65,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 b4ee13b..dbb4f0e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,7 +84,7 @@ then ynh_setup_source --dest_dir="$final_path" fi -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" @@ -125,7 +125,7 @@ if [ -d "$DIRECTORY" ]; then mv "$final_path/db" "$final_path/distbin-db" fi -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path"