openwrt-packages/net/knot/files/knotd.init

40 lines
755 B
Bash

#!/bin/sh /etc/rc.common
#
# Copyright (C) 2014-2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
#
# This is free software, licensed under the GNU General Public License v2.
START=50
USE_PROCD=1
PROG="/usr/sbin/knotd"
CONFFILE="/etc/knot/knot.conf"
USER="knot"
USERID="5353"
RUNDIR="/var/run/knot"
STORAGE="/var/lib/knot"
fix_perms() {
user_exists $USER $USERID || user_add $USER $USERID
group_exists $USER $USERID || group_add $USER $USERID
for dir in $RUNDIR $STORAGE; do
test -e $dir || {
mkdir -p $dir
chgrp $USER $dir
chmod g+w $dir
}
chgrp $USER $CONFFILE
chmod g+r $CONFFILE
done
}
start_service() {
fix_perms
procd_open_instance
procd_set_param command $PROG -c $CONFFILE
procd_set_param respawn
procd_close_instance
}