2014-01-25 04:21:40 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
# Source debconf library.
|
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
|
|
|
|
# Configuration
|
2020-02-05 02:27:27 -05:00
|
|
|
HOSTNAME="$(hostname)"
|
2014-01-25 04:21:40 -05:00
|
|
|
ROOT=/var/gopher
|
|
|
|
PACKAGE=gophernicus
|
|
|
|
LOGDIR=/var/log/$PACKAGE
|
|
|
|
LIBDIR=/usr/lib/$PACKAGE
|
2019-06-14 20:31:02 -04:00
|
|
|
BINARY=gophernicus
|
2016-11-13 05:54:53 -05:00
|
|
|
DEFAULT=/etc/default/$PACKAGE
|
2014-01-25 04:21:40 -05:00
|
|
|
USER=nobody
|
|
|
|
|
|
|
|
# Get hostname from debconf
|
|
|
|
db_get gophernicus/fqdn
|
|
|
|
if [ "$RET" ]; then
|
2020-02-05 02:27:27 -05:00
|
|
|
HOSTNAME="$(echo $RET | tr -cd 'A-Za-z0-9.-')"
|
2014-01-25 04:21:40 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Configure gophernicus
|
|
|
|
if [ "$1" = "configure" ]; then
|
|
|
|
if [ ! -f "$ROOT/gophermap" ]; then
|
2019-10-26 17:34:11 -04:00
|
|
|
cp $LIBDIR/gophermap.sample $ROOT/gophermap
|
2014-01-25 04:21:40 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
chown $USER.adm $LOGDIR
|
|
|
|
chmod 0750 $LOGDIR
|
|
|
|
|
2016-11-13 05:54:53 -05:00
|
|
|
sed -i -e "s|-h [^ ]* |-h $HOSTNAME |" $DEFAULT
|
|
|
|
sed -i -e "s|__PACKAGE__|$PACKAGE|g" $DEFAULT
|
|
|
|
sed -i -e "s|__LOGDIR__|$LOGDIR|g" $DEFAULT
|
|
|
|
|
2016-11-13 07:51:06 -05:00
|
|
|
if [ -x /usr/bin/deb-systemd-helper -a -d /run/systemd/system ]; then
|
|
|
|
/usr/bin/deb-systemd-helper enable gophernicus.socket
|
|
|
|
/usr/bin/deb-systemd-invoke start gophernicus.socket
|
|
|
|
else
|
|
|
|
if [ -f /etc/inetd.conf -a -x /usr/sbin/update-inetd ]; then
|
|
|
|
/usr/sbin/update-inetd --add "gopher\t\tstream\ttcp\tnowait\t$USER\t/usr/sbin/$BINARY\t$BINARY -h $HOSTNAME -l $LOGDIR/server.log -f /usr/lib/$PACKAGE/filters"
|
|
|
|
fi
|
2016-11-13 05:54:53 -05:00
|
|
|
fi
|
2014-01-25 04:21:40 -05:00
|
|
|
fi
|
|
|
|
|