summaryrefslogtreecommitdiff
path: root/startup-scripts
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-09 16:04:58 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-09 16:04:58 +0200
commit819a9ab222da57d6064a7cc9ad3e2c9ff0ef2f82 (patch)
tree5a175f83ca99f08c81f9dd2be93649fd97eebdaa /startup-scripts
Imported Upstream version 0.6upstream/0.6
Diffstat (limited to 'startup-scripts')
-rwxr-xr-xstartup-scripts/archlinux-startup.sh36
-rw-r--r--startup-scripts/com.epipe.downtimed.plist14
-rwxr-xr-xstartup-scripts/debian-startup.sh137
-rw-r--r--startup-scripts/downtimed.smf.xml56
-rwxr-xr-xstartup-scripts/freebsd-startup.sh35
-rwxr-xr-xstartup-scripts/opensuse-startup.sh163
-rwxr-xr-xstartup-scripts/redhat-startup.sh115
-rw-r--r--startup-scripts/upstart-startup.conf14
8 files changed, 570 insertions, 0 deletions
diff --git a/startup-scripts/archlinux-startup.sh b/startup-scripts/archlinux-startup.sh
new file mode 100755
index 0000000..4d3c8fd
--- /dev/null
+++ b/startup-scripts/archlinux-startup.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PID=$(pidof -o %PPID /usr/sbin/downtimed)
+case "$1" in
+ start)
+ stat_busy "Starting downtimed"
+ [ -z "$PID" ] && /usr/sbin/downtimed
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon downtimed
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping downtimed"
+ [ ! -z "$PID" ] && kill $PID &> /dev/null
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon downtimed
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac
+exit 0
diff --git a/startup-scripts/com.epipe.downtimed.plist b/startup-scripts/com.epipe.downtimed.plist
new file mode 100644
index 0000000..194b34e
--- /dev/null
+++ b/startup-scripts/com.epipe.downtimed.plist
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Label</key>
+ <string>com.epipe.downtimed</string>
+ <key>KeepAlive</key>
+ <true/>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/usr/local/sbin/downtimed</string>
+ </array>
+</dict>
+</plist>
diff --git a/startup-scripts/debian-startup.sh b/startup-scripts/debian-startup.sh
new file mode 100755
index 0000000..8e04162
--- /dev/null
+++ b/startup-scripts/debian-startup.sh
@@ -0,0 +1,137 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: downtimed
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $local_fs
+# Default-Start: S
+# Default-Stop: 0 6
+# Short-Description: downtime record keeper
+# Description: Downtimed is a daemon which keeps records of
+# the periods when the operating system has been
+# out of service.
+### END INIT INFO
+#
+# Written 2011 by Mats Erik Andersson.
+# Licensed using two-clause FreeBSD statement.
+#
+###
+
+DESC="downtime bookkeeper"
+NAME="downtimed"
+
+DAEMON="/usr/local/sbin/$NAME"
+PIDFILE=/var/run/$NAME.pid
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+SCRIPT=/etc/init.d/$NAME
+
+DOWNTIMED_OPTS=""
+
+# Are we making sense?
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Detect VERBOSE mode and load any rcS variables.
+. /lib/init/vars.sh
+
+# Define all LSB log_* functions.
+. /lib/lsb/init-functions
+
+# Start downtimed.
+do_start()
+{
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE \
+ --exec $DAEMON -- $DOWNTIMED_OPTS \
+ || return 2
+
+ # Return status:
+ # 0 daemon has been started
+ # 1 daemon was already running
+ # 2 daemon could not be started
+}
+
+# Halt downtimed.
+do_stop()
+{
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
+ --pidfile $PIDFILE --exec $DAEMON
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+
+ rm -f $PIDFILE
+ return "$RETVAL"
+
+ # Return status:
+ # 0 daemon has been stopped
+ # 1 daemon was already stopped
+ # 2 daemon could not be stopped
+ # other daemon reported some other failure
+}
+
+# Reloading is a no-do in the standard case, when logging is
+# done via the syslog service. Only if $DOWNTIMED_OPTS states
+# a separate logging file, then a SIGHUP will result in the
+# daemon releasing the file for rotation, or a similar action.
+
+do_reload() {
+ start-stop-daemon --stop --signal 1 --quiet \
+ --pidfile $PIDFILE --exec $DAEMON
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ reload|force-reload)
+ log_daemon_msg "Reloading $DESC" "$NAME"
+ do_reload
+ log_end_msg $?
+ ;;
+ restart)
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Still running.
+ *) log_end_msg 1 ;; # Failure in starting.
+ esac
+ ;;
+ *)
+ # Failure in ending service.
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/startup-scripts/downtimed.smf.xml b/startup-scripts/downtimed.smf.xml
new file mode 100644
index 0000000..0d15a4b
--- /dev/null
+++ b/startup-scripts/downtimed.smf.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+
+<!DOCTYPE service_bundle SYSTEM
+ "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+
+<!--
+ SMF Manifest for downtimed.
+
+ Copyright 2012 Mats Erik Andersson. All rights reserved.
+ Licensed as 2-clause BSD license, identical to the text
+ used by downtimed-0.5.
+-->
+
+<service_bundle type="manifest" name="downtimed">
+ <service
+ name="system/downtimed"
+ type="service"
+ version="1">
+ <single_instance />
+ <dependency
+ name="usr"
+ type="service"
+ grouping="require_all"
+ restart_on="none">
+ <service_fmri value="svc:/system/filesystem/local" />
+ </dependency>
+ <exec_method
+ type="method"
+ name="start"
+ exec="/usr/local/sbin/downtimed"
+ timeout_seconds="15">
+ <method_context>
+ <method_credential user="root" group="root" />
+ </method_context>
+ </exec_method>
+ <exec_method
+ type="method"
+ name="stop"
+ exec=":kill"
+ timeout_seconds="5" />
+ <instance name="default" enabled="true" />
+ <stability value="Unstable" />
+
+ <template>
+ <common_name>
+ <loctext xml:lang="C">
+ downtime cronograph
+ </loctext>
+ </common_name>
+ <documentation>
+ <manpage title="downtimed" section="8" manpath="/usr/local/share/man" />
+ <manpage title="downtimes" section="1" manpath="/usr/local/share/man" />
+ </documentation>
+ </template>
+ </service>
+</service_bundle>
diff --git a/startup-scripts/freebsd-startup.sh b/startup-scripts/freebsd-startup.sh
new file mode 100755
index 0000000..5437086
--- /dev/null
+++ b/startup-scripts/freebsd-startup.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# $FreeBSD$
+
+# PROVIDE: downtimed
+# REQUIRE: LOGIN syslogd
+# KEYWORD: shutdown
+
+# This file should be installed as /usr/local/etc/rc.d/downtimed
+#
+# Define downtimed_* variables in one of these files:
+# /etc/rc.conf
+# /etc/rc.conf.local
+# /etc/rc.conf.d/downtimed
+#
+# Add the following line to enable:
+# downtimed_enable="YES"
+#
+# Add the following line to change the default options, see downtimed(8):
+# downtimed_flags="<set as needed>"
+#
+# DO NOT CHANGE THE DEFAULT VALUES BELOW
+
+. /etc/rc.subr
+
+name="downtimed"
+rcvar=`set_rcvar`
+
+command="/usr/local/sbin/${name}"
+pidfile="/var/run/${name}.pid"
+
+load_rc_config "$name"
+
+: ${downtimed_enable="NO"}
+
+run_rc_command "$1"
diff --git a/startup-scripts/opensuse-startup.sh b/startup-scripts/opensuse-startup.sh
new file mode 100755
index 0000000..48fac31
--- /dev/null
+++ b/startup-scripts/opensuse-startup.sh
@@ -0,0 +1,163 @@
+#! /bin/sh
+#
+# Copyright (c) 1995-2001 SuSE GmbH Nuernberg, Germany.
+# Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany.
+# Copyright (c) 2002--2008 Klaus Singvogel, SUSE / Novell Inc.
+# Copyright (c) 2010 Federico Lucifredi, SUSE / Novell Inc.
+#
+# Author: Kurt Garloff <feedback@suse.de>, 2000
+# Klaus Singvogel <feedback@suse.de>, 2002--2008
+# Federico Lucifredi <feedback@suse.de>, 2010
+#
+# /etc/init.d/downtimed
+#
+# System startup script for the downtimed daemon
+#
+### BEGIN INIT INFO
+# Provides: downtimed
+# Required-Start:
+# Required-Stop:
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 5
+# Default-Stop: 0 1 6
+# Short-Description: downtime monitoring daemon
+# Description: Start downtimed to provide monitoring of uptime and
+# downtime intervals.
+#
+### END INIT INFO
+
+# Source SuSE config, only if exists with size greater zero
+test -s /etc/rc.config && \
+ . /etc/rc.config
+
+# Shell functions sourced from /etc/rc.status:
+# rc_check check and set local and overall rc status
+# rc_status check and set local and overall rc status
+# rc_status -v ditto but be verbose in local rc status
+# rc_status -v -r ditto and clear the local rc status
+# rc_failed set local and overall rc status to failed
+# rc_failed <num> set local and overall rc status to <num><num>
+# rc_reset clear local rc status (overall remains)
+# rc_exit exit appropriate to overall rc status
+
+DOWNTIMED_BIN=/usr/local/sbin/downtimed
+
+test -s /etc/rc.status && \
+ . /etc/rc.status
+
+test -x $DOWNTIMED_BIN || exit 5
+
+# First reset status of this service
+rc_reset
+
+# Return values acc. to LSB for all commands but status:
+# 0 - success
+# 1 - generic or unspecified error
+# 2 - invalid or excess argument(s)
+# 3 - unimplemented feature (e.g. "reload")
+# 4 - insufficient privilege
+# 5 - program is not installed
+# 6 - program is not configured
+# 7 - program is not running
+#
+# Note that starting an already running service, stopping
+# or restarting a not-running service as well as the restart
+# with force-reload (in case signalling is not supported) are
+# considered a success.
+
+case "$1" in
+ start)
+ echo -n "Starting downtimed"
+ ## Start daemon with startproc(8). If this fails
+ ## the echo return value is set appropriate.
+
+ # NOTE: startproc return 0, even if service is
+ # already running to match LSB spec.
+ startproc $DOWNTIMED_BIN $DOWNTIMED_OPTIONS
+
+ # Remember status and be verbose
+ rc_status -v
+ ;;
+ stop)
+ echo -n "Shutting down downtimed"
+ ## Stop daemon with killproc(8) and if this fails
+ ## set echo the echo return value.
+
+ killproc -TERM $DOWNTIMED_BIN
+
+ # Remember status and be verbose
+ rc_status -v
+ ;;
+ try-restart)
+ ## Stop the service and if this succeeds (i.e. the
+ ## service was running before), start it again.
+ ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
+ $0 status >/dev/null && $0 restart
+
+ # Remember status and be quiet
+ rc_status
+ ;;
+ restart)
+ ## Stop the service and regardless of whether it was
+ ## running or not, start it again.
+ $0 stop
+ $0 start
+
+ # Remember status and be quiet
+ rc_status
+ ;;
+ force-reload)
+ ## Signal the daemon to reload its config. Most daemons
+ ## do this on signal 1 (SIGHUP).
+ ## If it does not support it, restart.
+
+ if ps -C downtimed -o user | grep -q '^root$'; then
+ echo -n "Reload service downtimed"
+ killproc -HUP $DOWNTIMED_BIN
+ rc_status -v
+ else
+ $0 restart
+ fi
+ ;;
+ reload)
+ ## Like force-reload, but if daemon does not support
+ ## signalling, do nothing (!)
+
+ # If it supports signalling:
+ if ps -C downtimed -o user | grep -q '^root$'; then
+ echo -n "Reload service downtimed"
+ killproc -HUP $DOWNTIMED_BIN
+ rc_status -v
+ else
+ echo -n '"reload" not possible in RunAsUser mode - use "restart" instead'
+ rc_status -s
+ fi
+ ;;
+ status)
+ echo -n "Checking for downtimed: "
+ ## Check status with checkproc(8), if process is running
+ ## checkproc will return with exit status 0.
+
+ # Status has a slightly different for the status command:
+ # 0 - service running
+ # 1 - service dead, but /var/run/ pid file exists
+ # 2 - service dead, but /var/lock/ lock file exists
+ # 3 - service not running
+
+ # NOTE: checkproc returns LSB compliant status values.
+ checkproc $DOWNTIMED_BIN
+ rc_status -v
+ ;;
+ probe)
+ ## Optional: Probe for the necessity of a reload,
+ ## give out the argument which is required for a reload.
+
+ rc_failed 3
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
+ exit 1
+ ;;
+esac
+rc_exit
diff --git a/startup-scripts/redhat-startup.sh b/startup-scripts/redhat-startup.sh
new file mode 100755
index 0000000..867cc45
--- /dev/null
+++ b/startup-scripts/redhat-startup.sh
@@ -0,0 +1,115 @@
+#!/bin/bash
+#
+# /etc/rc.d/init.d/downtimed
+#
+# downtimed: system downtime monitoring and reporting tool
+#
+# This init script should work on Red Hat related distributions
+# such as RHEL/Fedora/Scientific Linux/CentOS. Based on:
+# http://fedoraproject.org/wiki/Packaging:SysVInitScript
+#
+# chkconfig: 2345 99 99
+# description: downtimed is a program that monitors operating system \
+# downtime, uptime, shutdowns and crashes and keeps records \
+# of those events.
+# processname: downtimed
+# pidfile: /var/run/downtimed.pid
+
+### BEGIN INIT INFO
+# Provides: downtimed
+# Required-Start: $remote_fs $time
+# Required-Stop: $local_fs
+# Should-Start: $syslog $all
+# Should-Stop: $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: system downtime monitoring and reporting tool
+# Description: downtimed is a program that monitors operating system
+# downtime, uptime, shutdowns and crashes and keeps records
+# of those events.
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+prog="downtimed"
+exec="/usr/local/sbin/$prog"
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+start() {
+ [ -x $exec ] || exit 5
+ echo -n $"Starting $prog: "
+ daemon $exec
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ killproc $prog
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ status $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+start)
+ rh_status_q && exit 0
+ $1
+ ;;
+stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+restart)
+ $1
+ ;;
+reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+force-reload)
+ force_reload
+ ;;
+status)
+ rh_status
+ ;;
+condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+*)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
+
+# eof
diff --git a/startup-scripts/upstart-startup.conf b/startup-scripts/upstart-startup.conf
new file mode 100644
index 0000000..8a11ba9
--- /dev/null
+++ b/startup-scripts/upstart-startup.conf
@@ -0,0 +1,14 @@
+# downtimed - system downtime monitoring daemon
+#
+# This file should be installed as /etc/init/downtimed.conf
+# on architectures which use upstart(8) to bring up system
+# daemons.
+
+description "system downtime monitoring daemon"
+
+start on runlevel [2345]
+stop on runlevel [!2345]
+
+expect fork
+
+exec downtimed