cryptonas/debian/cryptobox-server.postrm

65 lines
1.5 KiB
Text
Raw Normal View History

#!/bin/sh
set -u
CRYPTOBOX_USER=cryptobox
LOG_FILE=/var/log/cryptobox-server/cryptobox.log
WEBLOG_FILE=/var/log/cryptobox-server/webserver.log
PID_DIR=/var/run/cryptobox-server
SUPER_FILE=/etc/super.tab
MNT_DIR=/var/cache/cryptobox-server/mnt
SETTINGS_DIR=/var/cache/cryptobox-server/settings
remove_super_lines()
{
## do nothing, if there is no CryptoBox line
grep -q "CRYPTOBOX_MARKER" "$SUPER_FILE" || return 0
sed -i /CRYPTOBOX_MARKER/d "$SUPER_FILE"
sed -i /^CryptoBoxRootActions/d "$SUPER_FILE"
}
2006-11-24 12:03:20 +01:00
umount_all()
{
2006-11-24 12:03:20 +01:00
test -d "$SETTINGS_DIR" && mountpoint -q "$SETTINGS_DIR" && umount "$SETTINGS_DIR"
test -d "$MNT_DIR" && ls "$MNT_DIR" | while read dir
do if test -d "$MNT_DIR/$dir"
then mountpoint -q "$MNT_DIR/$dir" && umount "$MNT_DIR/$dir"
rm -r "$MNT_DIR/$dir"
fi
done
}
2006-11-24 12:03:20 +01:00
remove_stuff()
{
2006-11-24 12:03:20 +01:00
test -e "$LOG_FILE" && rm "$LOG_FILE"
test -e "$WEBLOG_FILE" && rm "$WEBLOG_FILE"
test -e "$PID_DIR" && rm -r "$PID_DIR"
2006-11-24 12:03:20 +01:00
test -e "$SETTINGS_DIR" && rm -r "$SETTINGS_DIR"
}
2006-11-24 12:03:20 +01:00
################## main ###################
2006-11-24 12:03:20 +01:00
# umount everything that is still active
umount_all
# remove the user
if test "$1" = "purge" && getent passwd "$CRYPTOBOX_USER" 2>/dev/null >/dev/null \
&& test "$(getent passwd $CRYPTOBOX_USER | cut -d : -f 6)" = /var/cache/cryptobox-server
then echo "Removing user 'cryptobox' ..."
userdel -r "$CRYPTOBOX_USER"
fi
2006-11-24 12:03:20 +01:00
# always remove the lines from the 'super' configuration file
remove_super_lines
2006-11-24 12:03:20 +01:00
# remove obsolete files
test "$1" = "purge" && remove_stuff
2006-05-30 21:00:34 +02:00
#DEBHELPER#
2005-12-01 19:22:05 +01:00
# return without error
true