#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= rpcpassword=$(ynh_string_random) ynh_app_setting_set --app=$app --key=rpcpassword --value="$rpcpassword" #================================================= # SPECIFIC SETUP #================================================= # CREATE DATA DIRECTORY PERMISSIONS #================================================= ynh_script_progression --message="Set data directory permissions..." chmod -R 764 $data_dir chmod -R 775 $data_dir/watched chown -R debian-transmission:www-data "$data_dir" chown -R debian-transmission: $data_dir/{progress,watched} #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=2 # Transmission has to be stopped before modifying its config ynh_systemd_action --service_name=transmission-daemon --action=stop if [ "$path" != "/" ] then path_less="$path/" else path_less="$path" fi ynh_add_config --template="../conf/settings.json" --destination="/etc/transmission-daemon/settings.json" chmod 400 "/etc/transmission-daemon/settings.json" chown debian-transmission:debian-transmission "/etc/transmission-daemon/settings.json" if [ -e /proc/sys/net/core/rmem_max ] then ynh_add_config --template="../conf/90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf" chmod 400 "/etc/sysctl.d/90-transmission.conf" chown debian-transmission:debian-transmission "/etc/sysctl.d/90-transmission.conf" sysctl --load=/etc/sysctl.d/90-transmission.conf fi #================================================= # YUNOHOST MULTIMEDIA INTEGRATION #================================================= ynh_script_progression --message="Adding multimedia directories..." --weight=4 ynh_multimedia_build_main_dir # Set rights on transmission directory (parent need to be readable by other, and progress need to be writable by multimedia. Because files will move) ynh_multimedia_addfolder --source_dir="$data_dir" --dest_dir="share/Torrents" # And share completed directory ynh_multimedia_addfolder --source_dir="$data_dir/completed" --dest_dir="share/Torrents" # Share also watched directory, to allow to use it easily ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torrent to download" #================================================= # PATCH SOURCE TO ADD A DOWNLOAD BUTTON #================================================= cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css ynh_replace_string "
" "
" /usr/share/transmission/web/index.html #================================================= # GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last