1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/transmission_ynh.git synced 2024-09-04 01:46:12 +02:00
transmission_ynh/scripts/install

121 lines
4.6 KiB
Text
Raw Normal View History

2014-11-11 16:39:27 +01:00
#!/bin/bash
2013-10-29 14:14:27 +01: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
#=================================================
2017-06-13 23:37:51 +02:00
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
2022-07-03 20:36:04 +02:00
rpcpassword=$(ynh_string_random)
2013-10-29 14:14:27 +01:00
2017-06-13 23:37:51 +02:00
#=================================================
# SPECIFIC SETUP
#=================================================
Testing (#104) * Auto-update README * Bullseye (#95) * Upgrade to bullseye * Auto-update README * Auto-update README * Update check_process * Update manifest.json Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * Auto-update README * Version 2 (#99) * Update install * v2 * Auto-update README * v2 * fix * Auto-update README * Delete updater.sh * fix * fix * Update restore * fix * Update manifest.toml * add sudirs * Update install * cleaning * Update upgrade * Update tests.toml * Update manifest.toml * Update manifest.toml * cleaning * Auto-update README * cleaning * fix --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Auto-update README * Update manifest.toml * Auto-update README * Update upgrade * Update tests.toml * Fix upgrade script for old versions (#102) We moved from /home/yunohost.transmission to /home/yunohost.app/transmission. Dangling symlinks might exist in the $MEDIA_DIRECTORY... Removing this before ynh_multimedia_build_main_dir will fix this, and the symlinks will be recreated after by ynh_multimedia_addfolder. Also, we're using rm and not ynh_secure_remove because of https://github.com/YunoHost/issues/issues/2253 * Update manifest.toml * Auto-update README * Update remove * Update upgrade * cleaning * Update upgrade * Update install * Update manifest.toml * Update upgrade * Update manifest.toml * Auto-update README --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Salamandar <6552989+Salamandar@users.noreply.github.com>
2023-10-04 08:35:00 +02:00
# CREATE DATA DIRECTORY PERMISSIONS
2017-06-13 23:37:51 +02:00
#=================================================
Testing (#104) * Auto-update README * Bullseye (#95) * Upgrade to bullseye * Auto-update README * Auto-update README * Update check_process * Update manifest.json Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * Auto-update README * Version 2 (#99) * Update install * v2 * Auto-update README * v2 * fix * Auto-update README * Delete updater.sh * fix * fix * Update restore * fix * Update manifest.toml * add sudirs * Update install * cleaning * Update upgrade * Update tests.toml * Update manifest.toml * Update manifest.toml * cleaning * Auto-update README * cleaning * fix --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Auto-update README * Update manifest.toml * Auto-update README * Update upgrade * Update tests.toml * Fix upgrade script for old versions (#102) We moved from /home/yunohost.transmission to /home/yunohost.app/transmission. Dangling symlinks might exist in the $MEDIA_DIRECTORY... Removing this before ynh_multimedia_build_main_dir will fix this, and the symlinks will be recreated after by ynh_multimedia_addfolder. Also, we're using rm and not ynh_secure_remove because of https://github.com/YunoHost/issues/issues/2253 * Update manifest.toml * Auto-update README * Update remove * Update upgrade * cleaning * Update upgrade * Update install * Update manifest.toml * Update upgrade * Update manifest.toml * Auto-update README --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Salamandar <6552989+Salamandar@users.noreply.github.com>
2023-10-04 08:35:00 +02:00
ynh_script_progression --message="Set data directory permissions..."
2022-07-03 20:36:04 +02:00
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}
2017-06-13 23:37:51 +02:00
#=================================================
2022-07-03 20:36:04 +02:00
# NGINX CONFIGURATION
2017-06-13 23:37:51 +02:00
#=================================================
2022-07-03 20:36:04 +02:00
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
2017-06-13 23:37:51 +02:00
2022-07-03 20:36:04 +02:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2017-06-13 23:37:51 +02:00
#=================================================
2022-07-03 20:36:04 +02:00
# ADD A CONFIGURATION
2017-06-13 23:37:51 +02:00
#=================================================
2022-07-03 20:36:04 +02:00
ynh_script_progression --message="Adding a configuration file..." --weight=2
2017-06-13 23:37:51 +02:00
# Transmission has to be stopped before modifying its config
2019-05-01 13:24:56 +02:00
ynh_systemd_action --service_name=transmission-daemon --action=stop
2017-06-13 23:37:51 +02:00
if [ "$path" != "/" ]
2019-05-01 19:39:41 +02:00
then
path_less="$path/"
2019-05-01 19:39:41 +02:00
else
path_less="$path"
2019-05-01 19:39:41 +02:00
fi
2017-06-13 23:37:51 +02:00
ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE"
2019-05-09 11:07:57 +02: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=4
2013-10-29 14:14:27 +01:00
2017-06-18 15:57:00 +02:00
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"
2017-06-13 23:37:51 +02:00
# Share also watched directory, to allow to use it easily
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-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
cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css
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
2019-05-01 13:24:56 +02:00
#=================================================
2022-07-04 21:59:25 +02:00
# GENERIC FINALIZATION
2022-07-03 20:36:04 +02:00
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
2019-05-01 13:24:56 +02:00
#=================================================
2022-07-03 20:36:04 +02:00
ynh_script_progression --message="Integrating service in YunoHost..."
2019-05-01 13:24:56 +02:00
Testing (#104) * Auto-update README * Bullseye (#95) * Upgrade to bullseye * Auto-update README * Auto-update README * Update check_process * Update manifest.json Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * Auto-update README * Version 2 (#99) * Update install * v2 * Auto-update README * v2 * fix * Auto-update README * Delete updater.sh * fix * fix * Update restore * fix * Update manifest.toml * add sudirs * Update install * cleaning * Update upgrade * Update tests.toml * Update manifest.toml * Update manifest.toml * cleaning * Auto-update README * cleaning * fix --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Auto-update README * Update manifest.toml * Auto-update README * Update upgrade * Update tests.toml * Fix upgrade script for old versions (#102) We moved from /home/yunohost.transmission to /home/yunohost.app/transmission. Dangling symlinks might exist in the $MEDIA_DIRECTORY... Removing this before ynh_multimedia_build_main_dir will fix this, and the symlinks will be recreated after by ynh_multimedia_addfolder. Also, we're using rm and not ynh_secure_remove because of https://github.com/YunoHost/issues/issues/2253 * Update manifest.toml * Auto-update README * Update remove * Update upgrade * cleaning * Update upgrade * Update install * Update manifest.toml * Update upgrade * Update manifest.toml * Auto-update README --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Salamandar <6552989+Salamandar@users.noreply.github.com>
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"
2019-05-01 13:24:56 +02: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..."
2013-10-29 14:14:27 +01:00
2022-07-03 20:36:04 +02:00
# Start a systemd service
Testing (#104) * Auto-update README * Bullseye (#95) * Upgrade to bullseye * Auto-update README * Auto-update README * Update check_process * Update manifest.json Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Update manifest.json * Update upgrade * Auto-update README * Version 2 (#99) * Update install * v2 * Auto-update README * v2 * fix * Auto-update README * Delete updater.sh * fix * fix * Update restore * fix * Update manifest.toml * add sudirs * Update install * cleaning * Update upgrade * Update tests.toml * Update manifest.toml * Update manifest.toml * cleaning * Auto-update README * cleaning * fix --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> * Auto-update README * Update manifest.toml * Auto-update README * Update upgrade * Update tests.toml * Fix upgrade script for old versions (#102) We moved from /home/yunohost.transmission to /home/yunohost.app/transmission. Dangling symlinks might exist in the $MEDIA_DIRECTORY... Removing this before ynh_multimedia_build_main_dir will fix this, and the symlinks will be recreated after by ynh_multimedia_addfolder. Also, we're using rm and not ynh_secure_remove because of https://github.com/YunoHost/issues/issues/2253 * Update manifest.toml * Auto-update README * Update remove * Update upgrade * cleaning * Update upgrade * Update install * Update manifest.toml * Update upgrade * Update manifest.toml * Auto-update README --------- Co-authored-by: yunohost-bot <yunohost@yunohost.org> Co-authored-by: Salamandar <6552989+Salamandar@users.noreply.github.com>
2023-10-04 08:35:00 +02:00
ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd"
2013-12-07 10:10:55 +01:00
#=================================================
# RETRIEVE HASHED PASSWORD
#=================================================
ynh_script_progression --message="Saving the encrypted password..."
_wait_and_save_rcp_password_hash
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:22:53 +01:00
2019-05-01 13:24:56 +02:00
ynh_script_progression --message="Installation of $app completed" --last