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

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 03:07:17 +02:00 committed by Alexandre Aubin
parent 29939e5245
commit 2833bcee83
9 changed files with 89 additions and 154 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
*.swp *.swp
*.swo *.swo
*~ *~
*.sw[op]
.DS_Store

View file

@ -17,7 +17,8 @@ code = "https://github.com/transmission/transmission"
cpe = "cpe:2.3:a:transmissionbt:transmission" cpe = "cpe:2.3:a:transmissionbt:transmission"
[integration] [integration]
yunohost = ">= 11.2" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = false multi_instance = false
@ -46,6 +47,7 @@ ram.runtime = "50M"
[resources.system_user] [resources.system_user]
[resources.install_dir] [resources.install_dir]
group = "www-data:r-x"
[resources.data_dir] [resources.data_dir]
subdirs = [ "progress", "completed", "watched" ] subdirs = [ "progress", "completed", "watched" ]

View file

@ -1,15 +1,11 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#================================================= #=================================================
SETTINGS_FILE="/etc/transmission-daemon/settings.json" SETTINGS_FILE="/etc/transmission-daemon/settings.json"
#=================================================
# PERSONAL HELPERS
#=================================================
_wait_and_save_rcp_password_hash() { _wait_and_save_rcp_password_hash() {
# Transmission first reads the plaintext password in the config, then # Transmission first reads the plaintext password in the config, then
# computes a cryptographic hash and rewrites the config file. # computes a cryptographic hash and rewrites the config file.
@ -18,9 +14,9 @@ _wait_and_save_rcp_password_hash() {
pass=$(jq -r '.["rpc-password"]' "$SETTINGS_FILE") pass=$(jq -r '.["rpc-password"]' "$SETTINGS_FILE")
if [[ "$pass" == "{"* ]]; then if [[ "$pass" == "{"* ]]; then
# Save the hashed password # Save the hashed password
ynh_app_setting_set --app="$app" --key="rpcpassword" --value="$pass" ynh_app_setting_set --key="rpcpassword" --value="$pass"
# Save the edited settings file # Save the edited settings file
ynh_store_file_checksum --file="$SETTINGS_FILE" ynh_store_file_checksum "$SETTINGS_FILE"
return return
fi fi
sleep 1 sleep 1
@ -30,7 +26,6 @@ _wait_and_save_rcp_password_hash() {
return 1 return 1
} }
_save_and_revert_rpc_password_hash_to_password() { _save_and_revert_rpc_password_hash_to_password() {
# This one is tricky : # This one is tricky :
# * transmission did password -> hash (we want to store hash) # * transmission did password -> hash (we want to store hash)
@ -44,13 +39,12 @@ _save_and_revert_rpc_password_hash_to_password() {
return return
fi fi
ynh_app_setting_set --app="$app" --key="rpcpassword" --value="$password_hash" ynh_app_setting_set --key="rpcpassword" --value="$password_hash"
# Revert the change to maybe prevent ynh_backup_if_checksum_is_different to trigger # Revert the change to maybe prevent ynh_backup_if_checksum_is_different to trigger
sed -i "s|\"${password_hash}\"|\"${rpcpassword}\"|" "$SETTINGS_FILE" sed -i "s|\"${password_hash}\"|\"${rpcpassword}\"|" "$SETTINGS_FILE"
} }
_patch_download_locations() { _patch_download_locations() {
# First check if patching is required... # First check if patching is required...
if ! grep -R /home/yunohost.transmission /var/lib/transmission-daemon/info/resume >/dev/null; then if ! grep -R /home/yunohost.transmission /var/lib/transmission-daemon/info/resume >/dev/null; then
@ -77,11 +71,3 @@ _patch_download_locations() {
transmission-remote "$rpc_url" -t "$torrent" --verify transmission-remote "$rpc_url" -t "$torrent" --verify
done done
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,31 +1,22 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE DATA DIR # BACKUP THE DATA DIR
#================================================= #=================================================
ynh_backup --src_path="$data_dir" --is_big ynh_backup "$data_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
@ -33,17 +24,17 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
ynh_backup --src_path="$SETTINGS_FILE" ynh_backup "$SETTINGS_FILE"
if [ -e /proc/sys/net/core/rmem_max ] if [ -e /proc/sys/net/core/rmem_max ]
then then
ynh_backup --src_path="/etc/sysctl.d/90-transmission.conf" ynh_backup "/etc/sysctl.d/90-transmission.conf"
fi fi
ynh_backup --src_path="/usr/share/transmission" ynh_backup "/usr/share/transmission"
ynh_backup --src_path="/var/lib/transmission-daemon" ynh_backup "/var/lib/transmission-daemon"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,29 +1,21 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=2 ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=transmission-daemon --action="stop" --log_path="systemd" ynh_systemctl --service=transmission-daemon --action="stop" --log_path="systemd"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config ynh_config_change_url_nginx
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
@ -31,23 +23,21 @@ ynh_change_url_nginx_config
# UPDATE TRANSMISSION CONFIGURATION # UPDATE TRANSMISSION CONFIGURATION
#================================================= #=================================================
ynh_backup_if_checksum_is_different --file="$SETTINGS_FILE" ynh_backup_if_checksum_is_different "$SETTINGS_FILE"
ynh_replace_string --match_string="rpc-url\": \"${old_path%/}/transmission/" --replace_string="rpc-url\": \"${new_path%/}/transmission/" --target_file="$SETTINGS_FILE" ynh_replace --match="rpc-url\": \"${old_path%/}/transmission/" --replace="rpc-url\": \"${new_path%/}/transmission/" --file="$SETTINGS_FILE"
ynh_store_file_checksum --file="$SETTINGS_FILE" ynh_store_file_checksum "$SETTINGS_FILE"
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd" ynh_systemctl --service=transmission-daemon --action="start" --log_path="systemd"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression "Change of URL completed for $app"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -20,7 +14,7 @@ rpcpassword=$(ynh_string_random)
#================================================= #=================================================
# CREATE DATA DIRECTORY PERMISSIONS # CREATE DATA DIRECTORY PERMISSIONS
#================================================= #=================================================
ynh_script_progression --message="Set data directory permissions..." ynh_script_progression "Set data directory permissions..."
chmod -R 775 $data_dir chmod -R 775 $data_dir
chmod -R 775 $data_dir/watched chmod -R 775 $data_dir/watched
@ -30,18 +24,18 @@ chown -R debian-transmission: "$data_dir"/{progress,watched}
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=2 ynh_script_progression "Configuring NGINX web server..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2 ynh_script_progression "Adding $app's configuration..."
# Transmission has to be stopped before modifying its config # Transmission has to be stopped before modifying its config
ynh_systemd_action --service_name=transmission-daemon --action=stop ynh_systemctl --service=transmission-daemon --action=stop
if [ "$path" != "/" ] if [ "$path" != "/" ]
then then
@ -50,14 +44,14 @@ else
path_less="$path" path_less="$path"
fi fi
ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE" ynh_config_add --template="settings.json" --destination="$SETTINGS_FILE"
chmod 400 "$SETTINGS_FILE" chmod 400 "$SETTINGS_FILE"
chown debian-transmission:debian-transmission "$SETTINGS_FILE" chown debian-transmission:debian-transmission "$SETTINGS_FILE"
if [ -e /proc/sys/net/core/rmem_max ] if [ -e /proc/sys/net/core/rmem_max ]
then then
ynh_add_config --template="../conf/90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf" ynh_config_add --template="90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf"
chmod 400 "/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" chown debian-transmission:debian-transmission "/etc/sysctl.d/90-transmission.conf"
@ -68,7 +62,7 @@ fi
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=4 ynh_script_progression "Adding multimedia directories..."
ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir
@ -85,31 +79,30 @@ ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torr
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON # 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 cp ../sources/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 cat ../sources/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 # FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file=
ynh_replace "<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 # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression "Integrating service in YunoHost..."
yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer" yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression "Starting $app's systemd service..."
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd" ynh_systemctl --service=transmission-daemon --action="start" --log_path="systemd"
#================================================= #=================================================
# RETRIEVE HASHED PASSWORD # RETRIEVE HASHED PASSWORD
#================================================= #=================================================
ynh_script_progression --message="Saving the encrypted password..." ynh_script_progression "Saving the encrypted password..."
_wait_and_save_rcp_password_hash _wait_and_save_rcp_password_hash
@ -117,4 +110,4 @@ _wait_and_save_rcp_password_hash
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -14,28 +8,28 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression "Removing system configurations related to $app..."
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if yunohost service status transmission-daemon >/dev/null 2>&1 if yunohost service status transmission-daemon >/dev/null 2>&1
then then
ynh_script_progression --message="Removing $app service integration..." --weight=8 ynh_script_progression "Removing $app service integration..."
yunohost service remove transmission-daemon yunohost service remove transmission-daemon
fi fi
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_config_remove_nginx
# Web interface # Web interface
ynh_secure_remove --file=/usr/share/transmission ynh_safe_rm /usr/share/transmission
# And data # And data
ynh_secure_remove --file=/var/lib/transmission-daemon ynh_safe_rm /var/lib/transmission-daemon
# Kernel parameters # Kernel parameters
if [ -e /proc/sys/net/core/rmem_max ] if [ -e /proc/sys/net/core/rmem_max ]
then then
ynh_secure_remove --file=/etc/sysctl.d/90-transmission.conf ynh_safe_rm /etc/sysctl.d/90-transmission.conf
sysctl --load=/etc/sysctl.d/90-transmission.conf sysctl --load=/etc/sysctl.d/90-transmission.conf
fi fi
@ -43,4 +37,4 @@ fi
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,9 +7,9 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." ynh_script_progression "Restoring the data directory..."
ynh_restore_file --origin_path="$data_dir" --not_mandatory ynh_restore "$data_dir"
chmod -R 775 $data_dir chmod -R 775 $data_dir
chmod -R 775 $data_dir/watched chmod -R 775 $data_dir/watched
@ -25,37 +19,37 @@ chown -R debian-transmission: $data_dir/{progress,watched}
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_script_progression "Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." --weight=2 ynh_script_progression "Restoring various files..."
# Transmission has to be stopped before modifying its config # Transmission has to be stopped before modifying its config
ynh_systemd_action --service_name=transmission-daemon --action=stop ynh_systemctl --service=transmission-daemon --action=stop
ynh_secure_remove --file="$SETTINGS_FILE" ynh_safe_rm "$SETTINGS_FILE"
ynh_restore_file --origin_path="$SETTINGS_FILE" ynh_restore "$SETTINGS_FILE"
if [ -e /proc/sys/net/core/rmem_max ] if [ -e /proc/sys/net/core/rmem_max ]
then then
ynh_restore_file --origin_path="/etc/sysctl.d/90-transmission.conf" ynh_restore "/etc/sysctl.d/90-transmission.conf"
sysctl --load=/etc/sysctl.d/90-transmission.conf sysctl --load=/etc/sysctl.d/90-transmission.conf
fi fi
ynh_secure_remove --file=/usr/share/transmission ynh_safe_rm /usr/share/transmission
ynh_restore_file --origin_path=/usr/share/transmission ynh_restore /usr/share/transmission
ynh_secure_remove --file=/var/lib/transmission-daemon ynh_safe_rm /var/lib/transmission-daemon
ynh_restore_file --origin_path=/var/lib/transmission-daemon ynh_restore /var/lib/transmission-daemon
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=4 ynh_script_progression "Adding multimedia directories..."
ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir
@ -71,23 +65,21 @@ ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torr
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression "Integrating service in YunoHost..."
yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer" yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer"
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_script_progression "Reloading NGINX web server and $app's service..."
ynh_systemd_action --service_name=transmission-daemon --action=start --log_path="systemd" ynh_systemctl --service=transmission-daemon --action=start --log_path="systemd"
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -1,41 +1,27 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression "Stopping $app's systemd service..."
ynh_systemd_action --service_name=transmission-daemon --action="stop" --log_path="systemd" ynh_systemctl --service=transmission-daemon --action="stop" --log_path="systemd"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 ynh_script_progression "Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=2 ynh_script_progression "Updating configuration..."
if [ "$path" != "/" ] if [ "$path" != "/" ]
then then
@ -46,14 +32,14 @@ fi
_save_and_revert_rpc_password_hash_to_password _save_and_revert_rpc_password_hash_to_password
ynh_add_config --template="../conf/settings.json" --destination="$SETTINGS_FILE" ynh_config_add --template="settings.json" --destination="$SETTINGS_FILE"
chmod 400 "$SETTINGS_FILE" chmod 400 "$SETTINGS_FILE"
chown debian-transmission:debian-transmission "$SETTINGS_FILE" chown debian-transmission:debian-transmission "$SETTINGS_FILE"
if [ -e /proc/sys/net/core/rmem_max ] if [ -e /proc/sys/net/core/rmem_max ]
then then
ynh_add_config --template="../conf/90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf" ynh_config_add --template="90-transmission.conf" --destination="/etc/sysctl.d/90-transmission.conf"
chmod 400 "/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" chown debian-transmission:debian-transmission "/etc/sysctl.d/90-transmission.conf"
@ -64,10 +50,10 @@ fi
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=3 ynh_script_progression "Adding multimedia directories..."
# Remove possibly dangling symlinks created before the /home/yunohost.transmission -> /home/yunohost.app/transmission transition # 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... # Use rm because ynh_safe_rm fails on dangling symlinks, see https://github.com/YunoHost/issues/issues/2253...
rm "$MEDIA_DIRECTORY/share/Torrents" || true rm "$MEDIA_DIRECTORY/share/Torrents" || true
rm "$MEDIA_DIRECTORY/share/Torrent to download" || true rm "$MEDIA_DIRECTORY/share/Torrent to download" || true
@ -86,44 +72,43 @@ ynh_multimedia_addfolder --source_dir="$data_dir/watched" --dest_dir="share/Torr
# PATCH SOURCE TO ADD A DOWNLOAD BUTTON # 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 cp ../sources/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 if ! grep --quiet "Inserted by Yunohost install script" /usr/share/transmission/web/style/transmission/common.css
then then
cat ../sources/extra_files/app/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css cat ../sources/ynh_common.css >> /usr/share/transmission/web/style/transmission/common.css
fi fi
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 # FIXMEhelpers2.1: ynh_replace used with positional args. Please add the keywords: --match=, --replace=, --file=
ynh_replace "<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
#================================================= #=================================================
# SET DATA DIRECTORY PERMISSIONS # SET DATA DIRECTORY PERMISSIONS
#================================================= #=================================================
ynh_script_progression --message="Set data directory permissions..." --weight=1 ynh_script_progression "Set data directory permissions..."
chmod -R 775 $data_dir chmod -R 775 $data_dir
chmod -R 775 $data_dir/watched chmod -R 775 $data_dir/watched
chown -R debian-transmission:www-data "$data_dir" chown -R debian-transmission:www-data "$data_dir"
chown -R debian-transmission: $data_dir/{progress,watched} chown -R debian-transmission: $data_dir/{progress,watched}
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression "Integrating service in YunoHost..."
yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer" yunohost service add transmission-daemon --description="BitTorrent Client" --log="/var/log/$app/$app.log" --needs_exposed_ports="$port_peer"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name=transmission-daemon --action="start" --log_path="systemd" ynh_systemctl --service=transmission-daemon --action="start" --log_path="systemd"
#================================================= #=================================================
# PATCH DOWNLOAD LOCATION IF DOWNLOAD PATH CHANGED # PATCH DOWNLOAD LOCATION IF DOWNLOAD PATH CHANGED
#================================================= #=================================================
ynh_script_progression --message="Patching download locations..." --weight=1 ynh_script_progression "Patching download locations..."
_patch_download_locations _patch_download_locations
@ -131,4 +116,4 @@ _patch_download_locations
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"