#!/bin/bash source _common.sh source /usr/share/yunohost/helpers # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH data_dir=$YNH_APP_ARG_DATA_DIR app=$YNH_APP_INSTANCE_NAME # Exit if an error occurs during the execution of the script ynh_abort_if_errors # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) # Check web path availability ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url final_path=/var/www/$app test ! -e "$final_path" || ynh_die "Ce dossier existe déjà." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app data_dir $data_dir # Find a free port port=$(ynh_find_port 45069) # Open this port sudo yunohost firewall allow --no-upnp TCP $port 2>&1 ynh_app_setting_set $app port $port # Install de dependencies ynh_install_app_dependencies 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 mediainfo # 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 sed -i "s@YNH_EXAMPLE_PATH@$path_url@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.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 ynh_system_user_create $app # 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 # Install nodejs for flood curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs # Clone flood cd /var/www git clone https://github.com/jfurrow/flood.git # Launch flood on boot sudo cp ../sources/flood.service /etc/systemd/system/flood.service systemctl daemon-reload systemctl enable flood.service # Launch rtorrent on boot sudo cp ../sources/rtorrent.service /etc/systemd/system/rtorrent.service systemctl daemon-reload systemctl enable rtorrent.service # Start rtorrent and flood sudo service flood start sudo service rtorrent start sudo yunohost app ssowatconf sudo service nginx reload # Save config sudo yunohost app setting flood data_dir -v $data_dir sudo yunohost app setting flood path -v $path # Register the service on yunohost sudo yunohost service add rtorrent sudo yunohost service add flood