2017-08-09 22:13:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2017-08-09 22:13:32 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Stop script if errors
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
# Import common cmd
|
2018-02-11 01:20:58 +01:00
|
|
|
source ./experimental_helper.sh
|
2017-08-09 22:13:32 +02:00
|
|
|
source ./_common.sh
|
|
|
|
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
|
|
|
|
2017-08-09 22:13:32 +02:00
|
|
|
# Retrive arguments
|
|
|
|
old_domain=$YNH_APP_OLD_DOMAIN
|
2018-05-10 01:24:20 +02:00
|
|
|
domain=$YNH_APP_NEW_DOMAIN
|
2019-10-01 20:53:33 +02:00
|
|
|
old_path=$(ynh_normalize_url_path --path_url $YNH_APP_OLD_PATH)
|
|
|
|
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
|
2019-06-11 22:28:26 +02:00
|
|
|
seahub_port=$(ynh_app_setting_get --app $app --key seahub_port)
|
|
|
|
fileserver_port=$(ynh_app_setting_get --app $app --key fileserver_port)
|
|
|
|
webdav_port=$(ynh_app_setting_get --app $app --key webdav_port)
|
2019-08-05 15:34:00 +02:00
|
|
|
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
|
|
|
seafile_user=$app
|
2017-08-09 22:13:32 +02:00
|
|
|
|
|
|
|
# Create special path with / at the end
|
|
|
|
if [[ $old_path == '/' ]]
|
|
|
|
then
|
|
|
|
old_path2=$old_path
|
|
|
|
else
|
2018-05-09 16:13:36 +02:00
|
|
|
old_path2=$old_path'/'
|
2017-08-09 22:13:32 +02:00
|
|
|
fi
|
|
|
|
|
2018-05-09 16:13:36 +02:00
|
|
|
if [[ $path_url == '/' ]]
|
2017-08-09 22:13:32 +02:00
|
|
|
then
|
2018-05-09 16:13:36 +02:00
|
|
|
path_url2=$path_url
|
2017-08-09 22:13:32 +02:00
|
|
|
else
|
2018-05-09 16:13:36 +02:00
|
|
|
path_url2=$path_url'/'
|
2017-08-09 22:13:32 +02:00
|
|
|
fi
|
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
2017-08-09 22:13:32 +02:00
|
|
|
# STANDARD MODIFICATIONS
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_script_progression --message="Updating nginx configuration..."
|
|
|
|
|
2018-05-09 16:13:36 +02:00
|
|
|
# Update nginx config
|
|
|
|
if [ "$old_domain" != "$domain" ]
|
2017-08-09 22:13:32 +02:00
|
|
|
then
|
2018-05-19 21:51:46 +02:00
|
|
|
# Delete file checksum for the old conf file location
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_delete_file_checksum --file "/etc/nginx/conf.d/$old_domain.d/$app.conf"
|
2018-05-19 21:51:46 +02:00
|
|
|
|
|
|
|
mv "/etc/nginx/conf.d/$old_domain.d/$app.conf" "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
|
|
|
|
# Store file checksum for the new config file location
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
2017-08-09 22:13:32 +02:00
|
|
|
fi
|
2018-05-09 16:13:36 +02:00
|
|
|
ynh_add_nginx_config 'seahub_port fileserver_port webdav_port'
|
2017-08-09 22:13:32 +02:00
|
|
|
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_script_progression --message="Stoping services..."
|
2017-08-09 22:13:32 +02:00
|
|
|
|
|
|
|
# Stop service before any change
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_systemd_action --service_name seafile --action stop
|
|
|
|
ynh_systemd_action --service_name seahub --action stop
|
2018-06-07 21:20:50 +02:00
|
|
|
sleep 2
|
|
|
|
pkill -f seafile-controller || true
|
|
|
|
pkill -f seaf-server || true
|
|
|
|
pkill -f ccnet-server || true
|
|
|
|
pkill -f seahub || true
|
2017-08-09 22:13:32 +02:00
|
|
|
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_script_progression --message="Updating seafile configuration..."
|
|
|
|
|
2017-08-09 22:13:32 +02:00
|
|
|
# Update Seafile Config
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_replace_string --match_string "SERVICE_URL = https://$old_domain$old_path" --replace_string "SERVICE_URL = https://$domain$path_url" --target_file $final_path/conf/ccnet.conf
|
|
|
|
|
|
|
|
ynh_replace_string --match_string 'FILE_SERVER_ROOT = "https://'"$old_domain"'/seafhttp"' --replace_string 'FILE_SERVER_ROOT = "https://'"$domain"'/seafhttp"' --target_file $final_path/conf/seahub_settings.py
|
|
|
|
ynh_replace_string --match_string 'SITE_ROOT = "'"$old_path2"'"' --replace_string 'SITE_ROOT = "'"$path_url2"'"' --target_file $final_path/conf/seahub_settings.py
|
|
|
|
ynh_replace_string --match_string 'MEDIA_URL = "'"$old_path2"'media/"' --replace_string 'MEDIA_URL = "'"$path_url2"'media/"' --target_file $final_path/conf/seahub_settings.py
|
|
|
|
ynh_replace_string --match_string "LOGIN_URL = '${old_path2}accounts/login/'" --replace_string "LOGIN_URL = '${path_url2}accounts/login/'" --target_file $final_path/conf/seahub_settings.py
|
|
|
|
ynh_replace_string --match_string ' = "seafile@'"$old_domain"'"' --replace_string ' = "seafile@'"$domain"'"' --target_file $final_path/conf/seahub_settings.py
|
2019-08-05 15:36:02 +02:00
|
|
|
sed --in-place "s@ALLOWED_HOSTS = \['${old_domain}'\]@ALLOWED_HOSTS = \['${domain}'\]@g" $final_path/conf/seahub_settings.py
|
2019-07-30 21:58:38 +02:00
|
|
|
ynh_replace_string --match_string "REMOTE_USER_DOMAIN = '$old_domain'" --replace_string "REMOTE_USER_DOMAIN = '$domain'" --target_file $final_path/conf/seahub_settings.py
|
2019-08-05 15:36:02 +02:00
|
|
|
sed --in-place "s@REMOTE_USER_PROTECTED_PATH = \['$old_path', '$old_path/accounts/login'\]@REMOTE_USER_PROTECTED_PATH = \['$path_url', '$path_url/accounts/login'\]@g" $final_path/conf/seahub_settings.py
|
2019-06-11 22:28:26 +02:00
|
|
|
|
2018-05-21 21:30:31 +02:00
|
|
|
# Avoid the current effect
|
2018-06-07 21:20:50 +02:00
|
|
|
sleep 2
|
2018-05-21 21:30:31 +02:00
|
|
|
|
2017-08-09 22:13:32 +02:00
|
|
|
# Reload services
|
2019-06-11 22:28:26 +02:00
|
|
|
ynh_script_progression --message="Starting services..."
|
2019-09-10 22:51:15 +02:00
|
|
|
ynh_systemd_action --service_name seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
|
|
|
|
ynh_systemd_action --service_name seahub -l "Started Seafile hub." -p "systemd"
|
|
|
|
sleep 2
|
2019-06-11 22:28:26 +02:00
|
|
|
|
|
|
|
ynh_script_progression --message="Change of URL completed for $app" --time --last
|