65 lines
1.5 KiB
Text
65 lines
1.5 KiB
Text
|
#!/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"
|
||
|
}
|
||
|
|
||
|
|
||
|
umount_all()
|
||
|
{
|
||
|
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
|
||
|
}
|
||
|
|
||
|
|
||
|
remove_stuff()
|
||
|
{
|
||
|
test -e "$LOG_FILE" && rm "$LOG_FILE"
|
||
|
test -e "$WEBLOG_FILE" && rm "$WEBLOG_FILE"
|
||
|
test -e "$PID_DIR" && rm -r "$PID_DIR"
|
||
|
test -e "$SETTINGS_DIR" && rm -r "$SETTINGS_DIR"
|
||
|
}
|
||
|
|
||
|
|
||
|
################## main ###################
|
||
|
|
||
|
# 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
|
||
|
|
||
|
# always remove the lines from the 'super' configuration file
|
||
|
remove_super_lines
|
||
|
|
||
|
# remove obsolete files
|
||
|
test "$1" = "purge" && remove_stuff
|
||
|
|
||
|
#DEBHELPER#
|
||
|
|
||
|
# return without error
|
||
|
true
|