#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) #================================================= # STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICE #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=transmission-daemon --action="stop" --log_path="systemd" #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=2 if [ "$path" != "/" ] then path_less="$path/" else path_less="$path" fi _save_and_revert_rpc_password_hash_to_password ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE" chmod 400 "$SETTINGS_FILE" chown debian-transmission:debian-transmission "$SETTINGS_FILE" 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=3 # Remove possibly dangling symlinks created before the /home/yunohost.transmission -> /home/yunohost.app/transmission transition # Use rm because ynh_secure_remove fails on dangling symlinks, see https://github.com/YunoHost/issues/issues/2253... rm "$MEDIA_DIRECTORY/share/Torrents" rm "$MEDIA_DIRECTORY/share/Torrent to download" 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 if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css then cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css fi ynh_replace_string "
$" "
" /usr/share/transmission/web/index.html #================================================= # SET DATA DIRECTORY PERMISSIONS #================================================= ynh_script_progression --message="Set data directory permissions..." --weight=1 chmod -R 775 $data_dir chmod -R 775 $data_dir/watched chown -R debian-transmission:www-data "$data_dir" chown -R debian-transmission: $data_dir/{progress,watched} #================================================= # GENERIC FINALIZATION #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 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..." --weight=2 ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd" #================================================= # PATCH DOWNLOAD LOCATION IF DOWNLOAD PATH CHANGED #================================================= ynh_script_progression --message="Patching download locations..." --weight=1 _patch_download_locations #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last