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 #56 from YunoHost-Apps/package_upgrade

Package upgrade
This commit is contained in:
Kayou 2019-06-01 23:52:02 +02:00 committed by GitHub
commit 5a3f2640de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 495 additions and 230 deletions

View file

@ -1,16 +1,66 @@
Transmission for YunoHost # Transmission app for YunoHost
=========================
[Yunohost project](https://yunohost.org/#/) [![Integration level](https://dash.yunohost.org/integration/transmission.svg)](https://dash.yunohost.org/appci/app/transmission)
[![Install Transmission with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=transmission)
[Transmission](http://www.transmissionbt.com/) is a fast, Free/Libre BitTorrent > *This package allow you to install Transmission quickly and simply on a YunoHost server.
client. This package install the Transmission web server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
[![Install Wallabag v2 with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=transmission) ## Overview
Transmission is a fast, easy, and free BitTorrent client.
Continuous intergation **Shipped version:** Debian repository version.
----------------------
* [Weekly CI report (in french)](https://forum.yunohost.org/t/rapport-hebdomadaire-dintegration-continue/2297) ## Screenshots
* [Last CI build](https://ci-apps.yunohost.org/jenkins/job/transmission%20%28Official%29/lastBuild/consoleFull)
![](https://transmissionbt.com/images/screenshots/Clutch-Large.jpg)
## Demo
* [YunoHost demo](https://demo.yunohost.org/nextcloud/)
## Configuration
## Documentation
* Official documentation: https://github.com/transmission/transmission/wiki
* YunoHost documentation: https://yunohost.org/#/app_transmission
## YunoHost specific features
* Integration with YunoHost Multimedia directories
#### Multi-users support
#### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/transmission%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/transmission/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/transmission%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/transmission/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/transmission%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/transmission/)
## Limitations
## Additionnal informations
```
## Links
* Report a bug: https://github.com/YunoHost-Apps/transmission_ynh/issues
* Transmission website: https://transmissionbt.com/
* Transmission repository: https://github.com/transmission/transmission
* YunoHost website: https://yunohost.org/
---
Developers infos
----------------
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.
```
sudo yunohost app install https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug
or
sudo yunohost app upgrade transmission -u https://github.com/YunoHost-Apps/transmission_ynh/tree/testing --debug
```

View file

@ -8,7 +8,7 @@
setup_sub_dir=1 setup_sub_dir=1
setup_root=1 setup_root=1
setup_nourl=0 setup_nourl=0
setup_private=0 setup_private=1
setup_public=0 setup_public=0
upgrade=1 upgrade=1
upgrade=1 from_commit=7d887f6bc1e29ce94de703517d5302580cbb8a7e upgrade=1 from_commit=7d887f6bc1e29ce94de703517d5302580cbb8a7e
@ -16,20 +16,9 @@
multi_instance=0 multi_instance=0
incorrect_path=1 incorrect_path=1
port_already_use=1 (9091) port_already_use=1 (9091)
change_url=0 change_url=1
;;; Levels ;;; Levels
Level 1=auto Level 5=auto
Level 2=auto
Level 3=auto
# Level 4: No multi-users support
Level 4=na
# Level 5: https://github.com/YunoHost-Apps/transmission_ynh/issues/30
Level 5=1
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options ;;; Options
Email= Email=
Notification=down Notification=down

View file

@ -0,0 +1,5 @@
# These settings affect the size of the buffers for send and receive sockets.
# Size of receive socket buffer
net.core.rmem_max = 4194304
# Size of send socket buffer
net.core.wmem_max = 1048576

View file

@ -1,16 +1,16 @@
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;
# 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'; 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__/;
} }
location __PATH__downloads { location __PATH__/downloads {
alias /home/yunohost.transmission/completed/; alias /home/yunohost.transmission/completed/;
autoindex on; autoindex on;
autoindex_exact_size off; autoindex_exact_size off;

View file

@ -6,15 +6,15 @@
"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", "version": "1.0~ynh2",
"url": "https://www.transmissionbt.com/", "url": "https://www.transmissionbt.com/",
"license": " GPL-3.0", "license": "GPL-3.0",
"maintainer": { "maintainer": {
"name": "YunoHost Contributors", "name": "YunoHost Contributors",
"email": "apps@yunohost.org" "email": "apps@yunohost.org"
}, },
"requirements": { "requirements": {
"yunohost": ">= 2.7.2" "yunohost": ">= 3.5"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [

View file

@ -1,37 +1,62 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
pkg_dependencies="transmission-daemon transmission-cli transmission-common acl"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================
# Install or update the main directory yunohost.multimedia
#
# usage: ynh_multimedia_build_main_dir
ynh_multimedia_build_main_dir () { ynh_multimedia_build_main_dir () {
wget -qq https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip local ynh_media_release="v1.2"
unzip -qq master.zip local checksum="806a827ba1902d6911095602a9221181"
# Download yunohost.multimedia scripts
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz
# 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 ./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 () { ynh_multimedia_addfolder () {
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$1" --dest="$2" # 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
# BACKUP # Manage arguments with getopts
#================================================= ynh_handle_getopts_args "$@"
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
human=$(numfmt --to=iec --from-unit=1K $1)
echo $human
}
CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
file_to_analyse=$1
backup_size=$(du --summarize "$file_to_analyse" | cut -f1)
free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d)
if [ $free_space -le $backup_size ]
then
echo "Espace insuffisant pour sauvegarder $file_to_analyse." >&2
echo "Espace disponible: $(HUMAN_SIZE $free_space)" >&2
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
fi
} }

View file

@ -1,64 +1,61 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Exit on command errors and treat unset variables as an error
set -eu
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers 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 # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
#================================================= #=================================================
# BACKUP OF THE NGINX CONFIGURATION # BACKUP OF THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
# BACKUP TRANSMISSION CONFIGURATION # BACKUP TRANSMISSION CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up transmission configuration..."
ynh_backup "/etc/transmission-daemon/settings.json" ynh_backup --src_path="/etc/transmission-daemon/settings.json"
ynh_backup --src_path="/etc/sysctl.d/90-transmission.conf"
#================================================= #=================================================
# BACKUP DATA # BACKUP DATA
#================================================= #=================================================
ynh_script_progression --message="Backing up transmission data..."
ynh_backup "/usr/share/transmission" ynh_backup --src_path="/usr/share/transmission"
ynh_backup --src_path="/var/lib/transmission-daemon"
ynh_backup "/var/lib/transmission-daemon" ynh_backup --src_path="/home/yunohost.transmission" --is_big
backup_core_only=$(ynh_app_setting_get $app backup_core_only) #=================================================
# If backup_core_only have a value in settings.yml, do not backup the data directory # END OF SCRIPT
if [ -z $backup_core_only ] #=================================================
then
CHECK_SIZE "/home/yunohost.transmission" ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
ynh_backup "/home/yunohost.transmission"
else
echo "Data dir will not saved, because backup_core_only is set." >&2
fi

115
scripts/change_url Normal file
View file

@ -0,0 +1,115 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
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)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# 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
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping transmission..." --weight=2
ynh_systemd_action --service_name=transmission-daemon --action=stop
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
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
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# UPDATE TRANSMISSION CONFIGURATION
#=================================================
ynh_replace_string --match_string="rpc-url\": \"${old_path%/}/transmission/" --replace_string="rpc-url\": \"${new_path%/}/transmission/" --target_file="/etc/transmission-daemon/settings.json"
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting transmission..." --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
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -28,45 +28,47 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..."
# Normalize the url path syntax # Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url) path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set $app domain $domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app path $path_url ynh_app_setting_set --app=$app --key=path --value=$path_url
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN PORTS # FIND AND OPEN PORTS
#================================================= #=================================================
ynh_script_progression --message="Configuring firewall..." --weight=16
# Find a free port # Find a free port
port=$(ynh_find_port 9091) port=$(ynh_find_port --port=9091)
# Open this port # Open this port
yunohost firewall allow --no-upnp TCP $port >/dev/null 2>&1 ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
ynh_app_setting_set $app port $port ynh_app_setting_set --app=$app --key=port --value=$port
# Find a free port # Find a free port
peer_port=$(ynh_find_port 51413) peer_port=$(ynh_find_port --port=51413)
# Open this port # Open this port
yunohost firewall allow Both $peer_port >/dev/null 2>&1 ynh_exec_warn_less yunohost firewall allow Both $peer_port
ynh_app_setting_set $app peer_port $peer_port ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port
#================================================= #=================================================
# INSTALL TRANSMISSION # INSTALL TRANSMISSION
#================================================= #=================================================
ynh_script_progression --message="Installing transmission..." --weight=16
ynh_install_app_dependencies transmission-daemon transmission-cli transmission-common acl ynh_install_app_dependencies $pkg_dependencies
# Fix a stupid issue which happens sometimes ... # Fix a stupid issue which happens sometimes ...
# transmission-common is installed (it's a dependency of # transmission-common is installed (it's a dependency of
@ -82,10 +84,9 @@ fi
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=2
# Add a "/" at the end of path_url for next commands # Create a dedicated nginx config
# To avoid a double / in the nginx config file.
[ "$path_url" = "/" ] || path_url=${path_url}/
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
@ -108,37 +109,50 @@ chmod -R 777 /home/yunohost.transmission/watched
#================================================= #=================================================
# CONFIGURE TRANSMISSION # 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
systemctl stop transmission-daemon ynh_systemd_action --service_name=transmission-daemon --action=stop
# Create a RPC password # Create a RPC password
rpcpassword=$(ynh_string_random) rpcpassword=$(ynh_string_random)
ynh_app_setting_set $app rpcpassword "$rpcpassword" ynh_app_setting_set --app=$app --key=rpcpassword --value="$rpcpassword"
ynh_replace_string "__RPC_PASSWORD_TO_CHANGE__" "$rpcpassword" ../conf/settings.json ynh_replace_string --match_string="__RPC_PASSWORD_TO_CHANGE__" --replace_string="$rpcpassword" --target_file=../conf/settings.json
ynh_replace_string "__PATH__" "$path_url" ../conf/settings.json if [ "$path_url" != "/" ]
ynh_replace_string "__PEER_PORT__" "$peer_port" ../conf/settings.json then
ynh_replace_string "__PORT__" "$port" ../conf/settings.json ynh_replace_string --match_string="__PATH__" --replace_string="$path_url/" --target_file=../conf/settings.json
else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/settings.json
fi
ynh_replace_string --match_string="__PEER_PORT__" --replace_string="$peer_port" --target_file=../conf/settings.json
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=../conf/settings.json
cp ../conf/settings.json /etc/transmission-daemon/settings.json cp ../conf/settings.json /etc/transmission-daemon/settings.json
cp ../conf/90-transmission.conf /etc/sysctl.d/90-transmission.conf
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
sysctl --load=/etc/sysctl.d/90-transmission.conf
fi
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
ynh_store_file_checksum /etc/transmission-daemon/settings.json ynh_store_file_checksum --file=/etc/transmission-daemon/settings.json
ynh_store_file_checksum --file=/etc/sysctl.d/90-transmission.conf
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
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 "/home/yunohost.transmission" "share/Torrents" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission" --dest_dir="share/Torrents"
# And share completed directory # And share completed directory
ynh_multimedia_addfolder "/home/yunohost.transmission/completed" "share/Torrents" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/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 "/home/yunohost.transmission/watched" "share/Torrent to download" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/watched" --dest_dir="share/Torrent to download"
#================================================= #=================================================
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON # PATCH SOURCE TO ADD A DOWNLOAD BUTTON
@ -148,22 +162,30 @@ cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/
cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css
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
#=================================================
ynh_script_progression --message="Starting transmission..."
ynh_systemd_action --service_name=transmission-daemon --action=start
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
# ENABLE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add transmission-daemon --log "/var/log/syslog" yunohost service add transmission-daemon --log "/var/log/syslog"
#=================================================
# START TRANSMISSION
#=================================================
systemctl start transmission-daemon
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -12,28 +12,31 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
peer_port=$(ynh_app_setting_get $app peer_port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# REMOVE TRANSMISSION-DAEMON # REMOVE TRANSMISSION-DAEMON
#================================================= #=================================================
ynh_script_progression --message="Removing transmission..." --weight=9
ynh_remove_app_dependencies ynh_remove_app_dependencies
#================================================= #=================================================
# DISABLE SERVICE IN ADMIN PANEL # REMOVE SERVICE FROM ADMIN PANEL
#================================================= #=================================================
if yunohost service status | grep -q transmission-daemon # Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status transmission-daemon >/dev/null 2>&1
then then
echo "Remove transmission-daemon service" ynh_script_progression --message="Removing $app service..." --weight=8
yunohost service remove transmission-daemon yunohost service remove transmission-daemon
fi fi
@ -43,19 +46,20 @@ fi
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
echo "Close port $port" ynh_script_progression --message="Closing port $port..."
yunohost firewall disallow TCP $port 2>&1 ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
if yunohost firewall list | grep -q "\- $peer_port$" if yunohost firewall list | grep -q "\- $peer_port$"
then then
echo "Close port $peer_port" ynh_script_progression --message="Closing port $peer_port..."
yunohost firewall disallow Both $peer_port 2>&1 ynh_exec_warn_less yunohost firewall disallow Both $peer_port
fi fi
#================================================= #=================================================
# REMOVE THE NGINX CONFIGURATION # REMOVE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -65,27 +69,30 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DATA # REMOVE DATA
#================================================= #=================================================
ynh_script_progression --message="Removing transmission data..."
backup_core_only=$(ynh_app_setting_get $app backup_core_only)
# If backup_core_only have a value in settings.yml, do not remove the data directory
if [ -z $backup_core_only ]
then
ynh_secure_remove /home/yunohost.transmission
fi
# And remove the link in yunohost.multimedia
rm "/home/yunohost.multimedia/share/Torrents"
rm "/home/yunohost.multimedia/share/Torrent to download"
# Web interface # Web interface
ynh_secure_remove /usr/share/transmission ynh_secure_remove --file=/usr/share/transmission
# And data # And data
ynh_secure_remove /var/lib/transmission-daemon ynh_secure_remove --file=/var/lib/transmission-daemon
# Kernel parameters
ynh_secure_remove --file=/etc/sysctl.d/90-transmission.conf
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
sysctl --load=/etc/sysctl.d/90-transmission.conf
fi
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user"
ynh_system_user_delete debian-transmission # Delete a system user
ynh_system_user_delete --username=debian-transmission
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -1,40 +1,37 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# GENERIC STARTING # GENERIC START
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Exit on command errors and treat unset variables as an error
set -eu
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
if [ ! -e _common.sh ]; then source ../settings/scripts/_common.sh
# Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh
chmod a+rx _common.sh
fi
source _common.sh
source /usr/share/yunohost/helpers 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 # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
peer_port=$(ynh_app_setting_get $app peer_port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available $domain $path_url \ ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
@ -42,87 +39,106 @@ ynh_webpath_available $domain $path_url \
#================================================= #=================================================
# STANDARD RESTORE STEPS # STANDARD RESTORE STEPS
#================================================= #=================================================
# RESTORE OF THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# OPEN PORTS # OPEN PORTS
#================================================= #=================================================
ynh_script_progression --message="Configuring firewall..." --weight=13
yunohost firewall allow --no-upnp TCP $port >/dev/null 2>&1 ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
yunohost firewall allow Both $peer_port >/dev/null 2>&1 ynh_exec_warn_less yunohost firewall allow Both $peer_port
#================================================= #=================================================
# SPECIFIC RESTORE # SPECIFIC RESTORE
#================================================= #=================================================
# REINSTALL TRANSMISSION # REINSTALL TRANSMISSION
#================================================= #=================================================
ynh_script_progression --message="Reinstalling transmission..." --weight=16
ynh_install_app_dependencies transmission-daemon transmission-cli transmission-common acl # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE TRANSMISSION CONFIGURATION # RESTORE TRANSMISSION CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring transmission configuration..." --weight=2
# Transmission has to be stopped before modifying its config # Transmission has to be stopped before modifying its config
systemctl stop transmission-daemon ynh_systemd_action --service_name=transmission-daemon --action=stop
ynh_secure_remove /etc/transmission-daemon/settings.json ynh_secure_remove --file=/etc/transmission-daemon/settings.json
ynh_restore_file /etc/transmission-daemon/settings.json ynh_restore_file --origin_path=/etc/transmission-daemon/settings.json
ynh_restore_file --origin_path="/etc/sysctl.d/90-transmission.conf"
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
sysctl --load=/etc/sysctl.d/90-transmission.conf
fi
#================================================= #=================================================
# RESTORE DATA # RESTORE DATA
#================================================= #=================================================
ynh_script_progression --message="Restoring transmission data..."
ynh_secure_remove /usr/share/transmission ynh_secure_remove --file=/usr/share/transmission
ynh_restore_file /usr/share/transmission ynh_restore_file --origin_path=/usr/share/transmission
ynh_secure_remove /var/lib/transmission-daemon ynh_secure_remove --file=/var/lib/transmission-daemon
ynh_restore_file /var/lib/transmission-daemon ynh_restore_file --origin_path=/var/lib/transmission-daemon
# The data directory is restored only if it's in the backup. # 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.
# If the backup have made with backup_core_only option, this directory didn't saved. ynh_restore_file --origin_path="/home/yunohost.transmission" --not_mandatory
if [ -d "${YNH_APP_BACKUP_DIR}/home/yunohost.transmission" ]
then #=================================================
ynh_restore_file "/home/yunohost.transmission" # RESTORE USER RIGHTS
else #=================================================
mkdir -p /home/yunohost.transmission/{progress,completed,watched}
chown -R debian-transmission:www-data /home/yunohost.transmission/ mkdir -p /home/yunohost.transmission/{progress,completed,watched}
chown -R debian-transmission: /home/yunohost.transmission/{progress,watched} chown -R debian-transmission:www-data /home/yunohost.transmission/
chmod -R 640 /home/yunohost.transmission chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
chmod -R 777 /home/yunohost.transmission/watched chmod -R 640 /home/yunohost.transmission
fi chmod -R 777 /home/yunohost.transmission/watched
# Remove the backup_core_only option from the settings.yml
ynh_app_setting_delete $app backup_core_only
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
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 "/home/yunohost.transmission" "share/Torrents" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission" --dest_dir="share/Torrents"
# And share completed directory # And share completed directory
ynh_multimedia_addfolder "/home/yunohost.transmission/completed" "share/Torrents" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/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 "/home/yunohost.transmission/watched" "share/Torrent to download" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/watched" --dest_dir="share/Torrent to download"
#================================================= #=================================================
# ENABLE SERVICE IN ADMIN PANEL # START TRANSMISSION
#=================================================
ynh_script_progression --message="Starting transmission..."
ynh_systemd_action --service_name=transmission-daemon --action=start
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add transmission-daemon --log "/var/log/syslog" yunohost service add transmission-daemon --log "/var/log/syslog"
#================================================= #=================================================
# START TRANSMISSION # GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=2
systemctl start transmission-daemon ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# RELOAD NGINX # END OF SCRIPT
#================================================= #=================================================
systemctl reload nginx ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,65 +12,84 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
peer_port=$(ynh_app_setting_get $app peer_port) peer_port=$(ynh_app_setting_get --app=$app --key=peer_port)
#================================================= #=================================================
# FIX OLD THINGS # CHECK VERSION
#================================================= #=================================================
if [ -z $port ]; then upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=4
if [ -z "$port" ]; then
port=9091 port=9091
ynh_app_setting_set $app port $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 peer_port $peer_port ynh_app_setting_set --app=$app --key=peer_port --value=$peer_port
fi fi
# Add peer_port also on UDP. # Add peer_port also on UDP.
yunohost firewall allow UDP $peer_port >/dev/null 2>&1 ynh_exec_warn_less yunohost firewall allow UDP $peer_port
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
# Inform the backup/restore process that it should not save the data directory # 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 ynh_app_setting_set $app backup_core_only 1
ynh_backup_before_upgrade # Backup the current version of the app
# 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 () { ynh_clean_setup () {
ynh_restore_upgradebackup # restore it if the upgrade fails # restore it if the upgrade fails
ynh_restore_upgradebackup
} }
ynh_abort_if_errors # 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
#================================================= #=================================================
# CHECK THE PATH # CHECK THE PATH
#================================================= #=================================================
# Normalize the URL path syntax # Normalize the URL path syntax
path_url=$(ynh_normalize_url_path $path_url) path_url=$(ynh_normalize_url_path --path_url=$path_url)
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
# Add a "/" at the end of path_url for next commands # Create a dedicated nginx config
# To avoid a double / in the nginx config file.
[ "$path_url" = "/" ] || path_url=${path_url}/
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=7
ynh_install_app_dependencies transmission-daemon transmission-cli transmission-common acl ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -92,41 +111,57 @@ chmod -R 777 /home/yunohost.transmission/watched
#================================================= #=================================================
# CONFIGURE TRANSMISSION # 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
systemctl stop transmission-daemon ynh_systemd_action --service_name=transmission-daemon --action=stop
# Verify the checksum and backup the file if it's different # Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different /etc/transmission-daemon/settings.json ynh_backup_if_checksum_is_different --file=/etc/transmission-daemon/settings.json
# Create a RPC password # Create a RPC password
rpcpassword=$(ynh_string_random) rpcpassword=$(ynh_string_random)
ynh_app_setting_set $app rpcpassword "$rpcpassword" ynh_app_setting_set --app=$app --key=rpcpassword --value="$rpcpassword"
ynh_replace_string "__RPC_PASSWORD_TO_CHANGE__" "$rpcpassword" ../conf/settings.json ynh_replace_string --match_string="__RPC_PASSWORD_TO_CHANGE__" --replace_string="$rpcpassword" --target_file=../conf/settings.json
ynh_replace_string "__PATH__" "$path_url" ../conf/settings.json if [ "$path_url" != "/" ]
ynh_replace_string "__PEER_PORT__" "$peer_port" ../conf/settings.json then
ynh_replace_string "__PORT__" "$port" ../conf/settings.json ynh_replace_string --match_string="__PATH__" --replace_string="$path_url/" --target_file=../conf/settings.json
else
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/settings.json
fi
ynh_replace_string --match_string="__PEER_PORT__" --replace_string="$peer_port" --target_file=../conf/settings.json
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file=../conf/settings.json
cp ../conf/settings.json /etc/transmission-daemon/settings.json cp ../conf/settings.json /etc/transmission-daemon/settings.json
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different --file=/etc/sysctl.d/90-transmission.conf
cp ../conf/90-transmission.conf /etc/sysctl.d/90-transmission.conf
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then
sysctl --load=/etc/sysctl.d/90-transmission.conf
fi
#================================================= #=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE # STORE THE CHECKSUM OF THE CONFIG FILE
#================================================= #=================================================
# Recalculate and store the config file checksum into the app settings # Recalculate and store the config file checksum into the app settings
ynh_store_file_checksum /etc/transmission-daemon/settings.json ynh_store_file_checksum --file=/etc/transmission-daemon/settings.json
ynh_store_file_checksum --file=/etc/sysctl.d/90-transmission.conf
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
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 "/home/yunohost.transmission" "share/Torrents" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission" --dest_dir="share/Torrents"
# And share completed directory # And share completed directory
ynh_multimedia_addfolder "/home/yunohost.transmission/completed" "share/Torrents" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/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 "/home/yunohost.transmission/watched" "share/Torrent to download" ynh_multimedia_addfolder --source_dir="/home/yunohost.transmission/watched" --dest_dir="share/Torrent to download"
#================================================= #=================================================
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON # PATCH SOURCE TO ADD A DOWNLOAD BUTTON
@ -142,17 +177,21 @@ ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></d
#================================================= #=================================================
# START TRANSMISSION # START TRANSMISSION
#================================================= #=================================================
ynh_script_progression --message="Starting transmission..." --weight=2
systemctl start transmission-daemon ynh_systemd_action --service_name=transmission-daemon --action=start
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..."
systemctl reload nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# REMOVE BACKUP_CORE_ONLY # END OF SCRIPT
#================================================= #=================================================
ynh_app_setting_delete $app backup_core_only ynh_script_progression --message="Upgrade of $app completed" --last