2017-07-15 11:39:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Retrieve arguments
|
|
|
|
domain=$1
|
|
|
|
path=$2
|
|
|
|
data_dir=$3
|
|
|
|
current_dir=${PWD}
|
|
|
|
debian_version=$(lsb_release -c -s)
|
|
|
|
|
2017-07-19 23:16:57 +02:00
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Check domain/path availability
|
|
|
|
sudo yunohost app checkurl $domain$path -a flood
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
echo "Error: domain/path not available"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Install de dependencies
|
|
|
|
sudo apt-get update
|
|
|
|
apt install build-essential subversion autoconf g++ gcc curl comerr-dev pkg-config cfv libtool libssl-dev libncurses5-dev ncurses-term libsigc++-2.0-dev libcppunit-dev libcurl3 libcurl4-openssl-dev
|
|
|
|
cd /tmp
|
|
|
|
wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2015.6.1_all.deb
|
|
|
|
sudo dpkg -i deb-multimedia-keyring_2015.6.1_all.deb
|
|
|
|
|
|
|
|
# Build xmlrpc
|
|
|
|
cd /tmp
|
|
|
|
sudo svn checkout http://svn.code.sf.net/p/xmlrpc-c/code/stable xmlrpc-c
|
|
|
|
cd xmlrpc-c/
|
|
|
|
sudo ./configure
|
|
|
|
sudo make
|
|
|
|
sudo make install
|
|
|
|
|
|
|
|
# Build libtorrent
|
|
|
|
cd /tmp
|
|
|
|
sudo git clone https://github.com/rakshasa/libtorrent.git
|
|
|
|
cd libtorrent
|
|
|
|
sudo git checkout 0.13.6
|
|
|
|
sudo ./autogen.sh
|
|
|
|
sudo ./configure
|
|
|
|
sudo make
|
|
|
|
sudo make install
|
|
|
|
|
|
|
|
# Build rtorrent
|
|
|
|
cd /tmp
|
|
|
|
sudo git clone https://github.com/rakshasa/rtorrent.git
|
|
|
|
cd rtorrent
|
|
|
|
sudo git checkout 0.9.6
|
|
|
|
sudo ./autogen.sh
|
|
|
|
sudo ./configure --with-xmlrpc-c
|
|
|
|
sudo make
|
|
|
|
sudo make install
|
|
|
|
|
|
|
|
sudo ldconfig
|
|
|
|
|
|
|
|
# Configure nginx
|
|
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/flood.conf
|
|
|
|
|
|
|
|
# Create data dir
|
|
|
|
sudo mkdir $data_dir
|
|
|
|
sudo mkdir $data_dir/watch
|
|
|
|
sudo mkdir $data_dir/downloads
|
|
|
|
sudo mkdir $data_dir/.session
|
|
|
|
|
|
|
|
# Create rtorrent user
|
|
|
|
sudo useradd -p -m flood
|
|
|
|
|
|
|
|
# Add rtorrent config
|
|
|
|
sudo sed -i "s@DATA_DIR@$data_dir@g" ../sources/rtorrent.rc
|
|
|
|
sudo cp ../sources/rtorrent.rc /home/flood/.rtorrent.rc
|
|
|
|
sudo chown -R flood:www-data /home/flood/.rtorrent.rc
|
|
|
|
|
|
|
|
sudo chown -R flood:www-data $data_dir
|
|
|
|
sudo chmod 755 $data_dir
|
|
|
|
|
|
|
|
|
|
|
|
# Check port availability
|
|
|
|
sudo yunohost app checkport 45069
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Open port in firewall
|
|
|
|
sudo yunohost firewall allow TCP 45069 > /dev/null 2>&1
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Install nodejs for flood
|
|
|
|
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
|
|
|
|
sudo apt-get install -y nodejs
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Clone flood
|
2017-07-19 22:40:20 +02:00
|
|
|
cd /var/www
|
|
|
|
git clone https://github.com/jfurrow/flood.git
|
|
|
|
cp
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Launch flood on boot
|
|
|
|
sudo cp ../sources/flood.service /etc/systemd/system/flood.service
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl enable flood.service
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Launch rtorrent on boot
|
|
|
|
sudo cp ../sources/rtorrent.service /etc/systemd/system/rtorrent.service
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl enable rtorrent.service
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Start rtorrent and flood
|
|
|
|
sudo service flood start
|
|
|
|
sudo service rtorrent start
|
|
|
|
sudo yunohost app ssowatconf
|
|
|
|
sudo service nginx reload
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Save config
|
|
|
|
sudo yunohost app setting flood data_dir -v $data_dir
|
|
|
|
sudo yunohost app setting flood path -v $path
|
2017-07-15 11:39:52 +02:00
|
|
|
|
2017-07-17 12:03:11 +02:00
|
|
|
# Register the service on yunohost
|
2017-07-19 22:40:20 +02:00
|
|
|
sudo yunohost service add rtorrent
|
|
|
|
sudo yunohost service add flood
|