2005-11-30 04:39:17 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2006-11-27 20:25:26 +01:00
|
|
|
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
|
2006-11-22 16:21:21 +01:00
|
|
|
SUPER_FILE=/etc/super.tab
|
2006-11-27 20:25:26 +01:00
|
|
|
MNT_DIR=/var/cache/cryptobox-server/mnt
|
|
|
|
SETTINGS_DIR=/var/cache/cryptobox-server/settings
|
2006-11-22 16:21:21 +01:00
|
|
|
|
|
|
|
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"
|
2006-12-11 15:16:10 +01:00
|
|
|
sed -i /^CryptoBoxRootActions/d "$SUPER_FILE"
|
2006-11-22 16:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-24 12:03:20 +01:00
|
|
|
umount_all()
|
2006-11-22 16:21:21 +01:00
|
|
|
{
|
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-22 16:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-24 12:03:20 +01:00
|
|
|
remove_stuff()
|
2006-11-22 16:21:21 +01:00
|
|
|
{
|
2006-11-24 12:03:20 +01:00
|
|
|
test -e "$LOG_FILE" && rm "$LOG_FILE"
|
|
|
|
test -e "$WEBLOG_FILE" && rm "$WEBLOG_FILE"
|
2006-11-22 16:21:21 +01:00
|
|
|
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-22 16:21:21 +01:00
|
|
|
}
|
|
|
|
|
2006-11-24 12:03:20 +01:00
|
|
|
|
2006-11-22 16:21:21 +01:00
|
|
|
################## main ###################
|
|
|
|
|
2006-11-24 12:03:20 +01:00
|
|
|
# umount everything that is still active
|
|
|
|
umount_all
|
|
|
|
|
|
|
|
# remove the user
|
2006-11-27 20:25:26 +01:00
|
|
|
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
|
2006-05-15 11:41:00 +02:00
|
|
|
then echo "Removing user 'cryptobox' ..."
|
2006-11-27 20:25:26 +01:00
|
|
|
userdel -r "$CRYPTOBOX_USER"
|
2006-05-15 11:41:00 +02:00
|
|
|
fi
|
2005-12-12 23:32:22 +01:00
|
|
|
|
2006-11-24 12:03:20 +01:00
|
|
|
# always remove the lines from the 'super' configuration file
|
2006-11-22 16:21:21 +01:00
|
|
|
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#
|
2006-05-30 11:08:35 +02:00
|
|
|
|
2005-12-01 19:22:05 +01:00
|
|
|
# return without error
|
|
|
|
true
|