From 3ac30d2f8156de6554f52f200e8d333019125bdb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 3 Jul 2022 20:36:04 +0200 Subject: [PATCH 01/10] Apply example_ynh --- .github/workflows/updater.sh | 137 ++++++++++++++++ check_process | 15 +- conf/nginx.conf | 30 ++-- conf/settings.json | 144 ++++++++-------- doc/.gitkeep | 0 doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 1 + doc/DISCLAIMER.md | 21 +++ doc/DISCLAIMER_fr.md | 21 +++ doc/screenshots/.gitkeep | 0 .../screenshots/transmission.jpg | Bin manifest.json | 77 +++++---- scripts/_common.sh | 42 ----- scripts/backup | 20 ++- scripts/change_url | 4 + scripts/install | 124 +++++++------- scripts/remove | 46 +++--- scripts/restore | 132 +++++++-------- scripts/upgrade | 154 +++++++++--------- 19 files changed, 560 insertions(+), 409 deletions(-) create mode 100644 .github/workflows/updater.sh create mode 100644 doc/.gitkeep create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md create mode 100644 doc/DISCLAIMER.md create mode 100644 doc/DISCLAIMER_fr.md create mode 100644 doc/screenshots/.gitkeep rename transmission.jpg => doc/screenshots/transmission.jpg (100%) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh new file mode 100644 index 0000000..72eb5cb --- /dev/null +++ b/.github/workflows/updater.sh @@ -0,0 +1,137 @@ +#!/bin/bash + +#================================================= +# PACKAGE UPDATING HELPER +#================================================= + +# This script is meant to be run by GitHub Actions +# The YunoHost-Apps organisation offers a template Action to run this script periodically +# Since each app is different, maintainers can adapt its contents so as to perform +# automatic actions when a new upstream release is detected. + +# Remove this exit command when you are ready to run this Action +exit 1 + +#================================================= +# FETCHING LATEST RELEASE AND ITS ASSETS +#================================================= + +# Fetching information +current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') +repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') +# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) +version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) +assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) + +# Later down the script, we assume the version has only digits and dots +# Sometimes the release name starts with a "v", so let's filter it out. +# You may need more tweaks here if the upstream repository has different naming conventions. +if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then + version=${version:1} +fi + +# Setting up the environment variables +echo "Current version: $current_version" +echo "Latest release from upstream: $version" +echo "VERSION=$version" >> $GITHUB_ENV +echo "REPO=$repo" >> $GITHUB_ENV +# For the time being, let's assume the script will fail +echo "PROCEED=false" >> $GITHUB_ENV + +# Proceed only if the retrieved version is greater than the current one +if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then + echo "::warning ::No new version available" + exit 0 +# Proceed only if a PR for this new version does not already exist +elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then + echo "::warning ::A branch already exists for this update" + exit 0 +fi + +# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) +echo "${#assets[@]} available asset(s)" + +#================================================= +# UPDATE SOURCE FILES +#================================================= + +# Here we use the $assets variable to get the resources published in the upstream release. +# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. + +# Let's loop over the array of assets URLs +for asset_url in ${assets[@]}; do + +echo "Handling asset at $asset_url" + +# Assign the asset to a source file in conf/ directory +# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) +# Leave $src empty to ignore the asset +case $asset_url in + *"admin"*) + src="app" + ;; + *"update"*) + src="app-upgrade" + ;; + *) + src="" + ;; +esac + +# If $src is not empty, let's process the asset +if [ ! -z "$src" ]; then + +# Create the temporary directory +tempdir="$(mktemp -d)" + +# Download sources and calculate checksum +filename=${asset_url##*/} +curl --silent -4 -L $asset_url -o "$tempdir/$filename" +checksum=$(sha256sum "$tempdir/$filename" | head -c 64) + +# Delete temporary directory +rm -rf $tempdir + +# Get extension +if [[ $filename == *.tar.gz ]]; then + extension=tar.gz +else + extension=${filename##*.} +fi + +# Rewrite source file +cat < conf/$src.src +SOURCE_URL=$asset_url +SOURCE_SUM=$checksum +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=$extension +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +EOT +echo "... conf/$src.src updated" + +else +echo "... asset ignored" +fi + +done + +#================================================= +# SPECIFIC UPDATE STEPS +#================================================= + +# Any action on the app's source code can be done. +# The GitHub Action workflow takes care of committing all changes after this script ends. + +#================================================= +# GENERIC FINALIZATION +#================================================= + +# Replace new version in manifest +echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json + +# No need to update the README, yunohost-bot takes care of it + +# The Action will proceed only if the PROCEED environment variable is set to true +echo "PROCEED=true" >> $GITHUB_ENV +exit 0 diff --git a/check_process b/check_process index 4aacb88..d9debb8 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,7 @@ ;; Test complet - auto_remove=1 ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" ; Checks pkg_linter=1 setup_sub_dir=1 @@ -11,14 +10,14 @@ setup_private=1 setup_public=0 upgrade=1 + # 1.0 upgrade=1 from_commit=7d887f6bc1e29ce94de703517d5302580cbb8a7e + # 1.0~ynh4 + upgrade=1 from_commit=c65b76e919089f3f88d2522cef2300db6f78201f backup_restore=1 multi_instance=0 + port_already_use=0 change_url=1 ;;; Options Email= -Notification=down -;;; Upgrade options - ; commit=7d887f6bc1e29ce94de703517d5302580cbb8a7e - name= Add acl dependency. Mar 3, 2018 - manifest_arg=domain=DOMAIN&path=PATH& +Notification=none diff --git a/conf/nginx.conf b/conf/nginx.conf index da17188..3e47350 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,23 +1,29 @@ location __PATH__/transmission { - proxy_pass http://127.0.0.1:__PORT____PATH__/transmission; + proxy_pass http://127.0.0.1:__PORT____PATH__/transmission; + more_clear_input_headers 'Accept-Encoding'; - client_max_body_size 8M; + client_max_body_size 8M; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; - more_clear_input_headers 'Accept-Encoding'; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } location __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__/; + proxy_pass http://127.0.0.1:__PORT____PATH__/; + more_clear_input_headers 'Accept-Encoding'; + + client_max_body_size 8M; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } location __PATH__/downloads/ { - alias /home/yunohost.transmission/completed/; - autoindex on; - autoindex_exact_size off; + alias __DATADIR__/completed/; + autoindex on; + autoindex_exact_size off; + more_clear_input_headers 'Accept-Encoding'; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; - more_clear_input_headers 'Accept-Encoding'; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/conf/settings.json b/conf/settings.json index cdcb4b2..14d56e6 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -1,75 +1,75 @@ { - "alt-speed-down": 50, - "alt-speed-enabled": false, - "alt-speed-time-begin": 540, - "alt-speed-time-day": 127, - "alt-speed-time-enabled": false, - "alt-speed-time-end": 1020, - "alt-speed-up": 50, - "bind-address-ipv4": "0.0.0.0", - "bind-address-ipv6": "::", - "blocklist-enabled": false, - "blocklist-url": "http://www.example.com/blocklist", - "cache-size-mb": 4, - "dht-enabled": true, - "download-dir": "/home/yunohost.transmission/completed", - "download-limit": 100, - "download-limit-enabled": 0, - "download-queue-enabled": true, - "download-queue-size": 5, - "encryption": 1, - "idle-seeding-limit": 30, - "idle-seeding-limit-enabled": false, - "incomplete-dir": "/home/yunohost.transmission/progress", - "incomplete-dir-enabled": true, - "lpd-enabled": false, - "max-peers-global": 200, - "message-level": 1, - "peer-congestion-algorithm": "", - "peer-id-ttl-hours": 6, - "peer-limit-global": 200, - "peer-limit-per-torrent": 50, - "peer-port": __PEER_PORT__, - "peer-port-random-high": 65535, - "peer-port-random-low": 49152, - "peer-port-random-on-start": false, - "peer-socket-tos": "default", - "pex-enabled": true, - "port-forwarding-enabled": false, - "preallocation": 1, - "prefetch-enabled": 1, - "queue-stalled-enabled": true, - "queue-stalled-minutes": 30, - "ratio-limit": 2, - "ratio-limit-enabled": false, - "rename-partial-files": true, - "rpc-authentication-required": false, - "rpc-bind-address": "127.0.0.1", - "rpc-enabled": true, - "rpc-host-whitelist": "", - "rpc-host-whitelist-enabled": false, - "rpc-password": "__RPC_PASSWORD_TO_CHANGE__", - "rpc-port": __PORT__, - "rpc-url": "__PATH__transmission/", - "rpc-username": "transmission", - "rpc-whitelist": "127.0.0.1", - "rpc-whitelist-enabled": false, - "scrape-paused-torrents-enabled": true, - "script-torrent-done-enabled": false, - "script-torrent-done-filename": "", - "seed-queue-enabled": false, - "seed-queue-size": 10, - "speed-limit-down": 100, - "speed-limit-down-enabled": false, - "speed-limit-up": 100, - "speed-limit-up-enabled": false, - "start-added-torrents": true, - "trash-original-torrent-files": false, - "umask": 18, - "upload-limit": 100, - "upload-limit-enabled": 0, - "upload-slots-per-torrent": 14, - "utp-enabled": true, - "watch-dir": "/home/yunohost.transmission/watched", + "alt-speed-down": 50, + "alt-speed-enabled": false, + "alt-speed-time-begin": 540, + "alt-speed-time-day": 127, + "alt-speed-time-enabled": false, + "alt-speed-time-end": 1020, + "alt-speed-up": 50, + "bind-address-ipv4": "0.0.0.0", + "bind-address-ipv6": "::", + "blocklist-enabled": false, + "blocklist-url": "http://www.example.com/blocklist", + "cache-size-mb": 4, + "dht-enabled": true, + "download-dir": "__DATADIR__/completed", + "download-limit": 100, + "download-limit-enabled": 0, + "download-queue-enabled": true, + "download-queue-size": 5, + "encryption": 1, + "idle-seeding-limit": 30, + "idle-seeding-limit-enabled": false, + "incomplete-dir": "__DATADIR__/progress", + "incomplete-dir-enabled": true, + "lpd-enabled": false, + "max-peers-global": 200, + "message-level": 1, + "peer-congestion-algorithm": "", + "peer-id-ttl-hours": 6, + "peer-limit-global": 200, + "peer-limit-per-torrent": 50, + "peer-port": __PEER_PORT__, + "peer-port-random-high": 65535, + "peer-port-random-low": 49152, + "peer-port-random-on-start": false, + "peer-socket-tos": "default", + "pex-enabled": true, + "port-forwarding-enabled": false, + "preallocation": 1, + "prefetch-enabled": true, + "queue-stalled-enabled": true, + "queue-stalled-minutes": 30, + "ratio-limit": 2, + "ratio-limit-enabled": false, + "rename-partial-files": true, + "rpc-authentication-required": false, + "rpc-bind-address": "127.0.0.1", + "rpc-enabled": true, + "rpc-host-whitelist": "", + "rpc-host-whitelist-enabled": false, + "rpc-password": "__RPCPASSWORD__", + "rpc-port": __PORT__, + "rpc-url": "__PATH_LESS__transmission/", + "rpc-username": "transmission", + "rpc-whitelist": "127.0.0.1", + "rpc-whitelist-enabled": false, + "scrape-paused-torrents-enabled": true, + "script-torrent-done-enabled": false, + "script-torrent-done-filename": "", + "seed-queue-enabled": false, + "seed-queue-size": 10, + "speed-limit-down": 100, + "speed-limit-down-enabled": false, + "speed-limit-up": 100, + "speed-limit-up-enabled": false, + "start-added-torrents": true, + "trash-original-torrent-files": false, + "umask": 18, + "upload-limit": 100, + "upload-limit-enabled": 0, + "upload-slots-per-torrent": 14, + "utp-enabled": true, + "watch-dir": "__DATADIR__/watched", "watch-dir-enabled": true } diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..9f4e7bf --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Transmission is a fast, easy, and free BitTorrent client. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..8e8a725 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Transmission est un client BitTorrent libre, efficace et simple. diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..749e331 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,21 @@ +## YunoHost specific features + + * Integration with YunoHost Multimedia directories + +## Additionnal informations +Alternative to WebUI : + +You can use remote client on different platforms to manage your Transmission server: + +* Dekstop: Transmission-remote-GUI: https://github.com/transmission-remote-gui/transgui +* Mobile: Transdroid: http://www.transdroid.org/ +* More clients here: https://transmissionbt.com/resources/ + +You can use the following information to connect your server: + +* Remote host: Your domain or IP address (don't add folder) +* Port: 443 +* SSL: Enabled +* User: Your Yunohost Username +* Password: Password of the Yunohost User above +* RPC Path: /torrent/transmission/rpc (if you used the standard folder) diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..a333dd8 --- /dev/null +++ b/doc/DISCLAIMER_fr.md @@ -0,0 +1,21 @@ +## Caractéristiques spécifiques YunoHost + + * Intégration avec les répertoires Multimédias de YunoHost + +## Informations additionnelles +Alternative à WebUI : + +Vous pouvez utiliser le client de contrôle à distance des différentes plateformes pour gérer votre serveur Transmission : + +* Bureau : Transmission-remote-GUI : https://github.com/transmission-remote-gui/transgui +* Mobile : Transdroid : http://www.transdroid.org/ +* Plus de clients ici : https://transmissionbt.com/resources/ + +Vous pouvez utiliser les informations suivantes pour vous connecter à votre serveur : + +* Hôte distant : Votre domaine ou adresse IP (n'ajoutez pas le répertoire) +* Port : 443 +* SSL : Activé +* Utilisateur : Votre nom d'utilisateur YunoHost +* Mot de passe : Le mot de passe de l'utilisateur YunoHost utilisé +* Répertoire RPC : `/torrent/transmission/rpc` (si vous utilisez le répertoire par défaut) diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/transmission.jpg b/doc/screenshots/transmission.jpg similarity index 100% rename from transmission.jpg rename to doc/screenshots/transmission.jpg diff --git a/manifest.json b/manifest.json index f12d575..55cab1e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,39 +1,44 @@ { - "name": "Transmission", - "id": "transmission", - "packaging_format": 1, - "description": { - "en": "A Fast, Easy, and Free BitTorrent Client", - "fr": "Un client BitTorrent libre et rapide" - }, - "version": "1.0~ynh4", - "url": "https://www.transmissionbt.com/", - "license": "GPL-3.0", - "maintainer": { - "name": "", - "email": "" - }, - "requirements": { - "yunohost": ">= 4.1.7" + "name": "Transmission", + "id": "transmission", + "packaging_format": 1, + "description": { + "en": "A Fast, Easy, and Free BitTorrent Client", + "fr": "Un client BitTorrent libre et rapide" }, - "multi_instance": false, - "services": [ - "nginx", - "transmission-daemon" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain", - "example": "domain.org" - }, - { - "name": "path", - "type": "path", - "example": "/transmission", - "default": "/transmission" - } - ] - } + "version": "2.94~ynh1", + "url": "https://www.transmissionbt.com", + "upstream": { + "license": "GPL-3.0", + "website": "https://www.transmissionbt.com", + "admindoc": "https://github.com/transmission/transmission/wiki", + "code": "https://github.com/transmission/transmission" + }, + "license": "GPL-3.0", + "maintainer": { + "name": "", + "email": "" + }, + "requirements": { + "yunohost": ">= 4.3.0" + }, + "multi_instance": false, + "services": [ + "nginx", + "transmission-daemon" + ], + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain" + }, + { + "name": "path", + "type": "path", + "example": "/transmission", + "default": "/transmission" + } + ] + } } diff --git a/scripts/_common.sh b/scripts/_common.sh index e3b88df..8d9a9d2 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,45 +18,3 @@ pkg_dependencies="transmission-daemon transmission-cli transmission-common acl" #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# Install or update the main directory yunohost.multimedia -# -# usage: ynh_multimedia_build_main_dir -ynh_multimedia_build_main_dir () { - local ynh_media_release="v1.2" - local checksum="806a827ba1902d6911095602a9221181" - - # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1 - - # Check the control sum - echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ - || ynh_die "Corrupt source" - - # Check if the package acl is installed. Or install it. - ynh_package_is_installed 'acl' \ - || ynh_package_install acl - - # Extract - mkdir yunohost.multimedia-master - tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 - ./yunohost.multimedia-master/script/ynh_media_build.sh -} - -# Add a directory in yunohost.multimedia -# This "directory" will be a symbolic link to a existing directory. -# -# usage: ynh_multimedia_addfolder "Source directory" "Destination directory" -# -# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias. -# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia" -ynh_multimedia_addfolder () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= ) - local source_dir - local dest_dir - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir" -} diff --git a/scripts/backup b/scripts/backup index 775a812..e180328 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# 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 @@ -24,6 +25,7 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -31,7 +33,13 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) ynh_print_info --message="Declaring files to be backed up..." #================================================= -# BACKUP OF THE NGINX CONFIGURATION +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + +#================================================= +# BACKUP THE NGINX CONFIGURATION #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -39,24 +47,18 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= -# BACKUP TRANSMISSION CONFIGURATION +# BACKUP VARIOUS FILES #================================================= ynh_backup --src_path="/etc/transmission-daemon/settings.json" if [ -e /proc/sys/net/core/rmem_max ] then - ynh_backup --src_path="/etc/sysctl.d/90-transmission.conf" + ynh_backup --src_path="/etc/sysctl.d/90-transmission.conf" fi -#================================================= -# BACKUP DATA -#================================================= - ynh_backup --src_path="/usr/share/transmission" ynh_backup --src_path="/var/lib/transmission-daemon" -ynh_backup --src_path="/home/yunohost.transmission" --is_big - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 2f8ffec..05d0dca 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -107,8 +107,12 @@ fi # UPDATE TRANSMISSION CONFIGURATION #================================================= +ynh_backup_if_checksum_is_different --file="/etc/transmission-daemon/settings.json" + ynh_replace_string --match_string="rpc-url\": \"${old_path%/}/transmission/" --replace_string="rpc-url\": \"${new_path%/}/transmission/" --target_file="/etc/transmission-daemon/settings.json" +ynh_store_file_checksum --file="/etc/transmission-daemon/settings.json" + #================================================= # GENERIC FINALISATION #================================================= diff --git a/scripts/install b/scripts/install index 3f80c43..b3ad146 100644 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,9 +10,12 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE FAILURE OF THE SCRIPT +# MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -25,8 +28,10 @@ path_url=$YNH_APP_ARG_PATH app=$YNH_APP_INSTANCE_NAME +rpcpassword=$(ynh_string_random) + #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_script_progression --message="Validating installation parameters..." @@ -40,30 +45,30 @@ 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=rpcpassword --value="$rpcpassword" #================================================= # STANDARD MODIFICATIONS #================================================= -# FIND AND OPEN PORTS +# FIND AND OPEN A PORT #================================================= ynh_script_progression --message="Finding an available port..." --weight=16 -# Find a free port +# Find an available port port=$(ynh_find_port --port=9091) -# Open this port -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port ynh_app_setting_set --app=$app --key=port --value=$port - -# Find a free port peer_port=$(ynh_find_port --port=51413) -# Open this port -ynh_exec_warn_less yunohost firewall allow Both $peer_port ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port +# Open the port +ynh_script_progression --message="Configuring firewall..." +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port +ynh_exec_warn_less yunohost firewall allow Both $peer_port + #================================================= -# INSTALL TRANSMISSION +# INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing Transmission..." --weight=16 +ynh_script_progression --message="Installing dependencies..." --weight=16 ynh_install_app_dependencies $pkg_dependencies @@ -78,6 +83,23 @@ then ynh_install_app_dependencies $pkg_dependencies --reinstall fi +#================================================= +# SPECIFIC SETUP +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir/{progress,completed,watched} + +chmod -R 764 $datadir +chmod -R 777 $datadir/watched +chown -R debian-transmission:www-data "$datadir" +chown -R debian-transmission: $datadir/{progress,watched} + #================================================= # NGINX CONFIGURATION #================================================= @@ -87,59 +109,33 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 ynh_add_nginx_config #================================================= -# SPECIFIC SETUP +# ADD A CONFIGURATION #================================================= -# CREATE DIRECTORIES -#================================================= - -mkdir -p /home/yunohost.transmission/{progress,completed,watched} - -#================================================= -# SECURING FILES AND DIRECTORIES -#================================================= - -chown -R debian-transmission:www-data /home/yunohost.transmission/ -chown -R debian-transmission: /home/yunohost.transmission/{progress,watched} -chmod -R 764 /home/yunohost.transmission -chmod -R 777 /home/yunohost.transmission/watched - -#================================================= -# CONFIGURE TRANSMISSION -#================================================= -ynh_script_progression --message="Configuring Transmission..." --weight=2 +ynh_script_progression --message="Adding a configuration file..." --weight=2 # Transmission has to be stopped before modifying its config ynh_systemd_action --service_name=transmission-daemon --action=stop -# Create a RPC password -rpcpassword=$(ynh_string_random) -ynh_app_setting_set --app=$app --key=rpcpassword --value="$rpcpassword" - -ynh_replace_string --match_string="__RPC_PASSWORD_TO_CHANGE__" --replace_string="$rpcpassword" --target_file=../conf/settings.json if [ "$path_url" != "/" ] then - ynh_replace_string --match_string="__PATH__" --replace_string="$path_url/" --target_file=../conf/settings.json + path_less="$path_url/" else - ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/settings.json + path_less="$path_url" fi -ynh_replace_string --match_string="__PEER_PORT__" --replace_string="$peer_port" --target_file=../conf/settings.json -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=../conf/settings.json -cp ../conf/settings.json /etc/transmission-daemon/settings.json + +ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json" + +chmod 400 "/etc/transmission-daemon/settings.json" +chown debian-transmission:debian-transmission "/etc/transmission-daemon/settings.json" if [ -e /proc/sys/net/core/rmem_max ] then - cp ../conf/90-transmission.conf /etc/sysctl.d/90-transmission.conf - sysctl --load=/etc/sysctl.d/90-transmission.conf -fi + ynh_add_config --template="../conf/90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf" -#================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE -#================================================= + chmod 400 "/etc/sysctl.d/90-transmission.conf" + chown debian-transmission:debian-transmission "/etc/sysctl.d/90-transmission.conf" -ynh_store_file_checksum --file=/etc/transmission-daemon/settings.json -if [ -e /proc/sys/net/core/rmem_max ] -then - ynh_store_file_checksum --file=/etc/sysctl.d/90-transmission.conf + sysctl --load=/etc/sysctl.d/90-transmission.conf fi #================================================= @@ -149,11 +145,11 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=4 ynh_multimedia_build_main_dir # Set rights on transmission directory (parent need to be readable by other, and progress need to be writable by multimedia. Because files will move) -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$datadir" --dest_dir="share/Torrents" # And share completed directory -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/completed" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$datadir/completed" --dest_dir="share/Torrents" # Share also watched directory, to allow to use it easily -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/watched" --dest_dir="share/Torrent to download" +ynh_multimedia_addfolder --source_dir="$datadir/watched" --dest_dir="share/Torrent to download" #================================================= # PATCH SOURCE TO ADD A DOWNLOAD BUTTON @@ -163,21 +159,23 @@ cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/ cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css ynh_replace_string "
" "
" /usr/share/transmission/web/index.html -#================================================= -# START TRANSMISSION -#================================================= -ynh_script_progression --message="Starting Transmission..." - -ynh_systemd_action --service_name=transmission-daemon --action=start - #================================================= # GENERIC FINALISATION #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/syslog" --needs_exposed_ports="$peer_port" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --service_name=transmission-daemon --action="start" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index 3ef5485..58732ea 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -12,36 +12,46 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove a service from the admin panel, added by `yunohost service add` +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if yunohost service status transmission-daemon >/dev/null 2>&1 then - ynh_script_progression --message="Removing $app service..." --weight=8 + ynh_script_progression --message="Removing $app service integration..." --weight=8 yunohost service remove transmission-daemon fi #================================================= -# REMOVE TRANSMISSION-DAEMON +# REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing transmission..." --weight=9 +ynh_script_progression --message="Removing NGINX web server configuration..." +# Remove the dedicated NGINX config +ynh_remove_nginx_config + +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=9 + +# Remove metapackage and its dependencies ynh_remove_app_dependencies #================================================= -# CLOSE THE PORTS +# CLOSE A PORT #================================================= if yunohost firewall list | grep -q "\- $port$" @@ -56,20 +66,12 @@ then ynh_exec_warn_less yunohost firewall disallow Both $peer_port fi -#================================================= -# REMOVE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - -# Remove the dedicated NGINX config -ynh_remove_nginx_config - #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE DATA +# REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing transmission data..." +ynh_script_progression --message="Removing various files..." # Web interface ynh_secure_remove --file=/usr/share/transmission @@ -78,16 +80,16 @@ ynh_secure_remove --file=/var/lib/transmission-daemon # Kernel parameters if [ -e /proc/sys/net/core/rmem_max ] then - ynh_secure_remove --file=/etc/sysctl.d/90-transmission.conf - sysctl --load=/etc/sysctl.d/90-transmission.conf + ynh_secure_remove --file=/etc/sysctl.d/90-transmission.conf + sysctl --load=/etc/sysctl.d/90-transmission.conf fi #================================================= -# GENERIC FINALISATION +# GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user" +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=debian-transmission diff --git a/scripts/restore b/scripts/restore index 17dad2b..91539a8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# 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 @@ -13,13 +14,16 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -27,23 +31,69 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) port=$(ynh_app_setting_get --app=$app --key=port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir/{progress,completed,watched} + +chmod -R 764 $datadir +chmod -R 777 $datadir/watched +chown -R debian-transmission:www-data "$datadir" +chown -R debian-transmission: $datadir/{progress,watched} #================================================= -# STANDARD RESTORE STEPS +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=16 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE 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" +#================================================= +# RESTORE VARIOUS FILES +#================================================= +ynh_script_progression --message="Restoring various files..." --weight=2 + +# Transmission has to be stopped before modifying its config +ynh_systemd_action --service_name=transmission-daemon --action=stop + +ynh_secure_remove --file=/etc/transmission-daemon/settings.json +ynh_restore_file --origin_path=/etc/transmission-daemon/settings.json + +if [ -e /proc/sys/net/core/rmem_max ] +then + ynh_restore_file --origin_path="/etc/sysctl.d/90-transmission.conf" + sysctl --load=/etc/sysctl.d/90-transmission.conf +fi + +ynh_secure_remove --file=/usr/share/transmission +ynh_restore_file --origin_path=/usr/share/transmission + +ynh_secure_remove --file=/var/lib/transmission-daemon +ynh_restore_file --origin_path=/var/lib/transmission-daemon + #================================================= # OPEN PORTS #================================================= @@ -52,57 +102,6 @@ ynh_script_progression --message="Configuring firewall..." --weight=13 ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port ynh_exec_warn_less yunohost firewall allow Both $peer_port -#================================================= -# SPECIFIC RESTORE -#================================================= -# REINSTALL TRANSMISSION -#================================================= -ynh_script_progression --message="Reinstalling Transmission..." --weight=16 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE TRANSMISSION CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring Transmission configuration..." --weight=2 - -# Transmission has to be stopped before modifying its config -ynh_systemd_action --service_name=transmission-daemon --action=stop - -ynh_secure_remove --file=/etc/transmission-daemon/settings.json -ynh_restore_file --origin_path=/etc/transmission-daemon/settings.json - -if [ -e /proc/sys/net/core/rmem_max ] -then - ynh_restore_file --origin_path="/etc/sysctl.d/90-transmission.conf" - sysctl --load=/etc/sysctl.d/90-transmission.conf -fi - -#================================================= -# RESTORE DATA -#================================================= -ynh_script_progression --message="Restoring transmission data..." - -ynh_secure_remove --file=/usr/share/transmission -ynh_restore_file --origin_path=/usr/share/transmission - -ynh_secure_remove --file=/var/lib/transmission-daemon -ynh_restore_file --origin_path=/var/lib/transmission-daemon - -# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. -ynh_restore_file --origin_path="/home/yunohost.transmission" --not_mandatory - -#================================================= -# RESTORE USER RIGHTS -#================================================= - -mkdir -p /home/yunohost.transmission/{progress,completed,watched} -chown -R debian-transmission:www-data /home/yunohost.transmission/ -chown -R debian-transmission: /home/yunohost.transmission/{progress,watched} -chmod -R 640 /home/yunohost.transmission -chmod -R 777 /home/yunohost.transmission/watched - #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= @@ -110,25 +109,26 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=4 ynh_multimedia_build_main_dir # Set rights on transmission directory (parent need to be readable by other, and progress need to be writable by multimedia. Because files will move) -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$datadir" --dest_dir="share/Torrents" # And share completed directory -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/completed" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$datadir/completed" --dest_dir="share/Torrents" # Share also watched directory, to allow to use it easily -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/watched" --dest_dir="share/Torrent to download" +ynh_multimedia_addfolder --source_dir="$datadir/watched" --dest_dir="share/Torrent to download" #================================================= -# START TRANSMISSION -#================================================= -ynh_script_progression --message="Starting transmission..." - -ynh_systemd_action --service_name=transmission-daemon --action=start - -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/syslog" --needs_exposed_ports="$peer_port" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=transmission-daemon --action=start + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6df4f46..89aef56 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -20,13 +20,40 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) port=$(ynh_app_setting_get --app=$app --key=port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) +rpcpassword=$(ynh_app_setting_get --app=$app --key=rpcpassword) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + ynh_clean_check_starting + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=transmission-daemon --action="stop" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -37,6 +64,7 @@ if [ -z "$port" ]; then ynh_app_setting_set --app=$app --key=port --value=$port fi + if [ -z "$peer_port" ]; then peer_port=51413 ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port @@ -45,30 +73,23 @@ fi # Add peer_port also on UDP. ynh_exec_warn_less yunohost firewall allow UDP $peer_port -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 - -# 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 backup_core_only 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 backup_core_only - -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +# If datadir doesn't exist, create it +if [ -z "$datadir" ]; then + datadir=/home/yunohost.app/$app + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + mv /home/yunohost.transmission/progress $datadir/progress + mv /home/yunohost.transmission/completed $datadir/completed + mv /home/yunohost.transmission/watched $datadir/watched + ynh_secure_remove --file="/home/yunohost.transmission/" +fi #================================================= -# STANDARD UPGRADE STEPS +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=7 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # NGINX CONFIGURATION #================================================= @@ -77,74 +98,48 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=7 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # SPECIFIC UPGRADE #================================================= -# CREATE DIRECTORIES +# CREATE DATA DIRECTORY #================================================= +ynh_script_progression --message="Creating a data directory..." -mkdir -p /home/yunohost.transmission/{progress,completed,watched} +mkdir -p $datadir/{progress,completed,watched} + +chmod -R 764 $datadir +chmod -R 777 $datadir/watched +chown -R debian-transmission:www-data "$datadir" +chown -R debian-transmission: $datadir/{progress,watched} #================================================= -# SECURING FILES AND DIRECTORIES +# UPDATE A CONFIG FILE #================================================= - -chown -R debian-transmission:www-data /home/yunohost.transmission/ -chown -R debian-transmission: /home/yunohost.transmission/{progress,watched} -chmod -R 764 /home/yunohost.transmission -chmod -R 777 /home/yunohost.transmission/watched - -#================================================= -# CONFIGURE TRANSMISSION -#================================================= -ynh_script_progression --message="Reconfiguring Transmission..." --weight=2 +ynh_script_progression --message="Updating a configuration file..." --weight=2 # Transmission has to be stopped before modifying its config ynh_systemd_action --service_name=transmission-daemon --action=stop -# Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different --file=/etc/transmission-daemon/settings.json - -# Create a RPC password -rpcpassword=$(ynh_string_random) -ynh_app_setting_set --app=$app --key=rpcpassword --value="$rpcpassword" - -ynh_replace_string --match_string="__RPC_PASSWORD_TO_CHANGE__" --replace_string="$rpcpassword" --target_file=../conf/settings.json if [ "$path_url" != "/" ] then - ynh_replace_string --match_string="__PATH__" --replace_string="$path_url/" --target_file=../conf/settings.json + path_less="$path_url/" else - ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/settings.json + path_less="$path_url" fi -ynh_replace_string --match_string="__PEER_PORT__" --replace_string="$peer_port" --target_file=../conf/settings.json -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=../conf/settings.json -cp ../conf/settings.json /etc/transmission-daemon/settings.json + +ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json" + +chmod 400 "/etc/transmission-daemon/settings.json" +chown debian-transmission:debian-transmission "/etc/transmission-daemon/settings.json" if [ -e /proc/sys/net/core/rmem_max ] then - # Verify the checksum and backup the file if it's different - ynh_backup_if_checksum_is_different --file=/etc/sysctl.d/90-transmission.conf + ynh_add_config --template="../conf/90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf" - cp ../conf/90-transmission.conf /etc/sysctl.d/90-transmission.conf - sysctl --load=/etc/sysctl.d/90-transmission.conf -fi + chmod 400 "/etc/sysctl.d/90-transmission.conf" + chown debian-transmission:debian-transmission "/etc/sysctl.d/90-transmission.conf" -#================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE -#================================================= - -# Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum --file=/etc/transmission-daemon/settings.json -if [ -e /proc/sys/net/core/rmem_max ] -then - ynh_store_file_checksum --file=/etc/sysctl.d/90-transmission.conf + sysctl --load=/etc/sysctl.d/90-transmission.conf fi #================================================= @@ -154,11 +149,11 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=3 ynh_multimedia_build_main_dir # Set rights on transmission directory (parent need to be readable by other, and progress need to be writable by multimedia. Because files will move) -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$datadir" --dest_dir="share/Torrents" # And share completed directory -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/completed" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$datadir/completed" --dest_dir="share/Torrents" # Share also watched directory, to allow to use it easily -ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/watched" --dest_dir="share/Torrent to download" +ynh_multimedia_addfolder --source_dir="$datadir/watched" --dest_dir="share/Torrent to download" #================================================= # PATCH SOURCE TO ADD A DOWNLOAD BUTTON @@ -167,25 +162,26 @@ ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/watched" --de cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css then - cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css + cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css fi ynh_replace_string "
$" "
" /usr/share/transmission/web/index.html #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# GENERIC FINALIZATION #================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/syslog" --needs_exposed_ports="$peer_port" #================================================= -# START TRANSMISSION +# START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting Transmission..." --weight=2 +ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_systemd_action --service_name=transmission-daemon --action=start -#================================================= -# GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= From 3675a3b7afd2bf94ca24463bf6f1600a1e71ccdd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 3 Jul 2022 20:38:46 +0200 Subject: [PATCH 02/10] charset --- doc/DISCLAIMER_fr.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md index a333dd8..6ca4fdc 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/DISCLAIMER_fr.md @@ -1,21 +1,21 @@ -## Caractéristiques spécifiques YunoHost +## Caractéristiques spécifiques YunoHost - * Intégration avec les répertoires Multimédias de YunoHost + * Intégration avec les répertoires Multimédias de YunoHost ## Informations additionnelles -Alternative à WebUI : +Alternative à WebUI : -Vous pouvez utiliser le client de contrôle à distance des différentes plateformes pour gérer votre serveur Transmission : +Vous pouvez utiliser le client de contrôle à distance des différentes plateformes pour gérer votre serveur Transmission : * Bureau : Transmission-remote-GUI : https://github.com/transmission-remote-gui/transgui * Mobile : Transdroid : http://www.transdroid.org/ * Plus de clients ici : https://transmissionbt.com/resources/ -Vous pouvez utiliser les informations suivantes pour vous connecter à votre serveur : +Vous pouvez utiliser les informations suivantes pour vous connecter à votre serveur : -* Hôte distant : Votre domaine ou adresse IP (n'ajoutez pas le répertoire) +* Hôte distant : Votre domaine ou adresse IP (n'ajoutez pas le répertoire) * Port : 443 -* SSL : Activé +* SSL : Activé * Utilisateur : Votre nom d'utilisateur YunoHost -* Mot de passe : Le mot de passe de l'utilisateur YunoHost utilisé -* Répertoire RPC : `/torrent/transmission/rpc` (si vous utilisez le répertoire par défaut) +* Mot de passe : Le mot de passe de l'utilisateur YunoHost utilisé +* Répertoire RPC : `/torrent/transmission/rpc` (si vous utilisez le répertoire par défaut) From a9ba51cfb8de917d53e35e99f9be497905aadcd3 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 3 Jul 2022 18:38:51 +0000 Subject: [PATCH 03/10] Auto-update README --- README.md | 53 ++++++++++++++++++++++++---------------------------- README_fr.md | 50 +++++++++++++++++++++++-------------------------- 2 files changed, 47 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index c506448..07ddb88 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,35 @@ + + # Transmission for YunoHost -[![Integration level](https://dash.yunohost.org/integration/transmission.svg)](https://dash.yunohost.org/appci/app/transmission) ![](https://ci-apps.yunohost.org/ci/badges/transmission.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/transmission.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/transmission.svg)](https://dash.yunohost.org/appci/app/transmission) ![Working status](https://ci-apps.yunohost.org/ci/badges/transmission.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/transmission.maintain.svg) [![Install Transmission with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=transmission) *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Transmission quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install Transmission quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview Transmission is a fast, easy, and free BitTorrent client. -**Shipped version:** 2.94-2 (Debian repository version) + +**Shipped version:** 2.94~ynh1 ## Screenshots -![](transmission.jpg) -## Configuration +![Screenshot of Transmission](./doc/screenshots/transmission.jpg) -## Documentation - - * Official documentation: https://github.com/transmission/transmission/wiki - * YunoHost documentation: https://yunohost.org/en/app_transmission +## Disclaimers / important information ## YunoHost specific features * Integration with YunoHost Multimedia directories -#### Multi-users support - -#### Supported architectures - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/transmission.svg)](https://ci-apps.yunohost.org/ci/apps/transmission/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/transmission.svg)](https://ci-apps-arm.yunohost.org/ci/apps/transmission/) - -## Limitations - ## Additionnal informations Alternative to WebUI : @@ -55,22 +48,24 @@ You can use the following information to connect your server: * Password: Password of the Yunohost User above * RPC Path: /torrent/transmission/rpc (if you used the standard folder) -## Links +## Documentation and resources - * Report a bug: https://github.com/YunoHost-Apps/transmission_ynh/issues - * Transmission website: https://transmissionbt.com/ - * Transmission repository: https://github.com/transmission/transmission - * YunoHost website: https://yunohost.org/ +* Official app website: +* Official admin documentation: +* Upstream app code repository: +* YunoHost documentation for this app: +* Report a bug: ---- +## Developer info -## Developers infos - -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/transmission_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/transmission_ynh/tree/testing). To try the testing branch, please proceed like that. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug or sudo yunohost app upgrade transmission -u https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug ``` + +**More info regarding app packaging:** diff --git a/README_fr.md b/README_fr.md index a1366da..2b7213c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,42 +1,35 @@ + + # Transmission pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/transmission.svg)](https://dash.yunohost.org/appci/app/transmission) ![](https://ci-apps.yunohost.org/ci/badges/transmission.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/transmission.maintain.svg) +[![Niveau d'intégration](https://dash.yunohost.org/integration/transmission.svg)](https://dash.yunohost.org/appci/app/transmission) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/transmission.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/transmission.maintain.svg) [![Installer Transmission avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=transmission) -*[Read this readme in english.](./README.md)* +*[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Transmission rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* +> *Ce package vous permet d'installer Transmission rapidement et simplement sur un serveur YunoHost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* ## Vue d'ensemble Transmission est un client BitTorrent libre, efficace et simple. -**Version incluse :** 2.94-2 (La version du dépôt de Debian) + +**Version incluse :** 2.94~ynh1 ## Captures d'écran -![](transmission.jpg) -## Configuration +![Capture d'écran de Transmission](./doc/screenshots/transmission.jpg) -## Documentation - - * Documentation officielle : https://github.com/transmission/transmission/wiki - * Documentation YunoHost : https://yunohost.org/fr/app_transmission +## Avertissements / informations importantes ## Caractéristiques spécifiques YunoHost * Intégration avec les répertoires Multimédias de YunoHost -#### Support multi-utilisateur - -#### Architectures supportées - -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/transmission.svg)](https://ci-apps.yunohost.org/ci/apps/transmission/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/transmission.svg)](https://ci-apps-arm.yunohost.org/ci/apps/transmission/) - -## Limitations - ## Informations additionnelles Alternative à WebUI : @@ -55,21 +48,24 @@ Vous pouvez utiliser les informations suivantes pour vous connecter à votre ser * Mot de passe : Le mot de passe de l'utilisateur YunoHost utilisé * Répertoire RPC : `/torrent/transmission/rpc` (si vous utilisez le répertoire par défaut) -## Liens - * Signaler un bug : https://github.com/YunoHost-Apps/transmission_ynh/issues - * Site de Transmission : https://transmissionbt.com/ - * Dépôt de Transmission : https://github.com/transmission/transmission - * Site de YunoHost : https://yunohost.org/ +## Documentations et ressources ---- +* Site officiel de l'app : +* Documentation officielle de l'admin : +* Dépôt de code officiel de l'app : +* Documentation YunoHost pour cette app : +* Signaler un bug : ## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/transmission_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. -``` + +``` bash sudo yunohost app install https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug ou sudo yunohost app upgrade transmission -u https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug ``` + +**Plus d'infos sur le packaging d'applications :** From 37355ac1a8d4937a0fb3a462e42623dcb7ed5e23 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 3 Jul 2022 20:39:22 +0200 Subject: [PATCH 04/10] Fix #88 --- conf/nginx.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 3e47350..a559aff 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -20,6 +20,7 @@ location __PATH__/ { location __PATH__/downloads/ { alias __DATADIR__/completed/; + charset UTF-8; autoindex on; autoindex_exact_size off; more_clear_input_headers 'Accept-Encoding'; From 18d6b388e168396386e4388aabf105847d4109d8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 3 Jul 2022 23:39:54 +0200 Subject: [PATCH 05/10] Fix restore --- scripts/restore | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scripts/restore b/scripts/restore index 91539a8..008b603 100644 --- a/scripts/restore +++ b/scripts/restore @@ -39,7 +39,15 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir) ynh_script_progression --message="Validating restoration parameters..." #================================================= -# STANDARD RESTORATION STEPS +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=16 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + #================================================= # RESTORE THE DATA DIRECTORY #================================================= @@ -54,16 +62,6 @@ chmod -R 777 $datadir/watched chown -R debian-transmission:www-data "$datadir" chown -R debian-transmission: $datadir/{progress,watched} -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=16 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= From 119d21842b669b688524bdf50f58d817ffef3fbc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 4 Jul 2022 00:01:30 +0200 Subject: [PATCH 06/10] cleanup --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 89aef56..66c21d1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -62,7 +62,6 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=4 if [ -z "$port" ]; then port=9091 ynh_app_setting_set --app=$app --key=port --value=$port - fi if [ -z "$peer_port" ]; then From 7610c1fbf686529058cf9816021455495dfdc0c6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 4 Jul 2022 00:12:52 +0200 Subject: [PATCH 07/10] Fix upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 66c21d1..1dcb65c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -76,6 +76,7 @@ ynh_exec_warn_less yunohost firewall allow UDP $peer_port if [ -z "$datadir" ]; then datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir + mkdir -p $datadir mv /home/yunohost.transmission/progress $datadir/progress mv /home/yunohost.transmission/completed $datadir/completed mv /home/yunohost.transmission/watched $datadir/watched From e81371587d8ae3f6af0616df1c66e0541a5c058a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 4 Jul 2022 00:15:21 +0200 Subject: [PATCH 08/10] Fix change_url --- scripts/change_url | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 05d0dca..1aae2f6 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,16 +28,20 @@ ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +# Add settings here as needed by your application port=$(ynh_app_setting_get --app=$app --key=port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= -# 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)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" @@ -68,9 +72,9 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping Transmission..." --weight=2 +ynh_script_progression --message="Stopping a systemd service..." --weight=2 -ynh_systemd_action --service_name=transmission-daemon --action=stop +ynh_systemd_action --service_name=transmission-daemon --action="stop" #================================================= # MODIFY URL IN NGINX CONF @@ -118,9 +122,9 @@ ynh_store_file_checksum --file="/etc/transmission-daemon/settings.json" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting transmission..." --weight=2 +ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=transmission-daemon --action=start +ynh_systemd_action --service_name=transmission-daemon --action="start" #================================================= # RELOAD NGINX From 1ce62f48b3f03e96a727847b322df4620e3f379d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 4 Jul 2022 21:59:25 +0200 Subject: [PATCH 09/10] typo --- manifest.json | 4 ++-- scripts/install | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 55cab1e..76d2285 100644 --- a/manifest.json +++ b/manifest.json @@ -36,8 +36,8 @@ { "name": "path", "type": "path", - "example": "/transmission", - "default": "/transmission" + "example": "/torrent", + "default": "/torrent" } ] } diff --git a/scripts/install b/scripts/install index b3ad146..fbdf40a 100644 --- a/scripts/install +++ b/scripts/install @@ -160,7 +160,7 @@ cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/sty ynh_replace_string "
" "
" /usr/share/transmission/web/index.html #================================================= -# GENERIC FINALISATION +# GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= From 4157ad8af89b1f34257edc06adcfcc07809b10da Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 5 Jul 2022 00:29:00 +0200 Subject: [PATCH 10/10] simplification --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 11 +++-------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/scripts/install b/scripts/install index fbdf40a..84b09dd 100644 --- a/scripts/install +++ b/scripts/install @@ -90,7 +90,7 @@ fi #================================================= ynh_script_progression --message="Creating a data directory..." -datadir=/home/yunohost.app/$app +datadir=/home/yunohost.transmission ynh_app_setting_set --app=$app --key=datadir --value=$datadir mkdir -p $datadir/{progress,completed,watched} @@ -166,7 +166,7 @@ ynh_replace_string "