aboutsummaryrefslogtreecommitdiff
path: root/_sys/etc/init.d/rescached.run
diff options
context:
space:
mode:
Diffstat (limited to '_sys/etc/init.d/rescached.run')
-rwxr-xr-x_sys/etc/init.d/rescached.run84
1 files changed, 84 insertions, 0 deletions
diff --git a/_sys/etc/init.d/rescached.run b/_sys/etc/init.d/rescached.run
new file mode 100755
index 0000000..e9a602f
--- /dev/null
+++ b/_sys/etc/init.d/rescached.run
@@ -0,0 +1,84 @@
+#!/bin/sh
+## SPDX-FileCopyrightText: 2018 M. Shulhan <ms@kilabit.info>
+## SPDX-License-Identifier: GPL-3.0-or-later
+
+### BEGIN INIT INFO
+# Provides: rescached
+# Required-Start: $syslog $remote_fs
+# Required-Stop: $syslog $remote_fs
+# Default-Start: 3 5
+# Default-Stop: 0 1 2 6
+# Short-Description: resolver cache daemon.
+# Description: resolver cache daemon.
+### END INIT INFO
+
+RESCACHED_BIN=/usr/bin/rescached
+RESCACHED_CFG=/etc/rescached/rescached.cfg
+
+#
+# check if program exist.
+#
+test -x ${RESCACHED_BIN} || {
+ echo "Program '${RESCACHED_BIN}' not installed";
+ if [ "$1" = "stop" ]; then
+ exit 0;
+ else
+ exit 5;
+ fi;
+}
+
+#
+# check if configuration file exist.
+#
+test -r ${RESCACHED_CFG} || {
+ echo "File '${RESCACHED_CFG}' not existing";
+ if [ "$1" = "stop" ]; then
+ exit 0;
+ else
+ exit 6;
+ fi;
+}
+
+case "$1" in
+start)
+ echo -n "Starting rescached "
+ ${RESCACHED_BIN} ${RESCACHED_CFG} &
+ if test $? = 0; then
+ echo "[OK]";
+ else
+ echo "[FAIL]";
+ fi;
+ ;;
+
+stop)
+ echo -n "Shutting down rescached "
+
+ killall ${RESCACHED_PID};
+
+ if test $? = 0; then
+ echo "[OK]";
+ else
+ echo "[not running]";
+ fi;
+ ;;
+
+restart)
+ $0 stop
+ $0 start
+ ;;
+
+status)
+ echo -n "Checking for service rescached "
+ RESCACHED_PS=`ps -ef | grep "rescached -config"`
+ if [[ "${RESCACHED_PS}" -ne "" ]]; then
+ echo "[running]";
+ else
+ echo "[not running]";
+ fi;
+ ;;
+
+*)
+ echo "Usage: $0 {start|stop|restart|status}"
+ exit 1
+ ;;
+esac