diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100644 index 72eb5cb..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/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/README.md b/README.md index 0b94b03..3fe8117 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # Transmission for YunoHost -[![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) +[![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)* @@ -17,37 +18,17 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in Transmission is a fast, easy, and free BitTorrent client. +### YunoHost specific features -**Shipped version:** 3.00~ynh1 + * Integration with YunoHost Multimedia directories + + +**Shipped version:** 3.00~ynh2 ## Screenshots ![Screenshot of Transmission](./doc/screenshots/transmission.jpg) -## Disclaimers / important information - -## 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) - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index b27ac07..e46cd2b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,54 +5,35 @@ It shall NOT be edited by hand. # Transmission pour YunoHost -[![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) +[![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)* -> *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.* +> *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 +## Vue d’ensemble Transmission est un client BitTorrent libre, efficace et simple. - -**Version incluse :** 3.00~ynh1 - -## Captures d'écran - -![Capture d'écran de Transmission](./doc/screenshots/transmission.jpg) - -## Avertissements / informations importantes - -## Caractéristiques spécifiques YunoHost +### 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 : +**Version incluse :** 3.00~ynh2 -* 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/ +## Captures d’écran -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) +![Capture d’écran de Transmission](./doc/screenshots/transmission.jpg) ## Documentations et ressources -* Site officiel de l'app : -* Documentation officielle de l'admin : -* Dépôt de code officiel de l'app : +* 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 : @@ -68,4 +49,4 @@ 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 :** +**Plus d’infos sur le packaging d’applications :** \ No newline at end of file diff --git a/check_process b/check_process deleted file mode 100644 index 7812ab9..0000000 --- a/check_process +++ /dev/null @@ -1,26 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=0 - upgrade=1 - # 2.94~ynh1 - upgrade=1 from_commit=c07a09d875cf11b4e3a3147e9e35ef5e06788cff - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=c07a09d875cf11b4e3a3147e9e35ef5e06788cff - name=2.94~ynh1 - manifest_arg=domain=DOMAIN&path=PATH&is_public=1&language=fr&admin=USER&password=pass&port=666& - diff --git a/conf/nginx.conf b/conf/nginx.conf index a559aff..9b35405 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -19,7 +19,7 @@ location __PATH__/ { } location __PATH__/downloads/ { - alias __DATADIR__/completed/; + alias __DATA_DIR__/completed/; charset UTF-8; autoindex on; autoindex_exact_size off; diff --git a/conf/settings.json b/conf/settings.json index 14d56e6..42d75ef 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -12,7 +12,7 @@ "blocklist-url": "http://www.example.com/blocklist", "cache-size-mb": 4, "dht-enabled": true, - "download-dir": "__DATADIR__/completed", + "download-dir": "__DATA_DIR__/completed", "download-limit": 100, "download-limit-enabled": 0, "download-queue-enabled": true, @@ -20,7 +20,7 @@ "encryption": 1, "idle-seeding-limit": 30, "idle-seeding-limit-enabled": false, - "incomplete-dir": "__DATADIR__/progress", + "incomplete-dir": "__DATA_DIR__/progress", "incomplete-dir-enabled": true, "lpd-enabled": false, "max-peers-global": 200, @@ -29,7 +29,7 @@ "peer-id-ttl-hours": 6, "peer-limit-global": 200, "peer-limit-per-torrent": 50, - "peer-port": __PEER_PORT__, + "peer-port": __PORT_PEER__, "peer-port-random-high": 65535, "peer-port-random-low": 49152, "peer-port-random-on-start": false, @@ -70,6 +70,6 @@ "upload-limit-enabled": 0, "upload-slots-per-torrent": 14, "utp-enabled": true, - "watch-dir": "__DATADIR__/watched", + "watch-dir": "__DATA_DIR__/watched", "watch-dir-enabled": true } diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 88% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md index 749e331..b21226e 100644 --- a/doc/DISCLAIMER.md +++ b/doc/ADMIN.md @@ -1,7 +1,3 @@ -## YunoHost specific features - - * Integration with YunoHost Multimedia directories - ## Additionnal informations Alternative to WebUI : diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 87% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md index 6ca4fdc..cc17a89 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/ADMIN_fr.md @@ -1,7 +1,3 @@ -## Caractéristiques spécifiques YunoHost - - * Intégration avec les répertoires Multimédias de YunoHost - ## Informations additionnelles Alternative à WebUI : diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 9f4e7bf..0b52a3c 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1 +1,5 @@ Transmission is a fast, easy, and free BitTorrent client. + +### YunoHost specific features + + * Integration with YunoHost Multimedia directories diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 8e8a725..6e4877f 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1 +1,5 @@ Transmission est un client BitTorrent libre, efficace et simple. + +### Caractéristiques spécifiques YunoHost + + * Intégration avec les répertoires Multimédias de YunoHost diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 9cc1b18..0000000 --- a/manifest.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "Transmission", - "id": "transmission", - "packaging_format": 1, - "description": { - "en": "Fast, Easy, and Free BitTorrent Client", - "fr": "Client BitTorrent libre et rapide" - }, - "version": "3.00~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", - "cpe": "cpe:2.3:a:transmissionbt:transmission" - }, - "license": "GPL-3.0", - "maintainer": { - "name": "", - "email": "" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": false, - "services": [ - "nginx", - "transmission-daemon" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/torrent", - "default": "/torrent" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..90418fd --- /dev/null +++ b/manifest.toml @@ -0,0 +1,64 @@ +packaging_format = 2 + +id = "transmission" +name = "Transmission" +description.en = "Fast, Easy, and Free BitTorrent Client" +description.fr = "Client BitTorrent libre et rapide" + +version = "3.00~ynh2" + +maintainers = [] + +[upstream] +license = "GPL-3.0" +website = "https://www.transmissionbt.com" +admindoc = "https://github.com/transmission/transmission/wiki" +code = "https://github.com/transmission/transmission" +cpe = "cpe:2.3:a:transmissionbt:transmission" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = false +ldap = false +sso = false +disk = "50M" +ram.build = "200M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/torrent" + + [install.init_main_permission] + type = "group" + default = "visitors" + +[resources] + + [resources.ports] + main.default = 9091 + main.exposed = "TCP" + peer.default = 51413 + peer.exposed = "Both" + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + subdirs = [ "progress", "completed", "watched" ] + + [resources.permissions] + main.url = "/" + rpc.url = "/transmission/rpc" + rpc.allowed = "visitors" + rpc.show_tile = false + rpc.protected = true + + [resources.apt] + packages = "transmission-daemon, transmission-cli, transmission-common, acl" diff --git a/scripts/_common.sh b/scripts/_common.sh index 8d9a9d2..944a65e 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="transmission-daemon transmission-cli transmission-common acl" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index e180328..a42bc4a 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,23 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -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 #================================================= @@ -36,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 1aae2f6..3d49a94 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,64 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -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 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" - - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -81,29 +23,7 @@ ynh_systemd_action --service_name=transmission-daemon --action="stop" #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi +ynh_change_url_nginx_config #================================================= # SPECIFIC MODIFICATIONS @@ -126,13 +46,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_systemd_action --service_name=transmission-daemon --action="start" -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 84b09dd..b1fab27 100644 --- a/scripts/install +++ b/scripts/install @@ -9,80 +9,13 @@ source _common.sh 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 - #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH - -app=$YNH_APP_INSTANCE_NAME - rpcpassword=$(ynh_string_random) - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -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 A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=16 - -# Find an available port -port=$(ynh_find_port --port=9091) -ynh_app_setting_set --app=$app --key=port --value=$port -peer_port=$(ynh_find_port --port=51413) -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 DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=16 - -ynh_install_app_dependencies $pkg_dependencies - -# Fix a stupid issue which happens sometimes ... -# transmission-common is installed (it's a dependency of -# transmission-daemon) but somehow the files it's supposed -# to add ain't there ... and possibly also the transmission user -# is missing. -# Explicitly reinstalling the packages fixes the issue :| -if [ ! -d /usr/share/transmission/ ] -then - ynh_install_app_dependencies $pkg_dependencies --reinstall -fi - #================================================= # SPECIFIC SETUP #================================================= @@ -90,15 +23,10 @@ fi #================================================= ynh_script_progression --message="Creating a data directory..." -datadir=/home/yunohost.transmission -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} +chmod -R 764 $data_dir +chmod -R 775 $data_dir/watched +chown -R debian-transmission:www-data "$data_dir" +chown -R debian-transmission: $data_dir/{progress,watched} #================================================= # NGINX CONFIGURATION @@ -116,11 +44,11 @@ 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 -if [ "$path_url" != "/" ] +if [ "$path" != "/" ] then - path_less="$path_url/" + path_less="$path/" else - path_less="$path_url" + path_less="$path" fi ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json" @@ -144,12 +72,15 @@ fi 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="$datadir" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$data_dir" --dest_dir="share/Torrents" + # And share completed directory -ynh_multimedia_addfolder --source_dir="$datadir/completed" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$data_dir/completed" --dest_dir="share/Torrents" + # Share also watched directory, to allow to use it easily -ynh_multimedia_addfolder --source_dir="$datadir/watched" --dest_dir="share/Torrent to download" +ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torrent to download" #================================================= # PATCH SOURCE TO ADD A DOWNLOAD BUTTON @@ -166,7 +97,7 @@ ynh_replace_string "
/dev/null 2>&1 @@ -34,49 +23,15 @@ then yunohost service remove transmission-daemon fi -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -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 A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - -if yunohost firewall list | grep -q "\- $peer_port$" -then - ynh_script_progression --message="Closing port $peer_port..." - ynh_exec_warn_less yunohost firewall disallow Both $peer_port -fi - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - # Web interface ynh_secure_remove --file=/usr/share/transmission + # And data ynh_secure_remove --file=/var/lib/transmission-daemon + # Kernel parameters if [ -e /proc/sys/net/core/rmem_max ] then @@ -84,16 +39,6 @@ then sysctl --load=/etc/sysctl.d/90-transmission.conf fi -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -ynh_system_user_delete --username=debian-transmission - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 256544f..9c46675 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,57 +10,17 @@ source ../settings/scripts/_common.sh 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 installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -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..." - -#================================================= -# 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 #================================================= ynh_script_progression --message="Restoring the data directory..." -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --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} +chmod -R 764 $data_dir +chmod -R 775 $data_dir/watched +chown -R debian-transmission:www-data "$data_dir" +chown -R debian-transmission: $data_dir/{progress,watched} #================================================= # RESTORE THE NGINX CONFIGURATION @@ -92,33 +52,28 @@ 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 -#================================================= -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 - #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= 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="$datadir" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$data_dir" --dest_dir="share/Torrents" + # And share completed directory -ynh_multimedia_addfolder --source_dir="$datadir/completed" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$data_dir/completed" --dest_dir="share/Torrents" + # Share also watched directory, to allow to use it easily -ynh_multimedia_addfolder --source_dir="$datadir/watched" --dest_dir="share/Torrent to download" +ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torrent to download" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add transmission-daemon --description="BitTorrent Client" --log=systemd --needs_exposed_ports="$peer_port" +yunohost service add transmission-daemon --description="BitTorrent Client" --log=systemd --needs_exposed_ports="$port_peer" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index c388f8f..7ae5caa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,41 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 - -app=$YNH_APP_INSTANCE_NAME - -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 #================================================= 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 #================================================= @@ -53,37 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=transmission-daemon --action="stop" -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -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 - peer_port=51413 - ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port -fi - -# Add peer_port also on UDP. -ynh_exec_warn_less yunohost firewall allow UDP $peer_port - -# If datadir doesn't exist, create it -if [ -z "$datadir" ]; then - datadir=/home/yunohost.transmission - ynh_app_setting_set --app=$app --key=datadir --value=$datadir -fi - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=7 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -99,12 +39,10 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." -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} +chmod -R 764 $data_dir +chmod -R 775 $data_dir/watched +chown -R debian-transmission:www-data "$data_dir" +chown -R debian-transmission: $data_dir/{progress,watched} #================================================= # UPDATE A CONFIG FILE @@ -114,14 +52,14 @@ 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 -if [ "$path_url" != "/" ] +if [ "$path" != "/" ] then - path_less="$path_url/" + path_less="$path/" else - path_less="$path_url" + path_less="$path" fi -ynh_add_config --template="../conf/settings.json" --destination="/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" @@ -141,13 +79,21 @@ fi #================================================= ynh_script_progression --message="Adding multimedia directories..." --weight=3 +# Remove possibly dangling symlinks created before the /home/yunohost.transmission -> /home/yunohost.app/transmission transition +# Use rm because ynh_secure_remove fails on dangling symlinks, see https://github.com/YunoHost/issues/issues/2253... +rm "$MEDIA_DIRECTORY/share/Torrents" +rm "$MEDIA_DIRECTORY/share/Torrent to download" + 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="$datadir" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$data_dir" --dest_dir="share/Torrents" + # And share completed directory -ynh_multimedia_addfolder --source_dir="$datadir/completed" --dest_dir="share/Torrents" +ynh_multimedia_addfolder --source_dir="$data_dir/completed" --dest_dir="share/Torrents" + # Share also watched directory, to allow to use it easily -ynh_multimedia_addfolder --source_dir="$datadir/watched" --dest_dir="share/Torrent to download" +ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torrent to download" #================================================= # PATCH SOURCE TO ADD A DOWNLOAD BUTTON @@ -158,6 +104,7 @@ if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/ then 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 #================================================= @@ -167,7 +114,7 @@ ynh_replace_string "