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

Add RPC Password

Generates a RPC password and saves it as a setting. If no RPC password
is present (previous versions), generates one and saves it as a setting
as well.
This commit is contained in:
Jean-Francois 2016-12-28 16:54:07 +01:00
parent 4a8c318579
commit d86c45d52a
3 changed files with 22 additions and 3 deletions

View file

@ -45,7 +45,7 @@
"rpc-authentication-required": false,
"rpc-bind-address": "127.0.0.1",
"rpc-enabled": true,
"rpc-password": "{22ef1abe361f619946cf9ce68c442d27f73512d5lL3qJ6bY",
"rpc-password": "RPCPASSWORDTOCHANGE",
"rpc-port": 9091,
"rpc-url": "PATHTOCHANGE/transmission/",
"rpc-username": "transmission",

View file

@ -6,6 +6,9 @@ set -eu
# Get app instance name
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH
@ -41,7 +44,12 @@ sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmissio
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
# Create RPC password
rpcpassword=$(ynh_string_random)
ynh_app_setting_set "$app" rpcpassword "$rpcpassword"
# Configure Transmission and reload
sed -i "s@RPCPASSWORDTOCHANGE@$rpcpassword@g" ../conf/settings.json
sed -i "s@PATHTOCHANGE@$path@g" ../conf/settings.json
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
sudo service transmission-daemon reload

View file

@ -6,9 +6,13 @@ set -eu
# Get app instance name
app=$YNH_APP_INSTANCE_NAME
# Source app helpers
. /usr/share/yunohost/helpers
# Retrieve arguments
domain=$(sudo yunohost app setting "$app" domain)
path=$(sudo yunohost app setting "$app" path)
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
rpcpassword=$(ynh_app_setting_get "$app" rpcpassword)
# Remove trailing "/" for next commands
path=${path%/}
@ -26,7 +30,14 @@ sudo chown -R debian-transmission:debian-transmission /home/yunohost.transmissio
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
# 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
sed -i "s@RPCPASSWORDTOCHANGE@$rpcpassword@g" ../conf/settings.json
sed -i "s@PATHTOCHANGE@$path@g" ../conf/settings.json
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
sudo service transmission-daemon reload