yunohost-gitea_ynh/scripts/remove

65 lines
1.9 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# Load common variables and helpers
source ./experimental_helper.sh
source ./_common.sh
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
ynh_script_progression --message="Loading installation settings..."
# Retrieve domain from app settings
domain=$(ynh_app_setting_get --app $app --key domain)
#=================================================
# STANDARD REMOVE
#=================================================
# Stop gitea
ynh_script_progression --message="Stoping services..."
systemctl stop "$app".service
# Drop MySQL database and user
ynh_script_progression --message="Removing databases..."
ynh_mysql_drop_db "$dbname" 2>/dev/null
ynh_mysql_drop_user "$db_user" 2>/dev/null
# Delete app directory and configurations
ynh_script_progression --message="Removing code..."
ynh_secure_remove --file="$final_path"
ynh_script_progression --message="Removing logs..."
ynh_secure_remove --file="/var/log/$app"
# Remove the app-specific logrotate config
ynh_remove_logrotate
# Remove nginx config
ynh_script_progression --message="Removing nginx configuration..."
ynh_remove_nginx_config
# Remove gitea user and data
ynh_script_progression --message="Removing the dedicated system user..."
ynh_system_user_delete $app
# Remove init script
ynh_script_progression --message="Removing systemd units..."
ynh_remove_systemd_config
# Remove monitor
ynh_script_progression --message="Removing gitea service..."
yunohost service remove "$app"
# Remove fail2ban config
ynh_script_progression --message="Removing fail2ban configuration..."
ynh_remove_fail2ban_config
ynh_print_info --message="Due of the backup core only feature the data directory in '$datadir' was not removed. It need to be removed manually to purge app user data."
ynh_script_progression --message="Removal of $app completed" --last
sleep 1