DAEMON_ARGS="-c /etc/yubikeyd.conf"
PIDFILE=/var/run/yubikeyd/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
+U=$(grep ^user= /etc/yubikeyd.conf| cut -d= -f 2)
+G=$(grep ^group= /etc/yubikeyd.conf| cut -d= -f 2)
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
#
do_start()
{
- # Return
- # 0 if daemon has been started
- # 1 if daemon was already running
- # 2 if daemon could not be started
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
- $DAEMON_ARGS \
- || return 2
+
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ mkdir -p "$(dirname $PIDFILE)"
+ chown "$U:$G" "$(dirname $PIDFILE)"
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
}
#