mirror of
https://github.com/YunoHost-Apps/transmission_ynh.git
synced 2024-09-04 01:46:12 +02:00
Merge pull request #23 from scith/master
Add support for RPC password and watchdir
This commit is contained in:
commit
86d8f5700c
4 changed files with 62 additions and 12 deletions
|
@ -45,7 +45,7 @@
|
||||||
"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-password": "{22ef1abe361f619946cf9ce68c442d27f73512d5lL3qJ6bY",
|
"rpc-password": "RPCPASSWORDTOCHANGE",
|
||||||
"rpc-port": 9091,
|
"rpc-port": 9091,
|
||||||
"rpc-url": "PATHTOCHANGE/transmission/",
|
"rpc-url": "PATHTOCHANGE/transmission/",
|
||||||
"rpc-username": "transmission",
|
"rpc-username": "transmission",
|
||||||
|
@ -66,5 +66,7 @@
|
||||||
"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-enabled": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ set -eu
|
||||||
# Get app instance name
|
# Get app instance name
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path=$YNH_APP_ARG_PATH
|
path=$YNH_APP_ARG_PATH
|
||||||
|
@ -35,16 +38,33 @@ sudo yunohost firewall allow TCP 51413 > /dev/null 2>&1
|
||||||
sudo apt-get install transmission-daemon -y -qq
|
sudo apt-get install transmission-daemon -y -qq
|
||||||
|
|
||||||
# Make directories and set rights
|
# Make directories and set rights
|
||||||
sudo mkdir -p /home/yunohost.transmission/{progress,completed}
|
sudo mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
||||||
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
||||||
sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmission/progress
|
sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmission/progress /home/yunohost.transmission/watched
|
||||||
sudo find /home/yunohost.transmission/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
sudo find /home/yunohost.transmission/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
||||||
sudo find /home/yunohost.transmission/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
sudo find /home/yunohost.transmission/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
||||||
|
sudo find /home/yunohost.transmission/watched -type d | while read LINE; do sudo chmod 770 "$LINE" ; done
|
||||||
|
ynh_app_setting_set "$app" watchdir "/home/yunohost.transmission/watched"
|
||||||
|
|
||||||
|
# YunoHost multimedia
|
||||||
|
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"
|
||||||
|
|
||||||
|
# Create RPC password
|
||||||
|
rpcpassword=$(ynh_string_random)
|
||||||
|
ynh_app_setting_set "$app" rpcpassword "$rpcpassword"
|
||||||
|
|
||||||
# Configure Transmission and reload
|
# Configure Transmission and reload
|
||||||
|
sudo service transmission-daemon stop
|
||||||
|
sed -i "s@RPCPASSWORDTOCHANGE@$rpcpassword@g" ../conf/settings.json
|
||||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/settings.json
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/settings.json
|
||||||
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
||||||
sudo service transmission-daemon reload
|
sudo service transmission-daemon start
|
||||||
|
|
||||||
# Monitor service
|
# Monitor service
|
||||||
sudo yunohost service add transmission-daemon
|
sudo yunohost service add transmission-daemon
|
||||||
|
|
|
@ -53,11 +53,12 @@ sudo yunohost firewall allow TCP 51413 > /dev/null 2>&1
|
||||||
sudo apt-get install transmission-daemon -y -qq
|
sudo apt-get install transmission-daemon -y -qq
|
||||||
|
|
||||||
# Make directories and set rights
|
# Make directories and set rights
|
||||||
sudo mkdir -p /home/yunohost.transmission/{progress,completed}
|
sudo mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
||||||
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
||||||
sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmission/progress
|
sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmission/progress /home/yunohost.transmission/watched
|
||||||
sudo find /home/yunohost.transmission/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
sudo find /home/yunohost.transmission/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
||||||
sudo find /home/yunohost.transmission/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
sudo find /home/yunohost.transmission/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
||||||
|
sudo find /home/yunohost.transmission/watched -type d | while read LINE; do sudo chmod 770 "$LINE" ; done
|
||||||
|
|
||||||
# Reload transmission service
|
# Reload transmission service
|
||||||
sudo service transmission-daemon reload
|
sudo service transmission-daemon reload
|
||||||
|
|
|
@ -6,9 +6,14 @@ set -eu
|
||||||
# Get app instance name
|
# Get app instance name
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
# Source app helpers
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Retrieve arguments
|
# Retrieve arguments
|
||||||
domain=$(sudo yunohost app setting "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(sudo yunohost app setting "$app" path)
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
|
rpcpassword=$(ynh_app_setting_get "$app" rpcpassword)
|
||||||
|
watchdir=$(ynh_app_setting_get "$app" watchdir)
|
||||||
|
|
||||||
# Remove trailing "/" for next commands
|
# Remove trailing "/" for next commands
|
||||||
path=${path%/}
|
path=${path%/}
|
||||||
|
@ -20,16 +25,38 @@ sudo yunohost firewall allow TCP 51413 > /dev/null 2>&1
|
||||||
sudo apt-get install transmission-daemon -y -qq
|
sudo apt-get install transmission-daemon -y -qq
|
||||||
|
|
||||||
# Make directories and set rights
|
# Make directories and set rights
|
||||||
sudo mkdir -p /home/yunohost.transmission/{progress,completed}
|
sudo mkdir -p /home/yunohost.transmission/{progress,completed,watched}
|
||||||
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
||||||
sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmission/progress
|
sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmission/progress /home/yunohost.transmission/watched
|
||||||
sudo find /home/yunohost.transmission/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
sudo find /home/yunohost.transmission/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done
|
||||||
sudo find /home/yunohost.transmission/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
sudo find /home/yunohost.transmission/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done
|
||||||
|
sudo find /home/yunohost.transmission/watched -type d | while read LINE; do sudo chmod 770 "$LINE" ; done
|
||||||
|
# Add watchdir in settings if it does not exist yet (previous versions)
|
||||||
|
if [ -z "$watchdir" ]; then
|
||||||
|
ynh_app_setting_set "$app" watchdir "/home/yunohost.transmission/watched"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# YunoHost multimedia
|
||||||
|
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"
|
||||||
|
|
||||||
|
# Create RPC password if none exists
|
||||||
|
if [ -z "$rpcpassword" ]; then
|
||||||
|
rpcpassword=$(ynh_string_random)
|
||||||
|
ynh_app_setting_set "$app" rpcpassword "$rpcpassword"
|
||||||
|
fi
|
||||||
|
|
||||||
# Configure Transmission and reload
|
# Configure Transmission and reload
|
||||||
|
sudo service transmission-daemon stop
|
||||||
|
sed -i "s@RPCPASSWORDTOCHANGE@$rpcpassword@g" ../conf/settings.json
|
||||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/settings.json
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/settings.json
|
||||||
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
||||||
sudo service transmission-daemon reload
|
sudo service transmission-daemon start
|
||||||
|
|
||||||
# Patch sources to add a download button
|
# Patch sources to add a download button
|
||||||
if ! grep 'toolbar-downloads' /usr/share/transmission/web/index.html --quiet; then
|
if ! grep 'toolbar-downloads' /usr/share/transmission/web/index.html --quiet; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue