diff options
| author | Ahmed AbdelHalim <[email protected]> | 2025-09-09 21:46:50 +0200 |
|---|---|---|
| committer | Ahmed AbdelHalim <[email protected]> | 2025-09-09 21:59:52 +0200 |
| commit | e3aed3022ff51a5f3b05cc5b8a5076199075c6f1 (patch) | |
| tree | cb418878a4f7c000b3c4784c93bc6b8d8faace16 /deployment/uninstall.sh | |
| parent | 81ca75de8ea7b010203a2036fc02779da8fdadfd (diff) | |
Add install/uninstall scripts
Diffstat (limited to 'deployment/uninstall.sh')
| -rwxr-xr-x | deployment/uninstall.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/deployment/uninstall.sh b/deployment/uninstall.sh new file mode 100755 index 0000000..a3a1b0e --- /dev/null +++ b/deployment/uninstall.sh @@ -0,0 +1,62 @@ +#!/bin/bash +set -euo pipefail + +abort() { + printf "\033[31m%s\033[0m\n" "$@" >&2 + exit 1 +} + +log() { + printf "%s\n" "$@" +} + +ensure_sudo() { + if [ "$EUID" -ne 0 ]; then + abort "Must be run as sudo" + fi +} + +uninstall_systemd_configurations() { + log "Removing wg-portal systemd configurations" + systemctl stop wg-portal 2>/dev/null || true + systemctl disable wg-portal 2>/dev/null || true + rm -f /etc/systemd/system/wg-portal.service + systemctl daemon-reload +} + +remove_directories() { + log "Removing wg-portal directories..." + rm -rf /etc/wg-portal +} + +remove_sudo_configurations() { + log "Removing wg-portal sudo permissions..." + rm -f /etc/sudoers.d/wg-portal +} + +remove_acl_permissions() { + if [ -d /etc/wireguard ]; then + log "Removing wg-portal ACL permissions from /etc/wireguard..." + setfacl -R -x g:wg-portal /etc/wireguard 2>/dev/null || true + fi +} + +remove_system_user() { + log "Removing wg-portal system user and group..." + userdel wg-portal 2>/dev/null || true + groupdel wg-portal 2>/dev/null || true +} + +show_completion_message() { + log "" + log "wg-portal uninstalled successfully!" +} + +# Main +ensure_sudo +uninstall_systemd_configurations +remove_directories +remove_sudo_configurations +remove_acl_permissions +remove_system_user +show_completion_message |
