2016-05-17 22:13:59 +02:00
|
|
|
#!/bin/bash
|
2016-05-14 09:56:38 +02:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
2022-07-03 20:36:04 +02:00
|
|
|
# GENERIC START
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2019-05-01 13:24:56 +02:00
|
|
|
# CHECK VERSION
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
|
2019-05-01 13:24:56 +02:00
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
2022-07-03 20:36:04 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2023-10-04 08:35:00 +02:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
2022-07-03 20:36:04 +02:00
|
|
|
|
2023-10-04 08:35:00 +02:00
|
|
|
ynh_systemd_action --service_name=transmission-daemon --action="stop" --log_path="systemd"
|
2022-07-03 20:36:04 +02:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-12-14 11:36:02 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
2017-06-13 23:37:51 +02:00
|
|
|
|
2020-12-14 11:36:02 +01:00
|
|
|
# Create a dedicated NGINX config
|
2017-08-27 22:01:10 +02:00
|
|
|
ynh_add_nginx_config
|
2017-06-13 23:37:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-07-03 20:36:04 +02:00
|
|
|
# UPDATE A CONFIG FILE
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
2022-07-03 20:36:04 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=2
|
2017-06-13 23:37:51 +02:00
|
|
|
|
2023-09-28 12:25:27 +02:00
|
|
|
if [ "$path" != "/" ]
|
2019-05-01 19:39:41 +02:00
|
|
|
then
|
2023-09-28 12:25:27 +02:00
|
|
|
path_less="$path/"
|
2019-05-01 19:39:41 +02:00
|
|
|
else
|
2023-09-28 12:25:27 +02:00
|
|
|
path_less="$path"
|
2019-05-01 19:39:41 +02:00
|
|
|
fi
|
2019-05-09 11:07:57 +02:00
|
|
|
|
2023-12-06 11:25:05 +01:00
|
|
|
_save_and_revert_rpc_password_hash_to_password
|
|
|
|
|
2023-12-06 11:24:08 +01:00
|
|
|
ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE"
|
2019-05-09 11:07:57 +02:00
|
|
|
|
2023-12-06 11:24:08 +01:00
|
|
|
chmod 400 "$SETTINGS_FILE"
|
|
|
|
chown debian-transmission:debian-transmission "$SETTINGS_FILE"
|
2017-06-13 23:37:51 +02:00
|
|
|
|
2020-03-03 19:06:26 +01:00
|
|
|
if [ -e /proc/sys/net/core/rmem_max ]
|
|
|
|
then
|
2022-07-03 20:36:04 +02:00
|
|
|
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
|
2020-03-03 19:06:26 +01:00
|
|
|
fi
|
2017-06-13 23:37:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# YUNOHOST MULTIMEDIA INTEGRATION
|
|
|
|
#=================================================
|
2019-05-01 13:24:56 +02:00
|
|
|
ynh_script_progression --message="Adding multimedia directories..." --weight=3
|
2013-10-29 14:26:46 +01:00
|
|
|
|
2023-09-28 12:25:27 +02:00
|
|
|
# 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"
|
|
|
|
|
2017-06-18 15:57:00 +02:00
|
|
|
ynh_multimedia_build_main_dir
|
2023-09-28 12:25:27 +02:00
|
|
|
|
2017-04-01 20:41:34 +02:00
|
|
|
# Set rights on transmission directory (parent need to be readable by other, and progress need to be writable by multimedia. Because files will move)
|
2023-09-28 12:25:27 +02:00
|
|
|
ynh_multimedia_addfolder --source_dir="$data_dir" --dest_dir="share/Torrents"
|
|
|
|
|
2017-04-01 20:41:34 +02:00
|
|
|
# And share completed directory
|
2023-09-28 12:25:27 +02:00
|
|
|
ynh_multimedia_addfolder --source_dir="$data_dir/completed" --dest_dir="share/Torrents"
|
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
# Share also watched directory, to allow to use it easily
|
2023-09-28 12:25:27 +02:00
|
|
|
ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torrent to download"
|
2017-06-13 23:37:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON
|
|
|
|
#=================================================
|
2017-04-01 20:41:34 +02:00
|
|
|
|
2017-08-27 22:01:10 +02:00
|
|
|
cp ../sources/extra_files/app/toolbar-downloads.png /usr/share/transmission/web/style/transmission/images/toolbar-downloads.png
|
2017-06-13 23:37:51 +02:00
|
|
|
if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css
|
|
|
|
then
|
2022-07-03 20:36:04 +02:00
|
|
|
cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css
|
2016-12-28 16:54:07 +01:00
|
|
|
fi
|
2023-09-28 12:25:27 +02:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
ynh_replace_string "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div>$" "<div id=\"toolbar-inspector\" title=\"Toggle Inspector\"></div><div id=\"toolbar-separator\"></div><a href=\"../../downloads/\" id=\"toolbar-downloads\" title=\"Downloads\" target=\"_blank\"></a>" /usr/share/transmission/web/index.html
|
2016-12-28 16:54:07 +01:00
|
|
|
|
2023-10-04 08:35:00 +02:00
|
|
|
#=================================================
|
|
|
|
# SET DATA DIRECTORY PERMISSIONS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Set data directory permissions..." --weight=1
|
|
|
|
|
2023-12-06 13:24:50 +01:00
|
|
|
chmod -R 775 $data_dir
|
2023-10-04 08:35:00 +02:00
|
|
|
chmod -R 775 $data_dir/watched
|
|
|
|
chown -R debian-transmission:www-data "$data_dir"
|
|
|
|
chown -R debian-transmission: $data_dir/{progress,watched}
|
|
|
|
|
2020-12-14 11:36:02 +01:00
|
|
|
#=================================================
|
2022-07-03 20:36:04 +02:00
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2020-12-14 11:36:02 +01:00
|
|
|
#=================================================
|
2023-10-04 08:35:00 +02:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2020-12-14 11:36:02 +01:00
|
|
|
|
2023-10-04 08:35:00 +02:00
|
|
|
yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer"
|
2020-12-14 11:36:02 +01:00
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
2022-07-03 20:36:04 +02:00
|
|
|
# START SYSTEMD SERVICE
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
2022-07-03 20:36:04 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=2
|
2013-10-29 14:26:46 +01:00
|
|
|
|
2023-10-04 08:35:00 +02:00
|
|
|
ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd"
|
2014-11-11 17:00:05 +01:00
|
|
|
|
2023-12-05 15:38:33 +01:00
|
|
|
#=================================================
|
|
|
|
# PATCH DOWNLOAD LOCATION IF DOWNLOAD PATH CHANGED
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Patching download locations..." --weight=1
|
|
|
|
|
|
|
|
_patch_download_locations
|
|
|
|
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
2019-05-01 13:24:56 +02:00
|
|
|
# END OF SCRIPT
|
2017-06-13 23:37:51 +02:00
|
|
|
#=================================================
|
2014-11-11 16:55:15 +01:00
|
|
|
|
2019-05-01 13:24:56 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|