1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/simple-torrent_ynh.git synced 2024-09-03 20:26:18 +02:00

Merge branch 'config-panel' into configpanel

This commit is contained in:
ericgaspar 2022-01-19 15:59:31 +01:00
commit ab73b3ab82
8 changed files with 89 additions and 7 deletions

View file

@ -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

View file

@ -19,20 +19,20 @@ 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
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.
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

View file

@ -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

View file

@ -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

44
config_panel.toml Normal file
View file

@ -0,0 +1,44 @@
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"
[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"

View file

@ -27,6 +27,11 @@ architecture=$(ynh_detect_arch)
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
#=================================================
@ -51,6 +56,10 @@ 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
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

View file

@ -55,6 +55,7 @@ ynh_secure_remove --file="$final_path"
# REMOVE DATA DIR
#=================================================
# 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

View file

@ -23,6 +23,11 @@ port=$(ynh_app_setting_get --app=$app --key=port)
peer_port=$(ynh_app_setting_get --app=$app --key=peer_port)
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)
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
#=================================================
@ -54,6 +59,26 @@ 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
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
@ -87,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"
pushd "$final_path"
gzip --decompress $(ynh_detect_arch).gz
@ -111,9 +136,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