1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#! /bin/bash
set -e
CHROOT=/var/lib/sshproxy
[ ! -d $CHROOT ] && mkdir $CHROOT
# Check if sshproxy:sshproxy exists and create it otherwise
chgrp sshproxy $CHROOT 2> /dev/null || \
addgroup --quiet --system sshproxy
chown sshproxy $CHROOT 2> /dev/null || \
adduser --system --home $CHROOT --no-create-home \
--disabled-password --quiet --ingroup sshproxy sshproxy
chown sshproxy:sshproxy $CHROOT
chmod 0750 $CHROOT
[ ! -d $CHROOT/log ] && mkdir $CHROOT/log
chown sshproxy:sshproxy $CHROOT/log
chmod 0750 $CHROOT/log
[ ! -d /etc/sshproxy ] && mkdir /etc/sshproxy
chown sshproxy:sshproxy /etc/sshproxy
chmod 0700 /etc/sshproxy
# Handle configuration file with ucf
case "$1" in
configure)
CONFFILE=/etc/sshproxy/sshproxy.ini
touch $CONFFILE.ucftmp
chmod 0600 $CONFFILE.ucftmp
# Get the current key if any
[ -f $CONFFILE ] && \
secret=$(sed -n "s+^secret = \(.*\)$+\1+p" $CONFFILE)
[ -z "$secret" ] && \
secret="${RANDOM}${RANDOM}${RANDOM}${RANDOM}"
cat /usr/share/doc/sshproxy/sshproxy.ini | \
sed -e "s/%BLOWFISH_SECRET%/${secret}/g" \
-e "s/%HOSTNAME%/$(hostname)/g" \
-e "s+plugin_dir = /usr/lib/sshproxy+plugin_dir = /usr/share/sshproxy+" >> $CONFFILE.ucftmp
ucf --debconf-ok $CONFFILE.ucftmp $CONFFILE
chown sshproxy:sshproxy $CONFFILE
rm -f $CONFFILE.ucftmp
;;
esac
#DEBHELPER#
|