2005-11-30 04:39:17 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2006-11-23 21:52:30 +01:00
|
|
|
LOG_FILE=/var/log/cryptobox/cryptobox.log
|
|
|
|
WEBLOG_FILE=/var/log/cryptobox/webserver.log
|
2006-11-22 16:21:21 +01:00
|
|
|
PID_DIR=/var/run/cryptobox
|
2006-11-10 10:05:14 +01:00
|
|
|
CRYPTOBOX_USER=cryptobox
|
2006-11-22 16:21:21 +01:00
|
|
|
USER_HOME=/var/cache/cryptobox
|
|
|
|
SUPER_FILE=/etc/super.tab
|
2006-11-24 12:03:20 +01:00
|
|
|
ADDITIONAL_GROUP=disk
|
2005-12-13 03:27:33 +01:00
|
|
|
|
2006-11-23 21:52:30 +01:00
|
|
|
# check the current cryptobox user - maybe it was changed
|
|
|
|
if test -r /etc/default/cryptobox
|
|
|
|
then runas_user=$(grep "^RUNAS=" /etc/default/cryptobox | cut -d "=" -f 2)
|
|
|
|
test -n "$runas_user" && CRYPTOBOX_USER=$runas_user
|
|
|
|
fi
|
|
|
|
|
2005-12-13 03:27:33 +01:00
|
|
|
|
2006-11-22 16:21:21 +01:00
|
|
|
create_user_home()
|
|
|
|
{
|
|
|
|
# if the user already exists -> do nothing
|
|
|
|
getent passwd "$CRYPTOBOX_USER" 2>/dev/null >/dev/null && return 0
|
|
|
|
# create cryptobox user
|
2006-05-15 11:41:00 +02:00
|
|
|
echo "Creating new user '$CRYPTOBOX_USER' ..."
|
2006-11-24 12:03:20 +01:00
|
|
|
adduser --system --group --home "$USER_HOME" "$CRYPTOBOX_USER"
|
|
|
|
adduser "$CRYPTOBOX_USER" "$ADDITIONAL_GROUP"
|
2006-11-22 16:21:21 +01:00
|
|
|
mkdir -p "$USER_HOME/mnt"
|
|
|
|
mkdir -p "$USER_HOME/settings"
|
2006-05-15 11:41:00 +02:00
|
|
|
chown -R ${CRYPTOBOX_USER}: "$USER_HOME"
|
|
|
|
# only members of the cryptobox group may access the user directory
|
|
|
|
chmod 750 "$USER_HOME"
|
2006-11-22 16:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
create_add_super_permission()
|
|
|
|
{
|
|
|
|
## this will add some lines to the configuration file of 'super'
|
|
|
|
## do nothing, if there is already a CryptoBox line
|
|
|
|
grep -q "CRYPTOBOX_MARKER" "$SUPER_FILE" && return 0
|
|
|
|
echo >>"$SUPER_FILE" "## CRYPTOBOX_MARKER - please do not remove!"
|
2006-11-23 21:52:30 +01:00
|
|
|
echo >>"$SUPER_FILE" "CryptoBoxRootActions /usr/sbin/CryptoBoxRootActions $CRYPTOBOX_USER"
|
2006-11-22 16:21:21 +01:00
|
|
|
}
|
|
|
|
|
2006-11-23 21:52:30 +01:00
|
|
|
create_dirs_and_files()
|
2006-11-22 16:21:21 +01:00
|
|
|
{
|
2006-11-23 21:52:30 +01:00
|
|
|
# pid file
|
|
|
|
test ! -e "$PID_DIR" && mkdir -p "$PID_DIR"
|
|
|
|
chown "$CRYPTOBOX_USER" "$PID_DIR"
|
|
|
|
# create config directories with appropriate permissions
|
|
|
|
test ! -e "$LOG_FILE" && mkdir -p "$(dirname $LOG_FILE)" && touch "$LOG_FILE"
|
|
|
|
chown "$CRYPTOBOX_USER" "$LOG_FILE"
|
|
|
|
test ! -e "$WEBLOG_FILE" && mkdir -p "$(dirname $WEBLOG_FILE)" && touch "$WEBLOG_FILE"
|
|
|
|
chown "$CRYPTOBOX_USER" "$WEBLOG_FILE"
|
2006-11-22 16:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#################### main ######################
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
|
|
|
create_user_home
|
2006-11-23 21:52:30 +01:00
|
|
|
create_dirs_and_files
|
2006-11-22 16:21:21 +01:00
|
|
|
create_add_super_permission
|
|
|
|
# continue at the end
|
|
|
|
;;
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
# nothing to be done
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2006-05-15 11:41:00 +02:00
|
|
|
|
2006-05-30 21:00:34 +02:00
|
|
|
#DEBHELPER#
|
2005-12-01 20:20:36 +01:00
|
|
|
|
2006-11-22 16:21:21 +01:00
|
|
|
exit 0
|
2006-05-15 11:41:00 +02:00
|
|
|
|