commit ac78252135f2c65c6bfb41d32f6d8f465084dced parent 199c6c38e1571897206ba77d416d81ae02dc3539 Author: Fred Großkopf <fred@kuandu.systems> Date: Wed, 29 Apr 2026 11:03:35 +0200 Adds unstinall.sh Diffstat:
| A | uninstall.sh | | | 57 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 57 insertions(+), 0 deletions(-)
diff --git a/uninstall.sh b/uninstall.sh @@ -0,0 +1,57 @@ +#!/bin/sh +set -e + +log() { printf 'info: %s\n' "$1"; } + +# Constants (Must match install.sh) +BIN_DIR="/usr/local/sbin" +ETC_DIR="/etc" +VAR_DIR="/var/gitpages" +LOG_DIR="/var/log/gitpages" + +remove_cron() { + if id "gitpages" >/dev/null 2>&1; then + crontab -u gitpages -r 2>/dev/null || true + log "Removed crontab for gitpages user." + fi +} + +remove_files() { + rm -f "$ETC_DIR/gitpages.conf" + rm -f "$BIN_DIR/gitpages.sh" "$BIN_DIR/gitpages-init.sh" \ + "$BIN_DIR/gitpages-mirror-git.sh" "$BIN_DIR/gitpages-update.sh" + log "Removed configuration and binaries." +} + +remove_logrotation() { + if [ -f "$ETC_DIR/newsyslog.conf" ]; then + # Use a different delimiter for sed since the path contains slashes + sed -i "\%$LOG_DIR/updates.log%d" "$ETC_DIR/newsyslog.conf" + log "Removed log rotation entry." + fi +} + +remove_user_and_data() { + if id "gitpages" >/dev/null 2>&1; then + userdel gitpages + log "Removed gitpages user." + fi + + if [ -d "$VAR_DIR" ]; then + rm -rf "$VAR_DIR" + log "Removed service directory $VAR_DIR." + fi +} + +main() { + log "Starting uninstallation of gitpages..." + + remove_cron + remove_files + remove_logrotation + remove_user_and_data + + log "Uninstallation complete." +} + +main "$@"