diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2012-10-08 14:29:15 -0500 |
---|---|---|
committer | Tim Laszlo <tim.laszlo@gmail.com> | 2012-10-08 14:29:15 -0500 |
commit | 3bee6cbd777cb11dc98daf6954bf9a4ec089a6ee (patch) | |
tree | 20bfcfc2d04c373c450314c33550ef30f9f15271 | |
parent | 75d4b13ce91c5f02e24dee894296345b3c54f833 (diff) | |
download | bcfg2-3bee6cbd777cb11dc98daf6954bf9a4ec089a6ee.tar.gz bcfg2-3bee6cbd777cb11dc98daf6954bf9a4ec089a6ee.tar.bz2 bcfg2-3bee6cbd777cb11dc98daf6954bf9a4ec089a6ee.zip |
add init script
-rwxr-xr-x | debian/bcfg2-report-collector.init | 108 | ||||
-rw-r--r-- | debian/bcfg2-server.default | 5 | ||||
-rw-r--r-- | misc/bcfg2.spec | 5 |
3 files changed, 118 insertions, 0 deletions
diff --git a/debian/bcfg2-report-collector.init b/debian/bcfg2-report-collector.init new file mode 100755 index 000000000..d3ef6dcc5 --- /dev/null +++ b/debian/bcfg2-report-collector.init @@ -0,0 +1,108 @@ +#!/bin/sh +# +# bcfg-report-collector - Bcfg2 reporting collector daemon +# +# chkconfig: 2345 19 81 +# description: bcfg2 server for reporting data +# +### BEGIN INIT INFO +# Provides: bcfg2-report-collector +# Required-Start: $network $remote_fs $named +# Required-Stop: $network $remote_fs $named +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Configuration management Server +# Description: Bcfg2 is a configuration management system that builds +# installs configuration files served by bcfg2-server +### END INIT INFO + +# Include lsb functions +. /lib/lsb/init-functions + +# Commonly used stuff +DAEMON=/usr/sbin/bcfg2-report-collector +PIDFILE=/var/run/bcfg2-server/bcfg2-report-collector.pid +PARAMS="-D $PIDFILE" + +# Include default startup configuration if exists +test -f "/etc/default/bcfg2-server" && . /etc/default/bcfg2-server + +# Exit if $DAEMON doesn't exist and is not executable +test -x $DAEMON || exit 5 + +# Internal variables +BINARY=$(basename $DAEMON) + +start () { + echo -n "Starting Configuration Report Collector: " + start_daemon ${DAEMON} ${PARAMS} ${BCFG2_REPORT_OPTIONS} + STATUS=$? + if [ "$STATUS" = 0 ] + then + log_success_msg "bcfg2-report-collector" + test -d /var/lock/subsys && touch /var/lock/subsys/bcfg2-report-collector + else + log_failure_msg "bcfg2-report-collector" + fi + return $STATUS +} + +stop () { + echo -n "Stopping Configuration Report Collector: " + if [ -f $PIDFILE ]; then + PID=`cat $PIDFILE | tr -d -c '0-9'` + killproc -p $PID ${BINARY} + else + killproc ${BINARY} + fi + STATUS=$? + if [ "$STATUS" = 0 ]; then + log_success_msg "bcfg2-report-collector" + test -d /var/lock/subsys && touch /var/lock/subsys/bcfg2-report-collector + else + log_failure_msg "bcfg2-report-collector" + fi + return $STATUS +} + +status () { + # Inspired by redhat /etc/init.d/functions status() call + PID=$(pidof -x $BINARY -o %PPID) + if [ -n "$PID" ]; then + echo "$BINARY (pid $PID) is running..." + return 0 + fi + + if [ -f $PIDFILE ]; then + if [ -n "$PID" ]; then + log_failure_msg "$BINARY dead but pid file exists..." + return 1 + fi + fi + + log_failure_msg "$BINARY is not running" + return 3 +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status + ;; + restart|reload|force-reload) + stop + sleep 5 + start + ;; + *) + log_success_msg "Usage: $0 {start|stop|status|reload|restart|force-reload}" + exit 1 + ;; +esac + +exit 0 diff --git a/debian/bcfg2-server.default b/debian/bcfg2-server.default index 61f9d8f80..446b5c94c 100644 --- a/debian/bcfg2-server.default +++ b/debian/bcfg2-server.default @@ -11,3 +11,8 @@ # Uncomment the following line to enable any of the below selections # Default: 0 (disable) BCFG2_SERVER_ENABLED=1 + +# BCFG2_REPORT_OPTIONS: +# Set the default options for Bcfg2 Report Collector on startup +# Default: "" +#BCFG2_REPORT_OPTIONS diff --git a/misc/bcfg2.spec b/misc/bcfg2.spec index 84e2bb41c..66a11833e 100644 --- a/misc/bcfg2.spec +++ b/misc/bcfg2.spec @@ -320,6 +320,7 @@ mkdir -p %{buildroot}%{_defaultdocdir}/bcfg2-server-%{version} %{__mv} %{buildroot}%{_bindir}/bcfg2* %{buildroot}%{_sbindir} %{__install} -m 755 debian/bcfg2.init %{buildroot}%{_initrddir}/bcfg2 %{__install} -m 755 debian/bcfg2-server.init %{buildroot}%{_initrddir}/bcfg2-server +%{__install} -m 755 debian/bcfg2-report-collector.init %{buildroot}%{_initrddir}/bcfg2-report-collector %{__install} -m 755 debian/bcfg2.default %{buildroot}%{_sysconfdir}/default/bcfg2 %{__install} -m 755 debian/bcfg2-server.default %{buildroot}%{_sysconfdir}/default/bcfg2-server %{__install} -m 755 debian/bcfg2.cron.daily %{buildroot}%{_sysconfdir}/cron.daily/bcfg2 @@ -382,6 +383,7 @@ touch %{buildroot}%{_sysconfdir}/bcfg2.conf %{buildroot}%{_sysconfdir}/bcfg2-web %files server %defattr(-,root,root,-) %{_initrddir}/bcfg2-server +%{_initrddir}/bcfg2-report-collector %dir %{python_sitelib}/Bcfg2 %{python_sitelib}/Bcfg2/Server %{python_sitelib}/Bcfg2/Reporting @@ -440,8 +442,10 @@ touch %{buildroot}%{_sysconfdir}/bcfg2.conf %{buildroot}%{_sysconfdir}/bcfg2-web if [ $1 -eq 1 ]; then %if 0%{?suse_version} %fillup_and_insserv -f bcfg2-server + %fillup_and_insserv -f bcfg2-report-collector %else /sbin/chkconfig --add bcfg2-server + /sbin/chkconfig --add bcfg2-report-collector %endif fi @@ -457,6 +461,7 @@ fi %if 0%{?suse_version} if [ $1 -eq 0 ]; then %stop_on_removal bcfg2-server + %stop_on_removal bcfg2-report-collector fi %endif |