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
eric_G 898d34dbd1
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>
2023-09-27 11:58:18 +02:00

114 lines
4.4 KiB
Bash

#!/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
#=================================================
ynh_script_progression --message="Creating a data directory..."
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 "<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
#=================================================
# GENERIC FINALIZATION
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add transmission-daemon --description="BitTorrent Client" --log=systemd --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"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last