1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/gogs_ynh.git synced 2024-09-03 20:36:23 +02:00
gogs_ynh/scripts/remove
Moul fa69e63bda [enh] linter fixes:
- remove: add 'set -u'.
- install: retrieve arguments from env var.
- manifest: update descriptions.
- _common.sh: use 'ynh_die' helper.
2017-04-05 21:12:30 +02:00

46 lines
1 KiB
Bash

#!/bin/bash
# Exit and treat unset variables as an error
set -u
# 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