postinst is in sbnc 1.3.9-3.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | #!/bin/sh
set -e
. /usr/share/debconf/confmodule
do_createconfig() {
FIRST_START=0
VALID_CONFIG=1
db_get sbnc/start_daemon
DAEMON_START=0
if [ "$RET" = "true" ] ; then
DAEMON_START=1
fi
db_get sbnc/host
HOST=$RET
if [ "X$HOST" = "X" ] ; then
HOST="0.0.0.0"
fi
db_get sbnc/port
PORT=$RET
if [ "X$PORT" = "X" ] ; then
PORT="9000"
fi
if [ ! -f /etc/sbnc/sbnc.conf ] ; then
FIRST_START=1
db_get sbnc/username
USERNAME=$RET
if [ "X$USERNAME" = "X" ] ; then
VALID_CONFIG=0
fi
db_get sbnc/password
PASSWORD=$RET
if [ "X$PASSWORD" = "X" ] ; then
VALID_CONFIG=0
fi
if [ "$VALID_CONFIG" = "1" ] ; then
SALT=`pwgen -s 50 1`
MD5_HEX=`echo -n "${PASSWORD}${SALT}" | md5sum - | awk '{print $1}'`
PASSWORD="${SALT}\$${MD5_HEX}"
umask 077
mkdir -p /etc/sbnc/users
umask 177
echo "user.password=${PASSWORD}" > /etc/sbnc/users/${USERNAME}.conf
echo "user.admin=1" >> /etc/sbnc/users/${USERNAME}.conf
db_set sbnc/password ""
fi
fi
if [ "$VALID_CONFIG" = "1" ] ; then
sed "s/=[0-9]/=$DAEMON_START/" -i /etc/default/sbnc
umask 177
if [ $FIRST_START = "1" ] ; then
echo "system.users=${USERNAME}" > /etc/sbnc/sbnc.conf
echo "system.port=${PORT}" >> /etc/sbnc/sbnc.conf
echo "system.ip=${HOST}" >> /etc/sbnc/sbnc.conf
echo "system.md5=1" >> /etc/sbnc/sbnc.conf
else
sed "s/system.port=.*/system.port=${PORT}/" -i /etc/sbnc/sbnc.conf
sed "s/system.ip=.*/system.ip=${HOST}/" -i /etc/sbnc/sbnc.conf
fi
chown sbnc:sbnc -R /etc/sbnc/users
chown sbnc:sbnc /etc/sbnc/sbnc.conf
fi
}
do_systeminstall() {
adduser --system --group --home /var/lib/sbnc --quiet sbnc || true
chown sbnc:adm /var/log/sbnc
chmod 0740 /var/log/sbnc
chown sbnc:sbnc /var/lib/sbnc
chmod 0775 /var/lib/sbnc
chown sbnc:sbnc /etc/sbnc
}
do_migrateuserconf () {
if [ -f /var/lib/sbnc/users/*.conf ] ; then
mv /var/lib/sbnc/users/ /etc/sbnc/
fi
}
case "$1" in
configure)
do_migrateuserconf;
do_systeminstall;
do_createconfig;
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# Automatically added by dh_installinit
if [ -x "/etc/init.d/sbnc" ] || [ -e "/etc/init/sbnc.conf" ]; then
if [ ! -e "/etc/init/sbnc.conf" ]; then
update-rc.d sbnc defaults 91 >/dev/null
fi
invoke-rc.d sbnc start || exit $?
fi
# End automatically added section
exit 0
|