2014-11-11 16:39:27 +01:00
|
|
|
#!/bin/bash
|
2013-10-29 14:14:27 +01:00
|
|
|
|
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
|
|
|
|
sudo yunohost app checkurl $domain$path -a transmission
|
2014-11-11 16:39:27 +01:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2013-10-29 14:51:24 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2013-10-29 14:14:27 +01:00
|
|
|
|
|
|
|
# Remove trailing "/" for next commands
|
|
|
|
path=${path%/}
|
|
|
|
|
|
|
|
# Check port availability
|
|
|
|
sudo yunohost app checkport 9091
|
2013-10-29 14:51:24 +01:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
2014-11-11 16:39:27 +01:00
|
|
|
exit 1
|
2013-10-29 14:51:24 +01:00
|
|
|
fi
|
2013-10-29 14:14:27 +01:00
|
|
|
sudo yunohost app checkport 51413
|
2014-11-11 16:39:27 +01:00
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
2013-10-29 14:51:24 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Open port in firewall
|
|
|
|
sudo yunohost firewall allow TCP 51413 > /dev/null 2>&1
|
2013-10-29 14:14:27 +01:00
|
|
|
|
|
|
|
# Install official debian package
|
2014-11-11 16:39:27 +01:00
|
|
|
sudo apt-get install transmission-daemon -y -qq
|
2013-10-29 14:14:27 +01:00
|
|
|
|
|
|
|
# Make directories and set rights
|
|
|
|
sudo mkdir -p /home/yunohost.transmission/{progress,completed}
|
2014-12-04 11:48:27 +01:00
|
|
|
sudo chown -R debian-transmission:www-data /home/yunohost.transmission/
|
2014-12-04 11:44:02 +01:00
|
|
|
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
|
2013-10-29 14:14:27 +01:00
|
|
|
|
|
|
|
# Configure Transmission and reload
|
2013-10-29 14:51:24 +01:00
|
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/settings.json
|
2013-10-29 14:14:27 +01:00
|
|
|
sudo cp ../conf/settings.json /etc/transmission-daemon/settings.json
|
|
|
|
sudo service transmission-daemon reload
|
|
|
|
|
2013-12-07 10:10:55 +01:00
|
|
|
# Monitor service
|
2014-05-18 15:40:05 +02:00
|
|
|
sudo yunohost service add transmission-daemon
|
2013-12-07 10:10:55 +01:00
|
|
|
|
2014-11-11 16:22:53 +01:00
|
|
|
# Patch sources to add a download button
|
2014-11-11 16:37:09 +01:00
|
|
|
sudo cp ../sources/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png
|
|
|
|
sudo bash -c 'cat ../sources/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css'
|
2014-12-04 11:42:49 +01:00
|
|
|
sudo sed -i "s@<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>@g" /usr/share/transmission/web/index.html
|
2014-11-11 16:22:53 +01:00
|
|
|
|
2013-10-29 14:14:27 +01:00
|
|
|
# Configure Nginx and reload
|
2013-10-29 14:51:24 +01:00
|
|
|
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
2013-10-29 14:14:27 +01:00
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/transmission.conf
|
2013-10-29 14:51:24 +01:00
|
|
|
sudo service nginx reload
|
|
|
|
echo $?
|