From 396e9b4191802fc487905959d596343df7b425c5 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Dec 2021 13:56:39 +0100 Subject: [PATCH 1/6] Move app data directory to /home/yunohost.app --- check_process | 8 ++++---- manifest.json | 2 +- scripts/backup | 7 +++++++ scripts/install | 18 +++++++++++++----- scripts/remove | 9 +++++++++ scripts/restore | 17 ++++++++++++++++- scripts/upgrade | 18 +++++++++++++++--- 7 files changed, 65 insertions(+), 14 deletions(-) diff --git a/check_process b/check_process index 1ba2470..d804bfb 100644 --- a/check_process +++ b/check_process @@ -16,7 +16,7 @@ setup_private=1 setup_public=1 upgrade=1 - #upgrade=1 from_commit=CommitHash + upgrade=1 from_commit=e0fcbf74138612f466fe0ce735060394245d8bb5 backup_restore=1 multi_instance=1 port_already_use=0 @@ -25,6 +25,6 @@ Email= Notification=none ;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1& + ; commit=e0fcbf74138612f466fe0ce735060394245d8bb5 + name=2021-09-30 0.1.1.875~ynh1 + manifest_arg=domain=DOMAIN&path=PATH&admin=USER& diff --git a/manifest.json b/manifest.json index f4b20d8..093db56 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Complete management of your indexers for Radarr, Sonarr, Lidarr, ...", "fr": "Gestion complète de vos indexeurs pour Radarr, Sonarr, Lidarr, ..." }, - "version": "0.1.1.875~ynh1", + "version": "0.1.1.875~ynh2", "url": "https://prowlarr.com", "upstream": { "license": "GPL-3.0-only", diff --git a/scripts/backup b/scripts/backup index 0670178..8555a32 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,6 +29,7 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= @@ -47,6 +48,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE APP DATA DIR +#================================================= + +ynh_backup --src_path="$data_path" + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/install b/scripts/install index 4b2d2bf..029f01c 100755 --- a/scripts/install +++ b/scripts/install @@ -36,7 +36,10 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/opt/yunohost/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="Installation path ($final_path) already exists" + +data_path=/home/yunohost.app/$app +test ! -e "$data_path" || ynh_die --message="Data directory ($data_path) already exists" # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url @@ -87,7 +90,8 @@ 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" --source_id="app.$architecture" -mkdir -p "$final_path/.data/logs" +ynh_app_setting_set --app=$app --key=data_path --value=$data_path +mkdir -p "$data_path/logs" #================================================= # NGINX CONFIGURATION @@ -115,7 +119,7 @@ ynh_script_progression --message="Configuring Prowlarr..." --weight=2 api_key=$(ynh_string_random --length=32) ynh_app_setting_set --app=$app --key=api_key --value=$api_key -ynh_add_config --template="../conf/config.xml" --destination="$final_path/.data/config.xml" +ynh_add_config --template="../conf/config.xml" --destination="$data_path/config.xml" #================================================= # SETUP FILE PERMISSIONS @@ -126,6 +130,10 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app: "$final_path" +chmod 750 "$data_path" +chmod -R o-rwx "$data_path" +chown -R $app: "$data_path" + #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= @@ -145,14 +153,14 @@ ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate -ynh_use_logrotate --logfile="$final_path/.data/logs" +ynh_use_logrotate --logfile="$data_path/logs" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Prowlarr daemon" --log="$final_path/.data/logs/prowlarr.txt" +yunohost service add $app --description="Prowlarr daemon" --log="$data_path/logs/prowlarr.txt" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index 6a5a83e..582f1c6 100755 --- a/scripts/remove +++ b/scripts/remove @@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # STANDARD REMOVE @@ -57,6 +58,14 @@ ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE APP DATA DIR +#================================================= +ynh_script_progression --message="Removing app data directory..." --weight=1 + +# Remove the app directory securely +ynh_secure_remove --file="$data_path" + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 41ea82a..b8e9be7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,6 +31,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -40,6 +41,9 @@ ynh_script_progression --message="Validating restoration parameters..." --weight test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " +test ! -d $data_path \ + || ynh_die --message="There is already a directory: $data_path " + #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -68,6 +72,17 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app: "$final_path" +#================================================= +# RESTORE THE APP DATA DIR +#================================================= +ynh_script_progression --message="Restoring the app data directory..." --weight=2 + +ynh_restore_file --origin_path="$data_path" + +chmod 750 "$data_path" +chmod -R o-rwx "$data_path" +chown -R $app: "$data_path" + #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= @@ -101,7 +116,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Prowlarr daemon" --log="$final_path/.data/logs/prowlarr.txt" +yunohost service add $app --description="Prowlarr daemon" --log="$data_path/logs/prowlarr.txt" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index c49fce1..2bea658 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) #================================================= # CHECK VERSION @@ -67,6 +68,13 @@ if ! ynh_permission_exists --permission="api"; then ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" fi +# Move data directory if needed +if [ -z "$data_path" ]; then + data_path=/home/yunohost.app/$app + ynh_app_setting_set --app=$app --key=data_path --value=$daya_path + mv "$final_path/.data" "/home/yunohost.app/$app" +fi + #================================================= # CREATE DEDICATED USER #================================================= @@ -89,11 +97,15 @@ then ynh_setup_source --dest_dir="$final_path" --source_id="app.$architecture" fi -mkdir -p "$final_path/.data/logs" chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app: "$final_path" +mkdir -p "$data_path/logs" +chmod 750 "$data_path" +chmod -R o-rwx "$data_path" +chown -R $app: "$data_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -128,14 +140,14 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --weight # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -ynh_use_logrotate --non-append --logfile="$final_path/.data/logs" +ynh_use_logrotate --non-append --logfile="$data_path/logs" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="Prowlarr daemon" --log="$final_path/.data/logs/prowlarr.txt" +yunohost service add $app --description="Prowlarr daemon" --log="$data_path/logs/prowlarr.txt" #================================================= # START SYSTEMD SERVICE From f78afcbe7082e27bcb2bd6985a35ae50e867a701 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Sat, 18 Dec 2021 12:59:13 +0000 Subject: [PATCH 2/6] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4bf2e35..4b6988d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Complete management of your indexers for Radarr, Sonarr, Lidarr, ... -**Shipped version:** 0.1.1.875~ynh1 +**Shipped version:** 0.1.1.875~ynh2 diff --git a/README_fr.md b/README_fr.md index 5266ad6..34b816a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Gestion complète de vos indexeurs pour Radarr, Sonarr, Lidarr, ... -**Version incluse :** 0.1.1.875~ynh1 +**Version incluse :** 0.1.1.875~ynh2 From a1af5074ca707072f7e74e3b6b530902ee0852a0 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Dec 2021 14:09:07 +0100 Subject: [PATCH 3/6] Change data path in service --- conf/systemd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index 9bd8a95..33e3501 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/Prowlarr -nobrowser -data=__FINALPATH__/.data +ExecStart=__FINALPATH__/Prowlarr -nobrowser -data=__DATA_PATH__ TimeoutStopSec=20 KillMode=process From 3608473005f3b97d10f660d51e36187344bc10d9 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Dec 2021 19:12:38 +0100 Subject: [PATCH 4/6] Fix typo --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2bea658..6700ffb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -71,7 +71,7 @@ fi # Move data directory if needed if [ -z "$data_path" ]; then data_path=/home/yunohost.app/$app - ynh_app_setting_set --app=$app --key=data_path --value=$daya_path + ynh_app_setting_set --app=$app --key=data_path --value=$data_path mv "$final_path/.data" "/home/yunohost.app/$app" fi From 83058bccf73b70dd3209dbe2292d6ba3deb411e7 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Dec 2021 19:16:38 +0100 Subject: [PATCH 5/6] Data path is also used in change_url --- scripts/change_url | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 35c55c5..2b8fca6 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,7 @@ ynh_script_progression --message="Loading installation settings..." --time --wei # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) +data_path=$(ynh_app_setting_get --app=$app --key=data_path) port=$(ynh_app_setting_get --app=$app --key=port) api_key=$(ynh_app_setting_get --app=$app --key=api_key) @@ -112,11 +113,11 @@ fi # UPDATE CONFIGURATION FILE #================================================= -ynh_exec_warn_less 'ynh_add_config --template="../conf/config.xml" --destination="$final_path/.data/config.xml"' +ynh_exec_warn_less 'ynh_add_config --template="../conf/config.xml" --destination="$data_path/config.xml"' -chmod 750 "$final_path/.data/config.xml" -chmod o-rwx "$final_path/.data/config.xml" -chown $app "$final_path/.data/config.xml" +chmod 750 "$data_path/config.xml" +chmod o-rwx "$data_path/config.xml" +chown $app "$data_path/config.xml" #================================================= # GENERIC FINALISATION From ed5fb67ff50b279e4cb9d31a6b285f91cc3e16c5 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sat, 18 Dec 2021 21:50:41 +0100 Subject: [PATCH 6/6] Appease linter --- conf/nginx.conf | 5 ----- manifest.json | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 5bdbc1e..cb18632 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,11 +1,6 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__ { - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - proxy_pass http://127.0.0.1:__PORT____PATH__; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/manifest.json b/manifest.json index 093db56..329121a 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,7 @@ "email": "tituspijean@outlook.com" }, "requirements": { - "yunohost": ">= 4.2" + "yunohost": ">= 4.3" }, "multi_instance": true, "services": [