From 4681c08ae82bb5729871696ad9a411fc971b8cd4 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 4 Dec 2021 23:50:03 +0100 Subject: [PATCH 01/10] arch --- conf/{x86_64.src => amd64.src} | 1 + conf/arm64.src | 1 + conf/i386.src | 1 + conf/nginx.conf | 5 ----- scripts/_common.sh | 21 --------------------- scripts/install | 7 +------ scripts/remove | 13 +++++++------ scripts/upgrade | 7 +------ 8 files changed, 12 insertions(+), 44 deletions(-) rename conf/{x86_64.src => amd64.src} (89%) diff --git a/conf/x86_64.src b/conf/amd64.src similarity index 89% rename from conf/x86_64.src rename to conf/amd64.src index 6489df8..f2281a6 100644 --- a/conf/x86_64.src +++ b/conf/amd64.src @@ -3,4 +3,5 @@ SOURCE_SUM=d2f535e4cd0449b357a563cfce79c1f6afcac9b7b3af94e758defc44faa52ebf SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=gz SOURCE_IN_SUBDIR=false +SOURCE_FILENAME=simple-torrent SOURCE_EXTRACT=false diff --git a/conf/arm64.src b/conf/arm64.src index 6c4b48d..f374176 100644 --- a/conf/arm64.src +++ b/conf/arm64.src @@ -3,4 +3,5 @@ SOURCE_SUM=6f48f8b59bc8d834c6ede1d27ecc1a598b8a0be1dab00622caa6fd047e51eed6 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=gz SOURCE_IN_SUBDIR=false +SOURCE_FILENAME=simple-torrent SOURCE_EXTRACT=false diff --git a/conf/i386.src b/conf/i386.src index dd17e3a..47e8bd2 100644 --- a/conf/i386.src +++ b/conf/i386.src @@ -3,4 +3,5 @@ SOURCE_SUM=583898eb907c21dbbcb6f33934eae3dc1d6ec2620fdc7689c70a3479049af52b SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=gz SOURCE_IN_SUBDIR=false +SOURCE_FILENAME=simple-torrent SOURCE_EXTRACT=false diff --git a/conf/nginx.conf b/conf/nginx.conf index d8ac826..f1a7df9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,5 @@ #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__/; proxy_redirect off; diff --git a/scripts/_common.sh b/scripts/_common.sh index 8fc49a5..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,24 +15,3 @@ #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# Check the architecture -# -# example: architecture=$(ynh_detect_arch) -# -# usage: ynh_detect_arch -# -# Requires YunoHost version 2.2.4 or higher. -ynh_detect_arch() { - local architecture - if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then - architecture="arm64" - elif [ -n "$(uname -m | grep 86)" ]; then - architecture="i386" - elif [ -n "$(uname -m | grep 64)" ]; then - architecture="x86_64" - else - architecture="unknown" - fi - echo $architecture -} diff --git a/scripts/install b/scripts/install index 12beb0c..cf24677 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -architecture=$(ynh_detect_arch) +architecture=$YNH_ARCH app=$YNH_APP_INSTANCE_NAME @@ -88,11 +88,6 @@ 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="$architecture" -pushd "$final_path" - gzip --decompress $(ynh_detect_arch).gz - mv $(ynh_detect_arch) $app -popd - chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" diff --git a/scripts/remove b/scripts/remove index 8fef2b5..5abf796 100644 --- a/scripts/remove +++ b/scripts/remove @@ -55,12 +55,13 @@ ynh_secure_remove --file="$final_path" # REMOVE DATA DIR #================================================= -# # Remove the app data directory with the command `yunohost app remove --purge` -# if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -# then -# ynh_script_progression --message="Removing $app data directory..." --weight=2 -# ynh_secure_remove --file="$datadir" -# fi +# Remove the app data directory with the command `yunohost app remove --purge` +# Remove the data directory if --purge option is used +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] +then + ynh_script_progression --message="Removing app data directory..." --weight=1 + ynh_secure_remove --file="$datadir" +fi #================================================= # REMOVE NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index b7e46f0..33de52e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) -architecture=$(ynh_detect_arch) +architecture=$YNH_ARCH #================================================= # CHECK VERSION @@ -88,11 +88,6 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$final_path --source_id="$architecture" --keep="$final_path/config.yml" - - pushd "$final_path" - gzip --decompress $(ynh_detect_arch).gz - mv $(ynh_detect_arch) $app - popd fi chmod 750 "$final_path" From a19d3e85663cc019d373edbd91189dbbfdae6009 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:03:59 +0100 Subject: [PATCH 02/10] Create config_panel.toml --- config_panel.toml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 config_panel.toml diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..e69de29 From 98128ad54dc0d04e8fe442989601d107c926ae52 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:19:41 +0100 Subject: [PATCH 03/10] FIx --- config_panel.toml | 22 ++++++++++++++++++++++ scripts/install | 5 +++++ scripts/upgrade | 13 +++++++++++++ 3 files changed, 40 insertions(+) diff --git a/config_panel.toml b/config_panel.toml index e69de29..f321441 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -0,0 +1,22 @@ +version = "1.0" + +[main] +name = "Simple Torrent configuration" +services = ["__APP__"] + + [main.config] + name = "Configuration Options" + + [main.config.download_directory] + ask = "Set download directory" + type = "string" + default = "/home/yunohost.app/__APP__/downloads" + help = "The directory where downloaded file saves." + bind = "DownloadDirectory:__FINALPATH__/config.yml" + + [main.config.watch_directory] + ask = "Set watch directory" + type = "string" + default = "/home/yunohost.app/__APP__/torrents" + help = "The directory where downloaded file saves." + bind = "WatchDirectory:__FINALPATH__/config.yml" diff --git a/scripts/install b/scripts/install index cf24677..e18ee0a 100644 --- a/scripts/install +++ b/scripts/install @@ -27,6 +27,9 @@ architecture=$YNH_ARCH app=$YNH_APP_INSTANCE_NAME +download_directory="/home/yunohost.app/$app/downloads" +watch_directory="/home/yunohost.app/$app/torrents" + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -51,6 +54,8 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=download_directory --value=$download_directory +ynh_app_setting_set --app=$app --key=watch_directory --value=$watch_directory #================================================= # STANDARD MODIFICATIONS diff --git a/scripts/upgrade b/scripts/upgrade index 33de52e..3e6dff7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,9 @@ port=$(ynh_app_setting_get --app=$app --key=port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) architecture=$YNH_ARCH +download_directory=$(ynh_app_setting_get --app=$app --key=download_directory) +watch_directory=$(ynh_app_setting_get --app=$app --key=watch_directory) + #================================================= # CHECK VERSION #================================================= @@ -54,6 +57,16 @@ then ynh_die --message="Sorry, this app cannot be installed on a 32-bit ARM machine." fi +if [ -z "$download_directory" ]; then + download_directory="/home/yunohost.app/$app/downloads" + ynh_app_setting_set --app=$app --key=download_directory --value=$download_directory +fi + +if [ -z "$watch_directory" ]; then + watch_directory="/home/yunohost.app/$app/torrents" + ynh_app_setting_set --app=$app --key=watch_directory --value=$watch_directory +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all From a31cdf071eb3ffe8a22e0ca900977343d50a9201 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:30:33 +0100 Subject: [PATCH 04/10] fix --- conf/config.default.yml | 6 +++--- config_panel.toml | 22 ++++++++++++++++++++++ scripts/install | 4 ++++ scripts/upgrade | 12 ++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/conf/config.default.yml b/conf/config.default.yml index c9949db..3ec8faf 100644 --- a/conf/config.default.yml +++ b/conf/config.default.yml @@ -19,7 +19,7 @@ ObfsRequirePreferred: false DisableTrackers: false # DisableTrackers Don't announce to trackers. This only leaves DHT to discover peers. -DisableIPv6: false +DisableIPv6: __DISABLE_IP_V6__ # DisableIPv6 Don't connect to IPv6 peers. DisableUTP: false @@ -29,10 +29,10 @@ DisableUTP: false NoDefaultPortForwarding: true # Don't broadcast the UPNP request for gateway port forwarding, which is unnecessary in machines that has public IP (of which this program is mean for?) -DownloadDirectory: /home/yunohost.app/__APP__/downloads +DownloadDirectory: __DOWNLOAD_DIRECTORY__ # DisableEncryption A switch disables [BitTorrent protocol encryption](https://en.wikipedia.org/wiki/BitTorrent_protocol_encryption) -WatchDirectory: /home/yunohost.app/__APP__/torrents +WatchDirectory: __WATCH_DIRECTORY__ # DownloadDirectory The directory where downloaded file saves. EnableUpload: true diff --git a/config_panel.toml b/config_panel.toml index f321441..e4e061c 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -20,3 +20,25 @@ services = ["__APP__"] default = "/home/yunohost.app/__APP__/torrents" help = "The directory where downloaded file saves." bind = "WatchDirectory:__FINALPATH__/config.yml" + + [main.config.disable_ip_v6] + ask = "Disable IPv6" + type = "boolean" + yes = "true" + no = "false" + help = "Don't connect to IPv6 peers." + bind = "DisableIPv6:__FINALPATH__/config.yml" + + [main.config.disable_utp] + ask = "Disable UTP" + type = "boolean" + yes = "true" + no = "false" + help = "Disable UTP in the torrent protocol. In recent versions, the UTP process cause quite high CPU usage. Set to true can ease the situation." + bind = "DisableUTP:__FINALPATH__/config.yml" + + + + + + diff --git a/scripts/install b/scripts/install index e18ee0a..353124f 100644 --- a/scripts/install +++ b/scripts/install @@ -29,6 +29,8 @@ app=$YNH_APP_INSTANCE_NAME download_directory="/home/yunohost.app/$app/downloads" watch_directory="/home/yunohost.app/$app/torrents" +disable_ip_v6="false" +disable_utp="false" #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -56,6 +58,8 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=download_directory --value=$download_directory ynh_app_setting_set --app=$app --key=watch_directory --value=$watch_directory +ynh_app_setting_set --app=$app --key=disable_ip_v6 --value=$disable_ip_v6 +ynh_app_setting_set --app=$app --key=disable_utp --value=$disable_utp #================================================= # STANDARD MODIFICATIONS diff --git a/scripts/upgrade b/scripts/upgrade index 3e6dff7..c575d46 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,8 @@ architecture=$YNH_ARCH download_directory=$(ynh_app_setting_get --app=$app --key=download_directory) watch_directory=$(ynh_app_setting_get --app=$app --key=watch_directory) +disable_ip_v6=$(ynh_app_setting_get --app=$app --key=disable_ip_v6) +disable_utp=$(ynh_app_setting_get --app=$app --key=disable_utp) #================================================= # CHECK VERSION @@ -67,6 +69,16 @@ if [ -z "$watch_directory" ]; then ynh_app_setting_set --app=$app --key=watch_directory --value=$watch_directory fi +if [ -z "$disable_ip_v6" ]; then + disable_ip_v6="false" + ynh_app_setting_set --app=$app --key=disable_ip_v6 --value=$disable_ip_v6 +fi + +if [ -z "$disable_utp" ]; then + disable_utp="false" + ynh_app_setting_set --app=$app --key=disable_utp --value=$disable_utp +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all From 6506e4b1bd31e2cafe5908c3cc9f396a20678341 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:35:57 +0100 Subject: [PATCH 05/10] Fix --- conf/config.default.yml | 2 +- scripts/upgrade | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/config.default.yml b/conf/config.default.yml index 3ec8faf..059f590 100644 --- a/conf/config.default.yml +++ b/conf/config.default.yml @@ -22,7 +22,7 @@ DisableTrackers: false DisableIPv6: __DISABLE_IP_V6__ # DisableIPv6 Don't connect to IPv6 peers. -DisableUTP: false +DisableUTP: __DISABLE_UTP__ # Disable UTP in the torrent protocol. # In recent versions, the UTP process cause quite high CPU usage. Set to true can ease the situation. diff --git a/scripts/upgrade b/scripts/upgrade index c575d46..9835ca1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,7 +112,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path --source_id="$architecture" --keep="$final_path/config.yml" + ynh_setup_source --dest_dir=$final_path --source_id="$architecture" #--keep="$final_path/config.yml" fi chmod 750 "$final_path" @@ -131,9 +131,9 @@ ynh_add_nginx_config #================================================= # MODIFY A CONFIG FILE #================================================= -# ynh_script_progression --message="Modifying a config file..." --weight=1 +ynh_script_progression --message="Modifying a config file..." --weight=1 -# ynh_add_config --template="../conf/config.default.yml" --destination="$final_path/config.yml" +ynh_add_config --template="../conf/config.default.yml" --destination="$final_path/config.yml" #================================================= # CREATE DIRECTORIES From 7dd3b013236761e0d4e47a516fae9d68e2418c58 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:42:37 +0100 Subject: [PATCH 06/10] Update _common.sh --- scripts/_common.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..8fc49a5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -15,3 +15,24 @@ #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +# Check the architecture +# +# example: architecture=$(ynh_detect_arch) +# +# usage: ynh_detect_arch +# +# Requires YunoHost version 2.2.4 or higher. +ynh_detect_arch() { + local architecture + if [ -n "$(uname -m | grep arm64)" ] || [ -n "$(uname -m | grep aarch64)" ]; then + architecture="arm64" + elif [ -n "$(uname -m | grep 86)" ]; then + architecture="i386" + elif [ -n "$(uname -m | grep 64)" ]; then + architecture="x86_64" + else + architecture="unknown" + fi + echo $architecture +} From 91b0349085bf52d512d374c8f92b74e2b52efdfc Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:43:16 +0100 Subject: [PATCH 07/10] Fix --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 353124f..9824915 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -architecture=$YNH_ARCH +architecture=$(ynh_detect_arch) app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/upgrade b/scripts/upgrade index 9835ca1..963eea5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) -architecture=$YNH_ARCH +architecture=$(ynh_detect_arch) download_directory=$(ynh_app_setting_get --app=$app --key=download_directory) watch_directory=$(ynh_app_setting_get --app=$app --key=watch_directory) From fe270614b8a6565bdd04b68bfa2dd1087c0b6af6 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:55:30 +0100 Subject: [PATCH 08/10] Fix --- scripts/install | 5 +++++ scripts/upgrade | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/scripts/install b/scripts/install index 9824915..fedc51c 100644 --- a/scripts/install +++ b/scripts/install @@ -97,6 +97,11 @@ 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="$architecture" +pushd "$final_path" + gzip --decompress $(ynh_detect_arch).gz + mv $(ynh_detect_arch) $app +popd + chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 963eea5..a9ceb14 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,6 +115,11 @@ then ynh_setup_source --dest_dir=$final_path --source_id="$architecture" #--keep="$final_path/config.yml" fi +pushd "$final_path" + gzip --decompress $(ynh_detect_arch).gz + mv $(ynh_detect_arch) $app +popd + chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" From a7147d5c9c24134a71c606de96c8d37183a451d1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:56:07 +0100 Subject: [PATCH 09/10] Update upgrade --- scripts/upgrade | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index a9ceb14..8a3db4d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -113,12 +113,12 @@ then # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$final_path --source_id="$architecture" #--keep="$final_path/config.yml" -fi -pushd "$final_path" - gzip --decompress $(ynh_detect_arch).gz - mv $(ynh_detect_arch) $app -popd + pushd "$final_path" + gzip --decompress $(ynh_detect_arch).gz + mv $(ynh_detect_arch) $app + popd +fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" From 113f6d83530585d8bba5fb8e5aca8272345dab5a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 19 Jan 2022 15:57:10 +0100 Subject: [PATCH 10/10] Fix --- conf/{amd64.src => x86_64.src} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename conf/{amd64.src => x86_64.src} (100%) diff --git a/conf/amd64.src b/conf/x86_64.src similarity index 100% rename from conf/amd64.src rename to conf/x86_64.src