seafile_ynh/scripts/remove

65 lines
1.7 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"
#=================================================
# STANDARD REMOVE
#=================================================
ynh_script_progression "Stoping services..."
# Stop all services
ynh_systemctl --service=seafile --action=stop
ynh_systemctl --service=seahub --action=stop
# Force to kill all process in case of a process is not stoped cleanly
pkill -f seafile-controller || true
pkill -f seaf-server || true
pkill -f ccnet-server || true
pkill -f seahub || true
ynh_script_progression "Removing code..."
ynh_safe_rm /var/www/"$app"
ynh_safe_rm /opt/yunohost/"$app"
# Remove databases
ynh_script_progression "Removing databases..."
db_helper=ynh_"mysql"_remove_db
$db_helper --db_name ccnetdb --db_user seafile
$db_helper --db_name seahubdb --db_user seafile
# Remove systemd service
ynh_script_progression "Removing systemd units..."
ynh_config_remove_systemdseafile
ynh_config_remove_systemdseahub
# Remove nginx config
ynh_script_progression "Removing nginx configuration..."
ynh_config_remove_nginx
# Remove logrotate
ynh_config_remove_logrotate
# Remove the dedicated fail2ban config
ynh_script_progression "Removing fail2ban configuration..."
ynh_config_remove_fail2ban
ynh_script_progression "Removing seafile service..."
yunohost service remove seafile
yunohost service remove seahub
ynh_script_progression "Removal of $app completed"
sleep 1