[csw-devel] SF.net SVN: gar:[6937] csw/mgar/pkg/puppet/trunk
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Wed Oct 21 18:46:06 CEST 2009
Revision: 6937
http://gar.svn.sourceforge.net/gar/?rev=6937&view=rev
Author: wahwah
Date: 2009-10-21 16:46:06 +0000 (Wed, 21 Oct 2009)
Log Message:
-----------
puppet: Reworked the init.d file.
Modified Paths:
--------------
csw/mgar/pkg/puppet/trunk/checksums
csw/mgar/pkg/puppet/trunk/files/cswpuppetd
Modified: csw/mgar/pkg/puppet/trunk/checksums
===================================================================
--- csw/mgar/pkg/puppet/trunk/checksums 2009-10-21 14:46:42 UTC (rev 6936)
+++ csw/mgar/pkg/puppet/trunk/checksums 2009-10-21 16:46:06 UTC (rev 6937)
@@ -1,5 +1,5 @@
-abaa404420106f9f28e9e1218b4e365b download/0001-pkgutil-support.patch
-71174fc47265e5c81a0e32366563e5e4 download/cswpuppetd
-fd5e49b7d2b7d288d5beb224d0cfa855 download/cswpuppetmasterd
-3ab0d4f9801075bc78b68b766b496fc7 download/cswusergroup
-288d46dee00acad64d0f3ecc6d8ba6fa download/puppet-0.24.8.tgz
+abaa404420106f9f28e9e1218b4e365b 0001-pkgutil-support.patch
+3b7da4c98895e944262ed684e48e3b08 cswpuppetd
+fd5e49b7d2b7d288d5beb224d0cfa855 cswpuppetmasterd
+3ab0d4f9801075bc78b68b766b496fc7 cswusergroup
+288d46dee00acad64d0f3ecc6d8ba6fa puppet-0.24.8.tgz
Modified: csw/mgar/pkg/puppet/trunk/files/cswpuppetd
===================================================================
--- csw/mgar/pkg/puppet/trunk/files/cswpuppetd 2009-10-21 14:46:42 UTC (rev 6936)
+++ csw/mgar/pkg/puppet/trunk/files/cswpuppetd 2009-10-21 16:46:06 UTC (rev 6937)
@@ -2,66 +2,118 @@
#
# $Id$
#
-# This is the /etc/init.d file for puppetd
-# Modified for CSW
+# /etc/opt/csw/init.d/cswpuppetd
#
-# description: puppetd - Puppet Automation Client
+# 2009-10-21 Maciej Blizinski
#
+# * Introduced start/stop/reload as functions
+# * Distinguishing between reload and restart
+# * Made the script zone-friendly
+# * Supported custom pid file locations.
. /lib/svc/share/smf_include.sh
-prefix=/opt/csw
-exec_prefix=/opt/csw
-sysconfdir=/opt/csw/etc
-sbindir=/opt/csw/bin
+prefix="/opt/csw"
+exec_prefix="/opt/csw"
+sysconfdir="/etc/csw/opt"
+sbindir="/opt/csw/bin"
+localstatedir="/var/opt/csw"
-pidfile=/var/opt/csw/puppet/run/puppetd.pid
-case "$1" in
-start)
- cd /
- # Start daemons.
+start_puppetd() {
+ cd /
+ # Start daemons.
+ ${sbindir}/puppetd
+}
- printf "Starting Puppet client services:"
+reload_puppetd() {
+ if [ -r $pidfile ]; then
+ kill -HUP `cat $pidfile`
+ fi
+}
- ${sbindir}/puppetd
+stop_puppetd() {
+ if [ -r $pidfile ]; then
+ pid=`cat $pidfile`
+ kill $pid
+ fi
+}
+get_current_pid() {
+ if [ -x /usr/bin/zonename ]; then
+ zone=`/usr/bin/zonename`
+ zoneopts="-z $zone"
+ else
+ zoneopts=""
+ fi
+ pgrep $zoneopts puppetd
+}
+
+# Returns a line with certain string from a config file.
+get_line_with() {
+ __s="$1"
+ __f="$2"
+ cat "${__f}" \
+ | sed -e 's/^ *//' \
+ | grep -v '^#' \
+ | grep "${__s}"
+}
+
+get_pid_file() {
+ # The default pid file is /var/opt/csw/puppet/run/puppetd.pid
+ # but a different pid file can be set in puppet.conf.
+ __pidfile="/var/opt/csw/puppet/run/puppetd.pid"
+ conffile="/etc/opt/csw/puppet/puppet.conf"
+ if [ -r "$conffile" ]; then
+ pid_line=`get_line_with pidfile ${conffile}`
+ if [ -n "${pid_line}" ]; then
+ echo "${pid_line}" | cut -d= -f2 | tr -d ' '
+ return
+ fi
+ fi
+ echo "${__pidfile}"
+}
+
+pidfile=`get_pid_file`
+
+case "$1" in
+ start)
+ printf "Starting Puppet client services:"
+ start_puppetd
printf " puppetd"
echo ""
;;
-stop)
+ stop)
printf "Stopping Puppet client services:"
- kill `cat $pidfile`
-
+ stop_puppetd
printf " puppetd"
echo ""
;;
-restart)
+ restart)
printf "Restarting Puppet client services:"
- kill -HUP `cat $pidfile`
-
+ stop_puppetd
+ start_puppetd
printf " puppetd"
echo ""
;;
-reload)
+ reload)
printf "Reloading Puppet client services:"
-
- kill -HUP `cat $pidfile`
-
+ reload_puppetd
printf " puppetd"
echo ""
;;
-status)
+ status)
if [ -f $pidfile ]; then
- pid=`cat $pidfile`
- curpid=`pgrep puppetd`
- if [ "$pid" -eq "$curpid" ]; then
- exit 0
- else
- exit 1
- fi
+ pid=`cat $pidfile`
+ curpid=`get_current_pid`
+ if [ "$pid" -eq "$curpid" ]; then
+ exit 0
+ else
+ exit 1
+ fi
else
- exit 1
+ exit 1
fi
+ ;;
esac
exit 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list