From 37d40d14f7529976a4e016e2b945e9686f5f290f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 23:37:52 +0200 Subject: [PATCH 01/10] Apply example_ynh --- README.md | 4 ++-- README_fr.md | 4 ++-- check_process | 11 +++++------ manifest.json | 14 +------------- scripts/backup | 2 +- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/restore | 8 ++++---- scripts/upgrade | 8 ++++---- 9 files changed, 22 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 8afc36f..a4c43f8 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ Want to see in action? #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/) ## Links diff --git a/README_fr.md b/README_fr.md index f363581..70694f9 100644 --- a/README_fr.md +++ b/README_fr.md @@ -64,8 +64,8 @@ En regardant une vidéo, vous aidez l'hébergeur à la diffuser en devenant vous #### Architectures supportées -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/peertube.svg)](https://ci-apps.yunohost.org/ci/apps/peertube/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/peertube.svg)](https://ci-apps-arm.yunohost.org/ci/apps/peertube/) ## Liens diff --git a/check_process b/check_process index b4f25f8..184542e 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,3 @@ -# See here for more informations -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) @@ -29,10 +24,12 @@ upgrade=1 from_commit=10d79175a8a45137d271931cbd6d14e927400729 # 3.0.1~ynh1 upgrade=1 from_commit=5a74f4033eafa657fcd32a9713cd77ba0f4f79c9 + # 3.1.0~ynh2 + upgrade=1 from_commit=1be4caaaf2787e614cd315ca8564573d4268032a backup_restore=1 multi_instance=0 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email=anmol@datamol.org;yalh@yahoo.com Notification=yes @@ -49,4 +46,6 @@ Notification=yes name=2.4.0~ynh1 ; commit=5a74f4033eafa657fcd32a9713cd77ba0f4f79c9 name=3.0.1~ynh1 + ; commit=1be4caaaf2787e614cd315ca8564573d4268032a + name=3.1.0~ynh2 \ No newline at end of file diff --git a/manifest.json b/manifest.json index f7eb226..0fc6968 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Video streaming platform using P2P directly in the web browser, connected to a federated network", "fr": "Plateforme de diffusion vidéo par P2P directement dans le navigateur, et connectée à un réseau fédéralisé" }, - "version": "3.1.0~ynh2", + "version": "3.1.0~ynh3", "url": "https://github.com/Chocobozzz/PeerTube", "license": "AGPL-3.0-only", "maintainer": [ @@ -30,28 +30,16 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for PeerTube", - "fr": "Choisissez un nom de domaine pour PeerTube" - }, "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 8c58481..1e20dde 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/install b/scripts/install index a2b1c90..0cc1db1 100644 --- a/scripts/install +++ b/scripts/install @@ -127,7 +127,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config "datadir" #================================================= @@ -240,7 +240,7 @@ ynh_use_logrotate --logfile="$datadir/logs/peertube.log" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port +yunohost service add $app --description="$app daemon for Peertube" --log="$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index 7950022..1dfe2e4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -79,7 +79,7 @@ ynh_secure_remove --file="$final_path" #================================================= 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 033dc18..4ff69f3 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,7 +52,7 @@ 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" @@ -145,7 +145,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port +yunohost service add $app --description="$app daemon for Peertube" --log="$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index d960814..69422ea 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -100,7 +100,7 @@ if ! ynh_permission_exists --permission="api"; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." @@ -115,7 +115,7 @@ ynh_backup_before_upgrade ynh_app_setting_delete --app=$app --key=backup_core_only ynh_clean_setup () { - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_clean_check_starting ynh_restore_upgradebackup } @@ -174,7 +174,7 @@ fi #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config "datadir" #================================================= @@ -292,7 +292,7 @@ ynh_use_logrotate --non-append #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description "$app daemon for Peertube" --log "$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port +yunohost service add $app --description="$app daemon for Peertube" --log="$datadir/logs/peertube.log" --needs_exposed_ports $rtmp_port #================================================= # START SYSTEMD SERVICE From 768e7c4a50a8e2a63e1dcb39b5f953ad077539db Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 23:51:13 +0200 Subject: [PATCH 02/10] Typo --- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 0cc1db1..d46d3a3 100644 --- a/scripts/install +++ b/scripts/install @@ -136,7 +136,7 @@ ynh_add_nginx_config "datadir" ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # SPECIFIC SETUP diff --git a/scripts/remove b/scripts/remove index 1dfe2e4..8149dd4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -34,7 +34,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=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..." diff --git a/scripts/restore b/scripts/restore index 4ff69f3..24a99d4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -69,7 +69,7 @@ ynh_restore_file --origin_path="$final_path" 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 +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE USER RIGHTS From 5a39e7ab86e546849154a075b7002559853e2422 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 19:38:56 +0200 Subject: [PATCH 03/10] Apply last example_ynh --- scripts/backup | 14 +++++------ scripts/install | 62 ++++++++++++++++++++++----------------------- scripts/restore | 39 +++++++++++++--------------- scripts/upgrade | 67 ++++++++++++++++++++----------------------------- 4 files changed, 82 insertions(+), 100 deletions(-) diff --git a/scripts/backup b/scripts/backup index 1e20dde..2fc99d4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -63,13 +63,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# BACKUP THE POSTGRESQL DATABASE -#================================================= -ynh_print_info --message="Backing up the PostgreSQL database..." - -ynh_psql_dump_db --database="$db_name" > db.sql - #================================================= # BACKUP THE DATA DIRECTORY #================================================= @@ -77,6 +70,13 @@ ynh_print_info --message="Backing up data directory..." ynh_backup --src_path="$datadir" --is_big +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Backing up the PostgreSQL database..." + +ynh_psql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index d46d3a3..07fe1fe 100644 --- a/scripts/install +++ b/scripts/install @@ -97,6 +97,14 @@ fi # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -122,6 +130,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 #================================================= @@ -130,14 +142,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config "datadir" -#================================================= -# 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 #================================================= @@ -148,25 +152,15 @@ ynh_script_progression --message="Creating the data directory..." # Create app folders mkdir -p "$datadir" -# Give permission to the datadir -chown -R $app:$app $datadir - -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Modifying a config file..." - -ynh_add_config --template="../conf/production.yaml" --destination="$final_path/config/production.yaml" - -ynh_add_config --template="../conf/local-production.json" --destination="$final_path/config/local-production.json" +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R root:$app "$datadir" #================================================= # BUILD YARN DEPENDENCIES #================================================= ynh_script_progression --message="Building Yarn dependencies..." -chown -R "$app":"$app" $final_path - pushd "$final_path" ynh_use_nodejs ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --production --pure-lockfile @@ -180,6 +174,21 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config --others_var="ynh_node_load_PATH" +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a config file..." + +ynh_add_config --template="../conf/production.yaml" --destination="$final_path/config/production.yaml" + +chmod 400 "$final_path/config/production.yaml" +chown $app:$app "$final_path/config/production.yaml" + +ynh_add_config --template="../conf/local-production.json" --destination="$final_path/config/local-production.json" + +chmod 400 "$final_path/config/local-production.json" +chown $app:$app "$final_path/config/local-production.json" + #================================================= # START SYSTEMD SERVICE #================================================= @@ -216,17 +225,6 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # 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 - -# Give permission to the datadir -chown -R $app:$app $datadir - #================================================= # SETUP LOGROTATE #================================================= diff --git a/scripts/restore b/scripts/restore index 24a99d4..f1002f5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -56,13 +56,6 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -72,12 +65,15 @@ ynh_script_progression --message="Recreating the dedicated system user..." ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring user rights..." +ynh_script_progression --message="Restoring the app main directory..." -# Restore permissions on app files -chown -R $app:$app $final_path +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -91,8 +87,17 @@ ynh_restore_file --origin_path="$datadir" --not_mandatory mkdir -p "$datadir" -# Give permission to the datadir -chown -R $app:$app $datadir +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R root:$app "$datadir" + +#================================================= +# OPEN A PORT +#================================================= +ynh_script_progression --message="Configuring firewall..." + +# Open the port +ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port #================================================= # REINSTALL DEPENDENCIES @@ -124,14 +129,6 @@ ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name -#================================================= -# OPEN A PORT -#================================================= -ynh_script_progression --message="Configuring firewall..." - -# Open the port -ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port - #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 69422ea..1ce2fad 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -100,20 +100,12 @@ if ! ynh_permission_exists --permission="api"; then fi #================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." -# Inform the backup/restore process that it should not save the data directory -# Use only for the previous backup script that doesn't set 'is_big' -ynh_app_setting_set --app=$app --key=backup_core_only --value=1 - # Backup the current version of the app ynh_backup_before_upgrade - -# Remove the option backup_core_only after the backup. -ynh_app_setting_delete --app=$app --key=backup_core_only - ynh_clean_setup () { # Restore it if the upgrade fails ynh_clean_check_starting @@ -131,6 +123,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +#================================================= +# 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 #================================================= @@ -169,6 +169,10 @@ 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 #================================================= @@ -202,14 +206,6 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/15-nginx_$app" yunohost tools regen-conf nginx -#================================================= -# 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 - #================================================= # SPECIFIC UPGRADE #================================================= @@ -217,25 +213,27 @@ ynh_system_user_create --username=$app #================================================= ynh_script_progression --message="Creating the data directory..." -if [ ! -d "$datadir" ] -then - # Create app folders - mkdir -p "$datadir" -fi +# Create app folders +mkdir -p "$datadir" -# Give permission to the datadir -chown -R $app:$app $datadir +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R root:$app "$datadir" #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Updating a config file..." ynh_add_config --template="../conf/production.yaml" --destination="$final_path/config/production.yaml" -local_config="$final_path/config/local-production.json" -ynh_backup_if_checksum_is_different --file="$local_config" -ynh_store_file_checksum --file="$local_config" +chmod 400 "$final_path/config/production.yaml" +chown $app:$app "$final_path/config/production.yaml" + +ynh_add_config --template="../conf/local-production.json" --destination="$final_path/config/local-production.json" + +chmod 400 "$final_path/config/local-production.json" +chown $app:$app "$final_path/config/local-production.json" #================================================= # BUILD YARN DEPENDENCIES @@ -268,17 +266,6 @@ ynh_add_systemd_config --others_var="ynh_node_load_PATH" #================================================= # 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 - -# Give permission to the datadir -chown -R $app:$app $datadir - #================================================= # SETUP LOGROTATE #================================================= From 55b28881bed32fb4859341b895c3aaff0f000ee9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 20:40:25 +0200 Subject: [PATCH 04/10] Fix rights --- scripts/install | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 07fe1fe..28ed43b 100644 --- a/scripts/install +++ b/scripts/install @@ -132,7 +132,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 @@ -154,7 +154,7 @@ mkdir -p "$datadir" chmod 750 "$datadir" chmod -R o-rwx "$datadir" -chown -R root:$app "$datadir" +chown -R $app:$app "$datadir" #================================================= # BUILD YARN DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index f1002f5..9b06575 100644 --- a/scripts/restore +++ b/scripts/restore @@ -73,7 +73,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 @@ -89,7 +89,7 @@ mkdir -p "$datadir" chmod 750 "$datadir" chmod -R o-rwx "$datadir" -chown -R root:$app "$datadir" +chown -R $app:$app "$datadir" #================================================= # OPEN A PORT diff --git a/scripts/upgrade b/scripts/upgrade index 1ce2fad..d2a7031 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -171,7 +171,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,7 +218,7 @@ mkdir -p "$datadir" chmod 750 "$datadir" chmod -R o-rwx "$datadir" -chown -R root:$app "$datadir" +chown -R $app:$app "$datadir" #================================================= # UPDATE A CONFIG FILE From 082854402899d698a60494a4bc47b70eba924e50 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 20:43:53 +0200 Subject: [PATCH 05/10] Several reorder --- scripts/_common.sh | 2 +- scripts/install | 18 +++++++++--------- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 1441eb6..d6aa49f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ # dependencies used by the app pkg_dependencies="ffmpeg postgresql postgresql-contrib openssl g++ redis-server redis-tools mailutils apt-transport-https" -YNH_NODEJS_VERSION=14 +NODEJS_VERSION=14 #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 28ed43b..65b76d2 100644 --- a/scripts/install +++ b/scripts/install @@ -82,7 +82,7 @@ ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port ynh_script_progression --message="Installing dependencies..." # Install nodejs -ynh_install_nodejs --nodejs_version=$YNH_NODEJS_VERSION +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION # Install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -166,14 +166,6 @@ pushd "$final_path" ynh_exec_warn_less sudo -u $app env $ynh_node_load_PATH yarn install --production --pure-lockfile popd -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config --others_var="ynh_node_load_PATH" - #================================================= # ADD A CONFIGURATION #================================================= @@ -189,6 +181,14 @@ ynh_add_config --template="../conf/local-production.json" --destination="$final_ chmod 400 "$final_path/config/local-production.json" chown $app:$app "$final_path/config/local-production.json" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config --others_var="ynh_node_load_PATH" + #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/restore b/scripts/restore index 9b06575..219f03e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -105,7 +105,7 @@ ynh_exec_warn_less yunohost firewall allow TCP $rtmp_port ynh_script_progression --message="Reinstalling dependencies..." # Install nodejs -ynh_install_nodejs --nodejs_version=$YNH_NODEJS_VERSION +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION # Install dependencies ynh_install_app_dependencies $pkg_dependencies diff --git a/scripts/upgrade b/scripts/upgrade index d2a7031..73bb2d3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -107,8 +107,8 @@ 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 ynh_clean_check_starting + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -187,7 +187,7 @@ ynh_add_nginx_config "datadir" ynh_script_progression --message="Upgrading dependencies..." # Install nodejs -ynh_install_nodejs --nodejs_version=$YNH_NODEJS_VERSION +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION # Install dependencies ynh_install_app_dependencies $pkg_dependencies From fd89035a375124a4efe4698009f62f75f1f7533f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 12 Apr 2021 08:22:21 +0200 Subject: [PATCH 06/10] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 184542e..ce713f1 100644 --- a/check_process +++ b/check_process @@ -29,7 +29,7 @@ backup_restore=1 multi_instance=0 port_already_use=0 - change_url=1 + change_url=0 ;;; Options Email=anmol@datamol.org;yalh@yahoo.com Notification=yes From 290e1299fc823e6d217c9016e453d82862081e8e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 14 Apr 2021 20:55:31 +0200 Subject: [PATCH 07/10] Fix cp --- scripts/upgrade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 73bb2d3..bd2d62b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,10 +143,10 @@ then tmpdir="$(mktemp -d)" # Backup the config file in the temp dir - cp -a "$final_path/config/production.yaml" "$tmpdir/production.yaml" + cp -af "$final_path/config/production.yaml" "$tmpdir/production.yaml" if [ -s "$final_path/config/local-production.json" ] then - cp -a "$final_path/config/local-production.json" "$tmpdir/local-production.json" + cp -af "$final_path/config/local-production.json" "$tmpdir/local-production.json" fi # Remove the app directory securely @@ -156,11 +156,11 @@ then ynh_setup_source --dest_dir="$final_path" #Copy the admin saved settings from tmp directory to final path - cp -a "$tmpdir/production.yaml" "$final_path/config/production.yaml" + cp -af "$tmpdir/production.yaml" "$final_path/config/production.yaml" if [ -s "$tmpdir/local-production.json" ] then - cp -a "$tmpdir/local-production.json" "$final_path/config/local-production.json" + cp -af "$tmpdir/local-production.json" "$final_path/config/local-production.json" else cp ../conf/local-production.json "$final_path/config/local-production.json" fi From 0e66238cb963ac15c2273238a6b2ed24032179ef Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 15 Apr 2021 20:29:01 +0200 Subject: [PATCH 08/10] Fix chmod --- scripts/install | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 65b76d2..a48ecdc 100644 --- a/scripts/install +++ b/scripts/install @@ -130,7 +130,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" @@ -152,7 +152,7 @@ ynh_script_progression --message="Creating the data directory..." # Create app folders mkdir -p "$datadir" -chmod 750 "$datadir" +chmod -R 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" diff --git a/scripts/restore b/scripts/restore index 219f03e..639268f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,7 +71,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" @@ -87,7 +87,7 @@ ynh_restore_file --origin_path="$datadir" --not_mandatory mkdir -p "$datadir" -chmod 750 "$datadir" +chmod -R 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" diff --git a/scripts/upgrade b/scripts/upgrade index bd2d62b..e88c791 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -169,7 +169,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" @@ -216,7 +216,7 @@ ynh_script_progression --message="Creating the data directory..." # Create app folders mkdir -p "$datadir" -chmod 750 "$datadir" +chmod -R 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" From ed96881283b5985dcea76a245133f2a8bc3d1caa Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 15:35:19 +0200 Subject: [PATCH 09/10] Fix rights --- 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 a48ecdc..42d51af 100644 --- a/scripts/install +++ b/scripts/install @@ -132,7 +132,7 @@ ynh_setup_source --dest_dir="$final_path" chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 639268f..e210367 100644 --- a/scripts/restore +++ b/scripts/restore @@ -73,7 +73,7 @@ ynh_restore_file --origin_path="$final_path" chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index e88c791..9b65839 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -171,7 +171,7 @@ fi chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION From b5475a003c46897f7a91327f2a6e7ac4a5d6e40f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:31:58 +0200 Subject: [PATCH 10/10] Fix recursive chmod --- scripts/install | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 42d51af..50849a3 100644 --- a/scripts/install +++ b/scripts/install @@ -130,7 +130,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:www-data "$final_path" @@ -152,7 +152,7 @@ ynh_script_progression --message="Creating the data directory..." # Create app folders mkdir -p "$datadir" -chmod -R 750 "$datadir" +chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" diff --git a/scripts/restore b/scripts/restore index e210367..7f7fe79 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,7 +71,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:www-data "$final_path" @@ -87,7 +87,7 @@ ynh_restore_file --origin_path="$datadir" --not_mandatory mkdir -p "$datadir" -chmod -R 750 "$datadir" +chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir" diff --git a/scripts/upgrade b/scripts/upgrade index 9b65839..07f9da9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -169,7 +169,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:www-data "$final_path" @@ -216,7 +216,7 @@ ynh_script_progression --message="Creating the data directory..." # Create app folders mkdir -p "$datadir" -chmod -R 750 "$datadir" +chmod 750 "$datadir" chmod -R o-rwx "$datadir" chown -R $app:$app "$datadir"