cryptonas/DEBIAN/postinst

38 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# read the default setting file, if it exists
[ -e /etc/default/cryptobox ] && . /etc/default/cryptobox
# set CONF_FILE to default value, if not configured in /etc/default/cryptobox
CONF_FILE=${CONF_FILE:-/etc/cryptobox/cryptobox.conf}
# parse config file
if [ -e "$CONF_FILE" ]
then . "$CONF_FILE"
# create mount and config directories with appropriate permissions
[ ! -e "$MNT_PARENT" ] && mkdir -p "$MNT_PARENT" && \
chown "$WEB_USER" "$MNT_PARENT" && chmod 700 "$MNT_PARENT"
[ ! -e "$CONFIG_DIR" ] && mkdir -p "$CONFIG_DIR" && \
chown "$WEB_USER" "$CONFIG_DIR" && chmod 700 "$CONFIG_DIR"
[ ! -e "$LOG_FILE" ] && touch "$LOG_FILE" && chown "$WEB_USER" "$LOG_FILE"
fi
# add the cryptobox startup script to /etc/rc?.d
update-rc.d cryptobox defaults 98
invoke-rc.d cryptobox restart
if grep -q "cryptobox package.*HEADER" /etc/sudoers
then true
else echo "Adding a new (disabled) entry to /etc/sudoers"
cat >>/etc/sudoers <<-EOF
######### Automatically inserted by cryptobox package - do not remove - HEADER ######
# read /usr/share/doc/cryptobox/SECURITY carefully before enabling the following line
#www-data ALL=NOPASSWD:/usr/lib/cryptobox/cbox-root-actions.sh
######### Automatically inserted by cryptobox package - do not remove - FOOTER ######
EOF
fi
true