1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flood_ynh.git synced 2024-09-03 18:36:20 +02:00
flood_ynh/scripts/install

92 lines
2.4 KiB
Text
Raw Normal View History

2017-07-15 11:39:52 +02:00
#!/bin/bash
2017-07-19 23:33:47 +02:00
source _common.sh
source /usr/share/yunohost/helpers
2017-07-17 12:03:11 +02:00
# Retrieve arguments
2017-07-19 23:33:47 +02:00
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
data_dir=$YNH_APP_ARG_DATA_DIR
app=$YNH_APP_INSTANCE_NAME
2017-11-19 23:00:55 +01:00
current_dir=${PWD}
2017-07-17 12:03:11 +02:00
2017-07-19 23:33:47 +02:00
# 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
2017-12-15 19:22:17 +01:00
test ! -e "$final_path" || ynh_die "Ce dossier existe déjà."
2017-07-19 23:33:47 +02:00
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app data_dir $data_dir
2017-07-19 23:16:57 +02:00
2017-07-19 23:33:47 +02:00
# Find a free port
port=$(ynh_find_port 45069)
# Open this port
2018-02-11 18:32:24 +01:00
sudo yunohost firewall allow --no-upnp TCP $port >/dev/null 2>&1
2017-07-19 23:33:47 +02:00
ynh_app_setting_set $app port $port
2017-07-15 11:39:52 +02:00
2017-07-17 12:03:11 +02:00
# Install de dependencies
2017-12-15 19:22:17 +01:00
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 rtorrent
2017-07-17 12:03:11 +02:00
sudo ldconfig
2018-02-11 18:32:24 +01:00
# Create flood user
2017-11-21 22:36:00 +01:00
ynh_system_user_create flood
2017-11-19 23:31:55 +01:00
2017-07-17 12:03:11 +02:00
# Create data dir
2018-02-11 18:32:24 +01:00
sudo mkdir -p $data_dir/{.session,watch,torrent}
2017-07-17 12:03:11 +02:00
# Add rtorrent config
2018-02-11 18:32:24 +01:00
ynh_replace_string "DATA_DIR" "$data_dir" ../sources/rtorrent.rc
2017-07-17 12:03:11 +02:00
sudo cp ../sources/rtorrent.rc /home/flood/.rtorrent.rc
sudo chown -R flood:www-data /home/flood/.rtorrent.rc
2018-02-11 18:32:24 +01:00
# Permission for data_dir
2017-07-17 12:03:11 +02:00
sudo chown -R flood:www-data $data_dir
sudo chmod 755 $data_dir
# Install nodejs for flood
2018-02-11 21:08:04 +01:00
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
2017-07-17 12:03:11 +02:00
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
2017-07-15 11:39:52 +02:00
2017-07-17 12:03:11 +02:00
# Launch flood on boot
2017-11-21 22:36:00 +01:00
cd $current_dir
2017-07-17 12:03:11 +02:00
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
# Save config
sudo yunohost app setting flood data_dir -v $data_dir
2018-02-11 19:45:03 +01:00
sudo yunohost app setting flood path_url -v $path_url
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
2018-02-11 18:32:24 +01:00
2018-02-11 20:23:54 +01:00
# nginx config
ynh_add_nginx_config
2018-02-11 18:32:24 +01:00
# Start rtorrent and flood
sudo service flood start
sudo service rtorrent start
sudo yunohost app ssowatconf
sudo service nginx reload