#!/bin/bash # Load common variables and helpers source ./_common.sh # Set app specific variables app=${APPNAME:-gogs} dbname=$app dbuser=$app # Source app helpers source /usr/share/yunohost/helpers # Stop gogs sudo systemctl stop "$app".service # Drop MySQL database and user ynh_mysql_drop_db "$dbname" 2>/dev/null || true ynh_mysql_drop_user "$dbuser" 2>/dev/null || true # Retrieve domain from app settings domain=$(ynh_app_setting_get "$app" domain) # Delete app directory and configurations sudo rm -rf "/opt/${app}" [[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf" sudo rm -rf /var/log/"$app" sudo rm -f /etc/logrotate.d/"$app" # Remove gogs user and data sudo userdel -r "$app" # Remove init script sudo systemctl disable "$app".service sudo rm -f /etc/systemd/system/"$app".service sudo systemctl daemon-reload # Remove monitor sudo yunohost service remove "$app" # Reload services sudo systemctl restart rsyslog.service || true sudo systemctl reload nginx.service || true