summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDiego Santa Cruz <Diego.SantaCruz@spinetix.com>2020-09-10 12:50:11 +0200
committerTobias Klauser <tobias.klauser@gmail.com>2020-09-10 13:01:25 +0200
commitc5ba2c5d06f3786b398df7c3e169c1beba2a1f68 (patch)
tree03b493cc058febc9184a197c974856c6e17b095f /etc
parentf0f8d391c588505ac01d7879681d59a42c3a8cee (diff)
Add a simple init script
Add a working init script as a base for distributions. Fixes #2
Diffstat (limited to 'etc')
-rwxr-xr-xetc/llmnrd-init-script172
1 files changed, 172 insertions, 0 deletions
diff --git a/etc/llmnrd-init-script b/etc/llmnrd-init-script
new file mode 100755
index 0000000..82ecc4e
--- /dev/null
+++ b/etc/llmnrd-init-script
@@ -0,0 +1,172 @@
+#!/bin/sh
+#
+# License: Copyright 2020 SpinetiX. This file is licensed
+# under the terms of the GNU General Public License version 2.
+# This program is licensed "as is" without any warranty of any
+# kind, whether express or implied.
+#
+# Copyright 1999-2003 MontaVista Software, Inc.
+# Copyright 2002, 2003, 2004 Sony Corporation
+# Copyright 2002, 2003, 2004 Matsushita Electric Industrial Co., Ltd.
+#
+### BEGIN INIT INFO
+# Required-Start:
+# Required-Stop:
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 5
+# Default-Stop:
+# Short-Description: Starting/stopping llmnrd
+# Description: Starting/stopping llmnrd
+### END INIT INFO
+
+# Init script information
+NAME=llmnrd
+DESC="llmnrd"
+
+# Individual Daemon information
+DAEMON=/usr/sbin/llmnrd
+ARGS="-6 -d -s"
+BASENAME=llmnrd
+
+# Load init script configuration
+DISABLE_LLMNRD=
+[ -f /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Source the init script functions
+. /etc/init.d/functions
+
+# Verify daemons are installed
+if [ ! -x $DAEMON -a "$1" != "stop" ]; then
+ echo -n "Not starting $DESC $NAME, $DAEMON not installed"
+ echo
+ exit 0
+fi
+
+if [ -n "$DISABLE_LLMNRD" -a "$1" != "stop" ]; then
+ echo -n "Not starting $DESC $NAME, disabled via /etc/default/$NAME"
+ echo
+ exit 0
+fi
+
+start() {
+ local RET
+
+ echo -n "Starting $DESC: "
+
+ echo -n "$NAME "
+
+ start-stop-daemon --start -u llmnrd -n llmnrd -p /run/llmnrd/pid -c llmnrd -x $DAEMON -- $ARGS
+ RET=$?
+ if [ $RET -eq 0 ]; then
+ success; echo
+ else
+ failure; echo
+ return 1
+ fi
+
+ return 0
+}
+
+stop () {
+ local RET
+
+ echo -n "Stopping $DESC: $NAME "
+ start-stop-daemon --stop -u llmnrd -n llmnrd -p /run/llmnrd/pid -q
+ RET=$?
+ if [ $RET -eq 0 ]; then
+ success; echo
+ else
+ failure; echo
+ return 1
+ fi
+
+ return 0
+}
+
+restart() {
+ local RET
+
+ echo "Restarting $DESC..."
+ stop
+ start
+ RET=$?
+
+ return $RET
+}
+
+condrestart() {
+ local RET
+
+ pidofproc $BASENAME >/dev/null
+ RET=$?
+ if [ $RET -eq 0 ]; then
+ restart
+ RET=$?
+ else
+ RET=1
+ fi
+
+ return $RET
+}
+
+reload() {
+ local RET pid
+
+ # llmnrd has no support for HUP, so just restart
+ condrestart
+}
+
+forcereload() {
+ local RET
+
+ reload
+ RET=$?
+ if [ $RET -ne 0 ]; then
+ restart
+ RET=$?
+ fi
+
+ return $RET
+}
+
+parse() {
+ case "$1" in
+ start)
+ start
+ return $?
+ ;;
+ stop)
+ stop
+ return $?
+ ;;
+ restart)
+ restart
+ return $?
+ ;;
+ condrestart|try-restart)
+ condrestart
+ return $?
+ ;;
+ reload)
+ reload
+ return $?
+ ;;
+ force-reload)
+ forcereload
+ return $?
+ ;;
+ status)
+ status $BASENAME
+ return $?
+ ;;
+ *)
+ echo "Usage: $NAME " \
+ "{start|stop|restart|condrestart|reload|force-reload|status}" >&2
+ ;;
+ esac
+
+ return 1
+}
+
+parse $@