2017-08-09 22:13:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2018-02-11 01:20:58 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-17 23:49:06 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ./experimental_helper.sh
|
|
|
|
source ./_common.sh
|
|
|
|
|
2017-08-09 22:13:32 +02:00
|
|
|
# Source YunoHost helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2023-10-04 07:54:21 +02:00
|
|
|
path=$new_path
|
|
|
|
domain=$new_domain
|
2019-06-11 22:28:26 +02:00
|
|
|
|
2023-09-27 23:04:06 +02:00
|
|
|
# Create special path with / at the end
|
|
|
|
if [[ $path == '/' ]]
|
|
|
|
then
|
|
|
|
path2=$path
|
|
|
|
else
|
|
|
|
path2=$path"/"
|
|
|
|
fi
|
|
|
|
|
2023-10-04 07:54:21 +02:00
|
|
|
# Patch helper
|
|
|
|
|
|
|
|
ynh_change_url_nginx_config() {
|
|
|
|
local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
|
|
|
local new_nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf
|
|
|
|
|
|
|
|
# Change the domain for NGINX
|
|
|
|
if [ $change_domain -eq 1 ]
|
|
|
|
then
|
|
|
|
ynh_delete_file_checksum --file="$old_nginx_conf_path"
|
|
|
|
mv "$old_nginx_conf_path" "$new_nginx_conf_path"
|
|
|
|
ynh_store_file_checksum --file="$new_nginx_conf_path"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Change the path in the NGINX config file
|
|
|
|
if [ $change_path -eq 1 ]
|
|
|
|
then
|
|
|
|
# Make a backup of the original NGINX config file if modified
|
|
|
|
ynh_backup_if_checksum_is_different --file="$new_nginx_conf_path"
|
|
|
|
# Set global variables for NGINX helper
|
|
|
|
path="$new_path"
|
|
|
|
path_url="$new_path"
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
fi
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
}
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD MODIFICATIONS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
|
|
|
ynh_change_url_nginx_config
|
|
|
|
|
2023-09-27 19:21:58 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC MODIFICATIONS
|
|
|
|
#=================================================
|
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
|
2023-09-27 19:21:58 +02:00
|
|
|
ynh_add_config --template=seahub_settings.py --destination=$install_dir/conf/seahub_settings.py
|
|
|
|
ynh_add_config --template=ccnet.conf --destination=$install_dir/conf/ccnet.conf
|
|
|
|
ynh_add_config --template=gunicorn.conf.py --destination=$install_dir/conf/gunicorn.conf.py
|
|
|
|
ynh_add_config --template=seafdav.conf --destination=$install_dir/conf/seafdav.conf
|
2023-08-08 23:21:11 +02:00
|
|
|
|
2023-10-04 07:54:21 +02:00
|
|
|
# Update permissions
|
|
|
|
ynh_permission_url --permission=file_server --url=$domain/seafhttp
|
|
|
|
ynh_permission_url --permission=webdav --url=$domain/seafdav
|
|
|
|
|
2023-09-27 19:21:58 +02:00
|
|
|
# Clean url in config in DB
|
|
|
|
clean_url_in_db_config
|
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
|