mirror of
https://github.com/YunoHost-Apps/transmission_ynh.git
synced 2024-09-04 01:46:12 +02:00
Changed change_url script for one based on wallabag2 package
This commit is contained in:
parent
3eef503e56
commit
7e6d2fabec
1 changed files with 27 additions and 52 deletions
|
@ -22,7 +22,7 @@ new_path=$YNH_APP_NEW_PATH
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK THE SYNTAX OF THE PATHS
|
# CHECK PATHS SYNTAX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
test -n "$old_path" || old_path="/"
|
test -n "$old_path" || old_path="/"
|
||||||
|
@ -46,21 +46,10 @@ then
|
||||||
change_path=1
|
change_path=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MANAGE FAILURE OF THE SCRIPT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_clean_setup () {
|
|
||||||
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
@ -70,67 +59,53 @@ if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
# Make a backup of the original nginx config file if modified
|
# Make a backup of the original nginx config file if modified
|
||||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||||
|
# Set global variables for nginx helper
|
||||||
# Move from sub path to root
|
domain="$old_domain"
|
||||||
if [ "$new_path" == "/" ]
|
path_url="$new_path"
|
||||||
|
# Store path_url setting
|
||||||
|
ynh_app_setting_set $app path_url "$path_url"
|
||||||
|
# Create a dedicated nginx config
|
||||||
|
ynh_add_nginx_config
|
||||||
|
if [ "$path_url" = "/" ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "^location $old_path/" "location $new_path" "$nginx_conf_path"
|
# Replace "//" location (due to nginx template)
|
||||||
ynh_replace_string "^.*rewrite.*\^/" "#sub_path_only&" "$nginx_conf_path"
|
# Prevent from replacing in "http://" expressions by excluding ":" as preceding character
|
||||||
ynh_replace_string "^location ~\* $old_path/" "location ~* $new_path" "$nginx_conf_path"
|
sed --in-place "s@\([^:]\)//@\1/@g" "$nginx_conf_path"
|
||||||
|
|
||||||
# Change the path in the two rewrite instructions
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path/*admin\$ $old_path/*" "\1${new_path}admin\$ $new_path" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Move to a sub path
|
|
||||||
else
|
else
|
||||||
ynh_replace_string "^location $old_path.*" "location $new_path/ {" "$nginx_conf_path"
|
# Move prefix comment #for-subdir at end of lines
|
||||||
ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path"
|
sed --in-place "s/#for-subdir\(.*\)/\1 #for-subdir/g" "$nginx_conf_path"
|
||||||
ynh_replace_string "^location ~\* $old_path/*" "location ~* $new_path/" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Change the path in the two rewrite instructions
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path/" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path/*admin\$ $old_path/*" "\1$new_path/admin\$ $new_path/" "$nginx_conf_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate and store the nginx config file checksum
|
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
ynh_store_file_checksum "$nginx_conf_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
if [ $change_domain -eq 1 ]
|
if [ $change_domain -eq 1 ]
|
||||||
then
|
then
|
||||||
# Delete file checksum for the old conf file location
|
# Delete file checksum for the old conf file location
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
ynh_delete_file_checksum "$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
|
# Store file checksum for the new config file location
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf
|
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
# Calculate and store the nginx config file checksum
|
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
# SPECIFIC MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# STOP TRANSMISSION
|
# STOP TRANSMISSION
|
||||||
#=================================================
|
|
||||||
|
|
||||||
systemctl stop transmission-daemon
|
systemctl stop transmission-daemon
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHANGE TRANSMISSION CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
if [ $change_path -eq 1 ]
|
if [ $change_path -eq 1 ]
|
||||||
then
|
then
|
||||||
[ "$new_path" = "/" ] || new_path=${new_path}/
|
[ "$new_path" = "/" ] || new_path=${new_path}/
|
||||||
ynh_replace_string "\"rpc-url\": \"${old_path}transmission/\"" "\"rpc-url\": \"${new_path}transmission/\"" /etc/transmission-daemon/settings.json
|
ynh_replace_string "\"rpc-url\": \"${old_path}transmission/\"" "\"rpc-url\": \"${new_path}transmission/\"" /etc/transmission-daemon/settings.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# START TRANSMISSION
|
# START TRANSMISSION
|
||||||
#=================================================
|
|
||||||
|
|
||||||
systemctl start transmission-daemon
|
systemctl start transmission-daemon
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue