2014-11-11 16:39:27 +01:00
|
|
|
#!/bin/bash
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-05-14 09:56:38 +02:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# MANAGE FAILURE OF THE SCRIPT
|
|
|
|
#=================================================
|
2016-05-14 09:56:38 +02:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2016-12-28 16:54:07 +01:00
|
|
|
|
2016-05-14 09:56:38 +02:00
|
|
|
domain=$YNH_APP_ARG_DOMAIN
|
2017-06-13 23:37:51 +02:00
|
|
|
path_url=$YNH_APP_ARG_PATH
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
|
|
|
CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# STORE SETTINGS FROM MANIFEST
|
|
|
|
#=================================================
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
ynh_app_setting_set $app domain $domain
|
|
|
|
ynh_app_setting_set $app path $path_url
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
# FIND AND OPEN PORTS
|
|
|
|
#=================================================
|
2013-10-29 14:51:24 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
port=$(ynh_find_port 9091) # Cherche un port libre.
|
|
|
|
# Ouvre le port dans le firewall
|
|
|
|
ALL_QUIET sudo yunohost firewall allow --no-upnp TCP $port
|
|
|
|
ynh_app_setting_set $app port $port
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
peer_port=$(ynh_find_port 51413) # Cherche un port libre.
|
|
|
|
# Ouvre le port dans le firewall
|
|
|
|
ALL_QUIET sudo yunohost firewall allow TCP $peer_port
|
|
|
|
ynh_app_setting_set $app peer_port $peer_port
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL TRANSMISSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_package_install transmission-daemon
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Add a "/" at the end of path_url for next commands
|
|
|
|
[ "$path_url" = "/" ] || path_url=${path_url}/
|
|
|
|
ynh_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC SETUP
|
|
|
|
#=================================================
|
|
|
|
# CREATE DIRECTORIES
|
|
|
|
#=================================================
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2016-12-28 17:23:48 +01:00
|
|
|
sudo mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
2017-06-13 23:37:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SECURING FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
2014-12-04 11:48:27 +01:00
|
|
|
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
2017-06-13 23:37:51 +02:00
|
|
|
sudo chown -R debian-transmission: /home/yunohost.transmission/{progress,watched}
|
|
|
|
sudo chmod -R 640 /home/yunohost.transmission
|
|
|
|
sudo chmod -R 777 /home/yunohost.transmission/watched
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURE TRANSMISSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Transmission has to be stopped before modifying its config
|
|
|
|
sudo systemctl stop transmission-daemon
|
|
|
|
|
|
|
|
# Create a RPC password
|
|
|
|
rpcpassword=$(ynh_string_random)
|
|
|
|
ynh_app_setting_set $app rpcpassword "$rpcpassword"
|
|
|
|
|
|
|
|
ynh_replace_string "__RPC_PASSWORD_TO_CHANGE__" "$rpcpassword" ../conf/settings.json
|
|
|
|
ynh_replace_string "__PATH__" "$path_url" ../conf/settings.json
|
|
|
|
ynh_replace_string "__PEER_PORT__" "$peer_port" ../conf/settings.json
|
|
|
|
ynh_replace_string "__PORT__" "$port" ../conf/settings.json
|
|
|
|
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STORE THE CHECKSUM OF THE CONFIG FILE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_store_file_checksum /etc/transmission-daemon/settings.json
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
|
|
|
#=================================================
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2017-04-01 20:41:34 +02:00
|
|
|
wget -qq https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip
|
|
|
|
unzip -qq master.zip
|
|
|
|
sudo ./yunohost.multimedia-master/script/ynh_media_build.sh
|
|
|
|
# Set rights on transmission directory (parent need to be readable by other, and progress need to be writable by multimedia. Because files will move)
|
|
|
|
sudo ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="/home/yunohost.transmission" --dest="share/Torrents"
|
|
|
|
# And share completed directory
|
|
|
|
sudo ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="/home/yunohost.transmission/completed" --dest="share/Torrents"
|
2017-06-13 23:37:51 +02:00
|
|
|
# Share also watched directory, to allow to use it easily
|
|
|
|
sudo ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="/home/yunohost.transmission/watched" --dest="share/Torrent to download"
|
2017-04-01 20:41:34 +02:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON
|
|
|
|
#=================================================
|
2016-12-28 16:54:07 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
sudo cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png
|
|
|
|
sudo bash -c '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
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
# ENABLE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
2013-10-29 14:14:27 +01:00
|
|
|
|
2014-05-18 15:40:05 +02:00
|
|
|
sudo yunohost service add transmission-daemon
|
2013-12-07 10:10:55 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# START TRANSMISSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
sudo systemctl start transmission-daemon
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2014-11-11 16:22:53 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
sudo systemctl reload nginx
|