seafile_ynh/scripts/change_url

61 lines
1.9 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
seafile_version="$(ynh_app_upstream_version)"
seafile_code="$install_dir/seafile_image/opt/seafile/seafile-server-$seafile_version"
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
ynh_config_change_url_nginx
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
ynh_script_progression "Stoping services..."
# Stop service before any change
ynh_systemctl --service=seafile --action=stop
ynh_systemctl --service=seahub --action=stop
sleep 2
pkill -f seafile-controller || true
pkill -f seaf-server || true
pkill -f ccnet-server || true
pkill -f seahub || true
ynh_script_progression "Updating seafile configuration..."
# Update Seafile Config
ynh_config_add --jinja --template=seahub_settings.py --destination="$install_dir"/conf/seahub_settings.py
ynh_config_add --template=ccnet.conf --destination="$install_dir"/conf/ccnet.conf
ynh_config_add --template=gunicorn.conf.py --destination="$install_dir"/conf/gunicorn.conf.py
ynh_config_add --template=seafdav.conf --destination="$install_dir"/conf/seafdav.conf
# Update permissions
ynh_permission_url --permission=file_server --url="$domain"/seafhttp
ynh_permission_url --permission=webdav --url="$domain"/seafdav
# Clean url in config in DB
clean_url_in_db_config
# Avoid the current effect
sleep 2
# Reload services
ynh_script_progression "Starting services..."
ynh_systemctl --service=seafile -l "spawned seaf-server, pid " -p /var/log/seafile/controller.log
ynh_systemctl --service=seahub -l "Started Seafile hub." -p "systemd"
sleep 2
ynh_script_progression "Change of URL completed for $app" --time=