#!/bin/sh LOG_FILE=/var/log/cryptobox.log WEBLOG_FILE=/var/log/cryptoboxwebserver.log PID_DIR=/var/run/cryptobox CRYPTOBOX_USER=cryptobox USER_HOME=/var/cache/cryptobox SUPER_FILE=/etc/super.tab create_user_home() { # if the user already exists -> do nothing getent passwd "$CRYPTOBOX_USER" 2>/dev/null >/dev/null && return 0 # create cryptobox user echo "Creating new user '$CRYPTOBOX_USER' ..." adduser --system --group --groups disk --home "$USER_HOME" cryptobox mkdir -p "$USER_HOME/mnt" mkdir -p "$USER_HOME/settings" chown -R ${CRYPTOBOX_USER}: "$USER_HOME" # only members of the cryptobox group may access the user directory chmod 750 "$USER_HOME" } create_log_file() { # 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" } 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!" echo >>"$SUPER_FILE" "CryptoBoxRootActions /usr/lib/cryptobox/CryptoBoxRootActions.py $CRYPTOBOX_USER" } create_pid_dir() { test ! -e "$PID_DIR" && mkdir -p "$PID_DIR" && chown "$CRYPTOBOX_USER" "$PID_DIR" } #################### main ###################### case "$1" in configure) create_user_home create_log_file create_pid_dir 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 #DEBHELPER# exit 0