2016-05-17 22:13:59 +02:00
|
|
|
#!/bin/bash
|
2016-05-14 09:56:38 +02:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2016-05-14 09:56:38 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2013-10-29 14:26:46 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path_url=$(ynh_app_setting_get $app path)
|
|
|
|
port=$(ynh_app_setting_get $app port)
|
|
|
|
peer_port=$(ynh_app_setting_get $app peer_port)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# FIX OLD THINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ -z $port ]; then
|
2017-06-15 00:33:49 +02:00
|
|
|
port=9091
|
|
|
|
ynh_app_setting_set $app port $port
|
2017-06-13 23:37:51 +02:00
|
|
|
fi
|
|
|
|
if [ -z $peer_port ]; then
|
2017-06-15 00:33:49 +02:00
|
|
|
peer_port=51413
|
|
|
|
ynh_app_setting_set $app peer_port $peer_port
|
2017-06-13 23:37:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
2016-12-28 16:54:07 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
ynh_app_setting_set $app backup_core_only 1 # Indique au backup/restore de ne pas sauvegarder le dossier de data.
|
|
|
|
BACKUP_BEFORE_UPGRADE # Backup the current version of the app
|
|
|
|
ynh_clean_setup () {
|
|
|
|
BACKUP_FAIL_UPGRADE # restore it if the upgrade fails
|
|
|
|
}
|
|
|
|
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
2013-10-29 14:26:46 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK THE PATH
|
|
|
|
#=================================================
|
2013-10-29 14:26:46 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
2013-10-29 14:51:24 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Add a "/" at the end of path_url for next commands
|
|
|
|
[ "$path_url" = "/" ] || path_url=${path_url}/
|
|
|
|
ynh_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# CREATE DIRECTORIES
|
|
|
|
#=================================================
|
2013-10-29 14:26:46 +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
|
|
|
|
|
|
|
|
# Créé un backup du fichier de config si il a été modifié.
|
|
|
|
ynh_backup_if_checksum_is_different /etc/transmission-daemon/settings.json
|
|
|
|
|
|
|
|
# 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:26:46 +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"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON
|
|
|
|
#=================================================
|
2017-04-01 20:41:34 +02: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
|
|
|
|
if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css
|
|
|
|
then
|
|
|
|
sudo bash -c 'cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css'
|
2016-12-28 16:54:07 +01:00
|
|
|
fi
|
2017-06-13 23:37:51 +02:00
|
|
|
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
|
2016-12-28 16:54:07 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# START TRANSMISSION
|
|
|
|
#=================================================
|
2013-10-29 14:26:46 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
sudo systemctl start transmission-daemon
|
2014-11-11 17:00:05 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
sudo systemctl reload nginx
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVE BACKUP_CORE_ONLY
|
|
|
|
#=================================================
|
2014-11-11 16:55:15 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
ynh_app_setting_delete $app backup_core_only
|