aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/rsyslog/files/initscript
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/rsyslog/files/initscript')
-rw-r--r--recipes/rsyslog/files/initscript90
1 files changed, 90 insertions, 0 deletions
diff --git a/recipes/rsyslog/files/initscript b/recipes/rsyslog/files/initscript
new file mode 100644
index 0000000000..8dee684a82
--- /dev/null
+++ b/recipes/rsyslog/files/initscript
@@ -0,0 +1,90 @@
+#! /bin/sh
+#
+# This is an init script for openembedded
+# Copy it to /etc/init.d/rsyslog and type
+# > update-rc.d rsyslog defaults 5
+#
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+NAME=rsyslog
+RSYSLOGD=rsyslogd
+RSYSLOGD_BIN=/usr/sbin/rsyslogd
+RSYSLOGD_OPTIONS="-c5"
+RSYSLOGD_PIDFILE=/var/run/rsyslogd.pid
+SCRIPTNAME=/etc/init.d/$NAME
+# Exit if the package is not installed
+[ -x "$RSYSLOGD_BIN" ] || exit 0
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ DAEMON=$1
+ DAEMON_ARGS=$2
+ PIDFILE=$3
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon could not be started
+ start-stop-daemon -S --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 1
+}
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ NAME=$1
+ PIDFILE=$2
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ # QUIT/TERM/INT should work here, but they don't ?????
+ start-stop-daemon -K --quiet --signal KILL --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ NAME=$1
+ PIDFILE=$2
+ start-stop-daemon -K --signal HUP --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+case "$1" in
+ start)
+ echo -n "starting $RSYSLOGD ... "
+ do_start "$RSYSLOGD_BIN" "$RSYSLOGD_OPTIONS" "$RSYSLOGD_PIDFILE"
+ case "$?" in
+ 0) echo "done" ;;
+ 1) echo "failed" ;;
+ esac
+ ;;
+ stop)
+ echo -n "stopping $RSYSLOGD ... "
+ do_stop "$RSYSLOGD" "$RSYSLOGD_PIDFILE"
+ case "$?" in
+ 0|1) echo "done" ;;
+ 2) echo "failed" ;;
+ esac
+ ;;
+ reload|force-reload)
+ echo -n "reloading $RSYSLOGD ... "
+ do_reload "$RSYSLOGD" "$RSYSLOGD_PIDFILE"
+ echo "done"
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+ exit 3
+ ;;
+esac
+exit 0