1
0
mirror of https://github.com/gophernicus/gophernicus.git synced 2024-06-30 06:45:24 +00:00
gophernicus/debian/postinst
fosslinux 57e0f9a827 version 3.0 release
* release version 3.0
* change appropriate documentation
* change debian packaging for 3.0
2019-07-09 17:55:26 +10:00

47 lines
1.1 KiB
Bash

#!/bin/sh
#DEBHELPER#
# Source debconf library.
. /usr/share/debconf/confmodule
# Configuration
HOSTNAME="`hostname`"
ROOT=/var/gopher
PACKAGE=gophernicus
LOGDIR=/var/log/$PACKAGE
LIBDIR=/usr/lib/$PACKAGE
BINARY=gophernicus
DEFAULT=/etc/default/$PACKAGE
USER=nobody
# Get hostname from debconf
db_get gophernicus/fqdn
if [ "$RET" ]; then
HOSTNAME="`echo $RET | tr -cd 'A-Za-z0-9.-'`"
fi
# Configure gophernicus
if [ "$1" = "configure" ]; then
if [ ! -f "$ROOT/gophermap" ]; then
cp $LIBDIR/gophermap $ROOT/
fi
chown $USER.adm $LOGDIR
chmod 0750 $LOGDIR
sed -i -e "s|-h [^ ]* |-h $HOSTNAME |" $DEFAULT
sed -i -e "s|__PACKAGE__|$PACKAGE|g" $DEFAULT
sed -i -e "s|__LOGDIR__|$LOGDIR|g" $DEFAULT
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
fi
fi