1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/transmission_ynh.git synced 2024-09-04 01:46:12 +02:00

Merge pull request #92 from YunoHost-Apps/upgrade

Apply example_ynh
This commit is contained in:
yalh76 2022-07-05 02:38:52 +02:00 committed by GitHub
commit e13c293a7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 612 additions and 472 deletions

137
.github/workflows/updater.sh vendored Normal file
View file

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

View file

@ -1,42 +1,35 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Transmission for YunoHost # 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) [![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)* *[Lire ce readme en français.](./README_fr.md)*
> *This package allow you to install Transmission quickly and simply on a YunoHost server. > *This package allows 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.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview ## Overview
Transmission is a fast, easy, and free BitTorrent client. Transmission is a fast, easy, and free BitTorrent client.
**Shipped version:** 2.94-2 (Debian repository version)
**Shipped version:** 2.94~ynh1
## Screenshots ## Screenshots
![](transmission.jpg)
## Configuration ![Screenshot of Transmission](./doc/screenshots/transmission.jpg)
## Documentation ## Disclaimers / important information
* Official documentation: https://github.com/transmission/transmission/wiki
* YunoHost documentation: https://yunohost.org/en/app_transmission
## YunoHost specific features ## YunoHost specific features
* Integration with YunoHost Multimedia directories * 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 ## Additionnal informations
Alternative to WebUI : Alternative to WebUI :
@ -55,22 +48,24 @@ You can use the following information to connect your server:
* Password: Password of the Yunohost User above * Password: Password of the Yunohost User above
* RPC Path: /torrent/transmission/rpc (if you used the standard folder) * 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 * Official app website: <https://www.transmissionbt.com>
* Transmission website: https://transmissionbt.com/ * Official admin documentation: <https://github.com/transmission/transmission/wiki>
* Transmission repository: https://github.com/transmission/transmission * Upstream app code repository: <https://github.com/transmission/transmission>
* YunoHost website: https://yunohost.org/ * YunoHost documentation for this app: <https://yunohost.org/app_transmission>
* Report a bug: <https://github.com/YunoHost-Apps/transmission_ynh/issues>
--- ## Developer info
## Developers infos Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/transmission_ynh/tree/testing).
Please do 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. To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug
or or
sudo yunohost app upgrade transmission -u https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug sudo yunohost app upgrade transmission -u https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,42 +1,35 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Transmission pour YunoHost # 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) [![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. > *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.* 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. 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 ## Captures d'écran
![](transmission.jpg)
## Configuration ![Capture d'écran de Transmission](./doc/screenshots/transmission.jpg)
## Documentation ## Avertissements / informations importantes
* Documentation officielle : https://github.com/transmission/transmission/wiki
* Documentation YunoHost : https://yunohost.org/fr/app_transmission
## 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
#### 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 ## Informations additionnelles
Alternative à WebUI : 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é * 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) * Répertoire RPC : `/torrent/transmission/rpc` (si vous utilisez le répertoire par défaut)
## Liens ## Documentations et ressources
* 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/
--- * Site officiel de l'app : <https://www.transmissionbt.com>
* Documentation officielle de l'admin : <https://github.com/transmission/transmission/wiki>
* Dépôt de code officiel de l'app : <https://github.com/transmission/transmission>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_transmission>
* Signaler un bug : <https://github.com/YunoHost-Apps/transmission_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/transmission_ynh/tree/testing). 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. Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade transmission -u https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug sudo yunohost app upgrade transmission -u https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug
``` ```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -1,8 +1,7 @@
;; Test complet ;; Test complet
auto_remove=1
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
path="/path" (PATH) path="/path"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=1
@ -11,14 +10,14 @@
setup_private=1 setup_private=1
setup_public=0 setup_public=0
upgrade=1 upgrade=1
# 1.0
upgrade=1 from_commit=7d887f6bc1e29ce94de703517d5302580cbb8a7e upgrade=1 from_commit=7d887f6bc1e29ce94de703517d5302580cbb8a7e
# 1.0~ynh4
upgrade=1 from_commit=c65b76e919089f3f88d2522cef2300db6f78201f
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0
change_url=1 change_url=1
;;; Options ;;; Options
Email= Email=
Notification=down Notification=none
;;; Upgrade options
; commit=7d887f6bc1e29ce94de703517d5302580cbb8a7e
name= Add acl dependency. Mar 3, 2018
manifest_arg=domain=DOMAIN&path=PATH&

View file

@ -1,23 +1,30 @@
location __PATH__/transmission { 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 SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
more_clear_input_headers 'Accept-Encoding';
} }
location __PATH__/ { 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/ { location __PATH__/downloads/ {
alias /home/yunohost.transmission/completed/; alias __DATADIR__/completed/;
autoindex on; charset UTF-8;
autoindex_exact_size off; autoindex on;
autoindex_exact_size off;
more_clear_input_headers 'Accept-Encoding';
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
more_clear_input_headers 'Accept-Encoding';
} }

View file

@ -1,75 +1,75 @@
{ {
"alt-speed-down": 50, "alt-speed-down": 50,
"alt-speed-enabled": false, "alt-speed-enabled": false,
"alt-speed-time-begin": 540, "alt-speed-time-begin": 540,
"alt-speed-time-day": 127, "alt-speed-time-day": 127,
"alt-speed-time-enabled": false, "alt-speed-time-enabled": false,
"alt-speed-time-end": 1020, "alt-speed-time-end": 1020,
"alt-speed-up": 50, "alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0", "bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::", "bind-address-ipv6": "::",
"blocklist-enabled": false, "blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist", "blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4, "cache-size-mb": 4,
"dht-enabled": true, "dht-enabled": true,
"download-dir": "/home/yunohost.transmission/completed", "download-dir": "__DATADIR__/completed",
"download-limit": 100, "download-limit": 100,
"download-limit-enabled": 0, "download-limit-enabled": 0,
"download-queue-enabled": true, "download-queue-enabled": true,
"download-queue-size": 5, "download-queue-size": 5,
"encryption": 1, "encryption": 1,
"idle-seeding-limit": 30, "idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false, "idle-seeding-limit-enabled": false,
"incomplete-dir": "/home/yunohost.transmission/progress", "incomplete-dir": "__DATADIR__/progress",
"incomplete-dir-enabled": true, "incomplete-dir-enabled": true,
"lpd-enabled": false, "lpd-enabled": false,
"max-peers-global": 200, "max-peers-global": 200,
"message-level": 1, "message-level": 1,
"peer-congestion-algorithm": "", "peer-congestion-algorithm": "",
"peer-id-ttl-hours": 6, "peer-id-ttl-hours": 6,
"peer-limit-global": 200, "peer-limit-global": 200,
"peer-limit-per-torrent": 50, "peer-limit-per-torrent": 50,
"peer-port": __PEER_PORT__, "peer-port": __PEER_PORT__,
"peer-port-random-high": 65535, "peer-port-random-high": 65535,
"peer-port-random-low": 49152, "peer-port-random-low": 49152,
"peer-port-random-on-start": false, "peer-port-random-on-start": false,
"peer-socket-tos": "default", "peer-socket-tos": "default",
"pex-enabled": true, "pex-enabled": true,
"port-forwarding-enabled": false, "port-forwarding-enabled": false,
"preallocation": 1, "preallocation": 1,
"prefetch-enabled": 1, "prefetch-enabled": true,
"queue-stalled-enabled": true, "queue-stalled-enabled": true,
"queue-stalled-minutes": 30, "queue-stalled-minutes": 30,
"ratio-limit": 2, "ratio-limit": 2,
"ratio-limit-enabled": false, "ratio-limit-enabled": false,
"rename-partial-files": true, "rename-partial-files": true,
"rpc-authentication-required": false, "rpc-authentication-required": false,
"rpc-bind-address": "127.0.0.1", "rpc-bind-address": "127.0.0.1",
"rpc-enabled": true, "rpc-enabled": true,
"rpc-host-whitelist": "", "rpc-host-whitelist": "",
"rpc-host-whitelist-enabled": false, "rpc-host-whitelist-enabled": false,
"rpc-password": "__RPC_PASSWORD_TO_CHANGE__", "rpc-password": "__RPCPASSWORD__",
"rpc-port": __PORT__, "rpc-port": __PORT__,
"rpc-url": "__PATH__transmission/", "rpc-url": "__PATH_LESS__transmission/",
"rpc-username": "transmission", "rpc-username": "transmission",
"rpc-whitelist": "127.0.0.1", "rpc-whitelist": "127.0.0.1",
"rpc-whitelist-enabled": false, "rpc-whitelist-enabled": false,
"scrape-paused-torrents-enabled": true, "scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false, "script-torrent-done-enabled": false,
"script-torrent-done-filename": "", "script-torrent-done-filename": "",
"seed-queue-enabled": false, "seed-queue-enabled": false,
"seed-queue-size": 10, "seed-queue-size": 10,
"speed-limit-down": 100, "speed-limit-down": 100,
"speed-limit-down-enabled": false, "speed-limit-down-enabled": false,
"speed-limit-up": 100, "speed-limit-up": 100,
"speed-limit-up-enabled": false, "speed-limit-up-enabled": false,
"start-added-torrents": true, "start-added-torrents": true,
"trash-original-torrent-files": false, "trash-original-torrent-files": false,
"umask": 18, "umask": 18,
"upload-limit": 100, "upload-limit": 100,
"upload-limit-enabled": 0, "upload-limit-enabled": 0,
"upload-slots-per-torrent": 14, "upload-slots-per-torrent": 14,
"utp-enabled": true, "utp-enabled": true,
"watch-dir": "/home/yunohost.transmission/watched", "watch-dir": "__DATADIR__/watched",
"watch-dir-enabled": true "watch-dir-enabled": true
} }

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Transmission is a fast, easy, and free BitTorrent client.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Transmission est un client BitTorrent libre, efficace et simple.

21
doc/DISCLAIMER.md Normal file
View file

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

21
doc/DISCLAIMER_fr.md Normal file
View file

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

0
doc/screenshots/.gitkeep Normal file
View file

View file

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View file

@ -1,39 +1,44 @@
{ {
"name": "Transmission", "name": "Transmission",
"id": "transmission", "id": "transmission",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "A Fast, Easy, and Free BitTorrent Client", "en": "A Fast, Easy, and Free BitTorrent Client",
"fr": "Un client BitTorrent libre et rapide" "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"
}, },
"multi_instance": false, "version": "2.94~ynh1",
"services": [ "url": "https://www.transmissionbt.com",
"nginx", "upstream": {
"transmission-daemon" "license": "GPL-3.0",
], "website": "https://www.transmissionbt.com",
"arguments": { "admindoc": "https://github.com/transmission/transmission/wiki",
"install": [ "code": "https://github.com/transmission/transmission"
{ },
"name": "domain", "license": "GPL-3.0",
"type": "domain", "maintainer": {
"example": "domain.org" "name": "",
}, "email": ""
{ },
"name": "path", "requirements": {
"type": "path", "yunohost": ">= 4.3.0"
"example": "/transmission", },
"default": "/transmission" "multi_instance": false,
} "services": [
] "nginx",
} "transmission-daemon"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/torrent",
"default": "/torrent"
}
]
}
} }

View file

@ -18,45 +18,3 @@ pkg_dependencies="transmission-daemon transmission-cli transmission-common acl"
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # 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"
}

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -24,6 +25,7 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) 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 # 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..." 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" 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 # SPECIFIC BACKUP
#================================================= #=================================================
# BACKUP TRANSMISSION CONFIGURATION # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="/etc/transmission-daemon/settings.json" ynh_backup --src_path="/etc/transmission-daemon/settings.json"
if [ -e /proc/sys/net/core/rmem_max ] if [ -e /proc/sys/net/core/rmem_max ]
then then
ynh_backup --src_path="/etc/sysctl.d/90-transmission.conf" ynh_backup --src_path="/etc/sysctl.d/90-transmission.conf"
fi fi
#=================================================
# BACKUP DATA
#=================================================
ynh_backup --src_path="/usr/share/transmission" ynh_backup --src_path="/usr/share/transmission"
ynh_backup --src_path="/var/lib/transmission-daemon" ynh_backup --src_path="/var/lib/transmission-daemon"
ynh_backup --src_path="/home/yunohost.transmission" --is_big
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -28,16 +28,20 @@ ynh_script_progression --message="Loading installation settings..."
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) 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) 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 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 # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { 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. # 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" ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
@ -68,9 +72,9 @@ fi
#================================================= #=================================================
# STOP SYSTEMD SERVICE # 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 # MODIFY URL IN NGINX CONF
@ -107,16 +111,20 @@ fi
# UPDATE TRANSMISSION CONFIGURATION # 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_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 # GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE # 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 # RELOAD NGINX

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,9 +10,12 @@ source _common.sh
source /usr/share/yunohost/helpers 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 # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -25,8 +28,10 @@ path_url=$YNH_APP_ARG_PATH
app=$YNH_APP_INSTANCE_NAME 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..." 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=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=rpcpassword --value="$rpcpassword"
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN PORTS # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." --weight=16 ynh_script_progression --message="Finding an available port..." --weight=16
# Find a free port # Find an available port
port=$(ynh_find_port --port=9091) 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 ynh_app_setting_set --app=$app --key=port --value=$port
# Find a free port
peer_port=$(ynh_find_port --port=51413) 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 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 ynh_install_app_dependencies $pkg_dependencies
@ -78,6 +83,23 @@ then
ynh_install_app_dependencies $pkg_dependencies --reinstall ynh_install_app_dependencies $pkg_dependencies --reinstall
fi fi
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DATA DIRECTORY
#=================================================
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}
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -87,59 +109,33 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# SPECIFIC SETUP # ADD A CONFIGURATION
#================================================= #=================================================
# CREATE DIRECTORIES ynh_script_progression --message="Adding a configuration file..." --weight=2
#=================================================
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
# Transmission has to be stopped before modifying its config # Transmission has to be stopped before modifying its config
ynh_systemd_action --service_name=transmission-daemon --action=stop 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" != "/" ] if [ "$path_url" != "/" ]
then then
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url/" --target_file=../conf/settings.json path_less="$path_url/"
else else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/settings.json path_less="$path_url"
fi 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 ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json"
cp ../conf/settings.json /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 ] if [ -e /proc/sys/net/core/rmem_max ]
then then
cp ../conf/90-transmission.conf /etc/sysctl.d/90-transmission.conf ynh_add_config --template="../conf/90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf"
sysctl --load=/etc/sysctl.d/90-transmission.conf
fi
#================================================= chmod 400 "/etc/sysctl.d/90-transmission.conf"
# STORE THE CHECKSUM OF THE CONFIG FILE chown debian-transmission:debian-transmission "/etc/sysctl.d/90-transmission.conf"
#=================================================
ynh_store_file_checksum --file=/etc/transmission-daemon/settings.json sysctl --load=/etc/sysctl.d/90-transmission.conf
if [ -e /proc/sys/net/core/rmem_max ]
then
ynh_store_file_checksum --file=/etc/sysctl.d/90-transmission.conf
fi fi
#================================================= #=================================================
@ -149,11 +145,11 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=4
ynh_multimedia_build_main_dir 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) # 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 # 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 # 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 # PATCH SOURCE TO ADD A DOWNLOAD BUTTON
@ -164,19 +160,21 @@ cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/sty
ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html
#================================================= #=================================================
# START TRANSMISSION # GENERIC FINALIZATION
#================================================= #=================================================
ynh_script_progression --message="Starting Transmission..." # INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_systemd_action --service_name=transmission-daemon --action=start yunohost service add transmission-daemon --description="BitTorrent Client" --log=systemd --needs_exposed_ports="$peer_port"
#================================================= #=================================================
# GENERIC FINALISATION # START SYSTEMD SERVICE
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..."
yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/syslog" --needs_exposed_ports="$peer_port" # Start a systemd service
ynh_systemd_action --service_name=transmission-daemon --action="start"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -12,36 +12,46 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
peer_port=$(ynh_app_setting_get --app=$app --key=peer_port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port)
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# STANDARD REMOVE # 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 if yunohost service status transmission-daemon >/dev/null 2>&1
then 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 yunohost service remove transmission-daemon
fi 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 ynh_remove_app_dependencies
#================================================= #=================================================
# CLOSE THE PORTS # CLOSE A PORT
#================================================= #=================================================
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
@ -56,20 +66,12 @@ then
ynh_exec_warn_less yunohost firewall disallow Both $peer_port ynh_exec_warn_less yunohost firewall disallow Both $peer_port
fi 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 # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE DATA # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing transmission data..." ynh_script_progression --message="Removing various files..."
# Web interface # Web interface
ynh_secure_remove --file=/usr/share/transmission ynh_secure_remove --file=/usr/share/transmission
@ -78,16 +80,16 @@ ynh_secure_remove --file=/var/lib/transmission-daemon
# Kernel parameters # Kernel parameters
if [ -e /proc/sys/net/core/rmem_max ] if [ -e /proc/sys/net/core/rmem_max ]
then then
ynh_secure_remove --file=/etc/sysctl.d/90-transmission.conf ynh_secure_remove --file=/etc/sysctl.d/90-transmission.conf
sysctl --load=/etc/sysctl.d/90-transmission.conf sysctl --load=/etc/sysctl.d/90-transmission.conf
fi fi
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALIZATION
#================================================= #=================================================
# REMOVE DEDICATED USER # 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 # Delete a system user
ynh_system_user_delete --username=debian-transmission ynh_system_user_delete --username=debian-transmission

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # 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 ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,13 +14,16 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -27,23 +31,67 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
peer_port=$(ynh_app_setting_get --app=$app --key=peer_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 # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available $domain $path_url \ #=================================================
|| ynh_die "Path not available: ${domain}${path_url}" # SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=16
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# STANDARD RESTORE 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}
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # 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" 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 # OPEN PORTS
#================================================= #=================================================
@ -52,57 +100,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 --no-upnp TCP $port
ynh_exec_warn_less yunohost firewall allow Both $peer_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 # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
@ -110,25 +107,26 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=4
ynh_multimedia_build_main_dir 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) # 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 # 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 # 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 # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Starting transmission..." ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add transmission-daemon --description="BitTorrent Client" --log=systemd --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 ynh_systemd_action --service_name=transmission-daemon --action=start
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/syslog" --needs_exposed_ports="$peer_port"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # 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) path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
peer_port=$(ynh_app_setting_get --app=$app --key=peer_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 # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) 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 # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
@ -35,8 +62,8 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=4
if [ -z "$port" ]; then if [ -z "$port" ]; then
port=9091 port=9091
ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=port --value=$port
fi fi
if [ -z "$peer_port" ]; then if [ -z "$peer_port" ]; then
peer_port=51413 peer_port=51413
ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port
@ -45,30 +72,19 @@ fi
# Add peer_port also on UDP. # Add peer_port also on UDP.
ynh_exec_warn_less yunohost firewall allow UDP $peer_port ynh_exec_warn_less yunohost firewall allow UDP $peer_port
#================================================= # If datadir doesn't exist, create it
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP if [ -z "$datadir" ]; then
#================================================= datadir=/home/yunohost.transmission
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3 ynh_app_setting_set --app=$app --key=datadir --value=$datadir
fi
# 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
#================================================= #=================================================
# STANDARD UPGRADE STEPS # UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=7
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -77,74 +93,48 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=7
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # 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
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2
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
# Transmission has to be stopped before modifying its config # Transmission has to be stopped before modifying its config
ynh_systemd_action --service_name=transmission-daemon --action=stop 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" != "/" ] if [ "$path_url" != "/" ]
then then
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url/" --target_file=../conf/settings.json path_less="$path_url/"
else else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/settings.json path_less="$path_url"
fi 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 ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json"
cp ../conf/settings.json /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 ] if [ -e /proc/sys/net/core/rmem_max ]
then then
# Verify the checksum and backup the file if it's different ynh_add_config --template="../conf/90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf"
ynh_backup_if_checksum_is_different --file=/etc/sysctl.d/90-transmission.conf
cp ../conf/90-transmission.conf /etc/sysctl.d/90-transmission.conf chmod 400 "/etc/sysctl.d/90-transmission.conf"
sysctl --load=/etc/sysctl.d/90-transmission.conf chown debian-transmission:debian-transmission "/etc/sysctl.d/90-transmission.conf"
fi
#================================================= sysctl --load=/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
fi fi
#================================================= #=================================================
@ -154,11 +144,11 @@ ynh_script_progression --message="Adding multimedia directories..." --weight=3
ynh_multimedia_build_main_dir 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) # 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 # 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 # 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 # PATCH SOURCE TO ADD A DOWNLOAD BUTTON
@ -167,25 +157,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 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 if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css
then 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 fi
ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>$" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>$" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /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" yunohost service add transmission-daemon --description="BitTorrent Client" --log=systemd --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 ynh_systemd_action --service_name=transmission-daemon --action="start"
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================