[csw-devel] SF.net SVN: gar:[16169] csw/mgar/pkg
guengel at users.sourceforge.net
guengel at users.sourceforge.net
Sat Nov 12 13:02:39 CET 2011
Revision: 16169
http://gar.svn.sourceforge.net/gar/?rev=16169&view=rev
Author: guengel
Date: 2011-11-12 12:02:38 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
cfengine3/trunk: Initial release
Added Paths:
-----------
csw/mgar/pkg/cfengine3/
csw/mgar/pkg/cfengine3/Makefile
csw/mgar/pkg/cfengine3/branches/
csw/mgar/pkg/cfengine3/tags/
csw/mgar/pkg/cfengine3/trunk/
csw/mgar/pkg/cfengine3/trunk/Makefile
csw/mgar/pkg/cfengine3/trunk/checksums
csw/mgar/pkg/cfengine3/trunk/files/
csw/mgar/pkg/cfengine3/trunk/files/CSWcfengine3rt.postinstall
csw/mgar/pkg/cfengine3/trunk/files/README.CSW
csw/mgar/pkg/cfengine3/trunk/files/cfengine3rc
csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfexecd
csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfmonitord
csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfserverd
Added: csw/mgar/pkg/cfengine3/Makefile
===================================================================
--- csw/mgar/pkg/cfengine3/Makefile (rev 0)
+++ csw/mgar/pkg/cfengine3/Makefile 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,2 @@
+%:
+ $(MAKE) -C trunk $*
Property changes on: csw/mgar/pkg/cfengine3/Makefile
___________________________________________________________________
Added: svn:keywords
+ Date Revision Author HeadURL Id
Added: svn:eol-style
+ native
Property changes on: csw/mgar/pkg/cfengine3/trunk
___________________________________________________________________
Added: svn:ignore
+ cookies
download
work
Added: svn:externals
+ gar https://gar.svn.sourceforge.net/svnroot/gar/csw/mgar/gar/v2
Added: csw/mgar/pkg/cfengine3/trunk/Makefile
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/Makefile (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/Makefile 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,160 @@
+# $Id$
+#
+NAME = cfengine3
+VERSION = 3.2.3
+CATEGORIES = utils
+
+DESCRIPTION = Open source configuration management system
+define BLURB
+ CFEngine Community is the Open Source foundation of CFEngine's innovative
+ configuration management technology that helps systems administrators
+ automate and ensure the availability, security and compliance of
+ mission-critical applications and services.
+endef
+
+DISTNAME = cfengine-$(VERSION)
+MASTER_SITES = http://www.cfengine.com/source-code/download?file=
+DISTFILES = $(DISTNAME).tar.gz
+DISTFILES += $(NAME)rc
+DISTFILES += CSW$(NAME)rt.postinstall
+DISTFILES += csw$(NAME)-cfexecd
+DISTFILES += csw$(NAME)-cfmonitord
+DISTFILES += csw$(NAME)-cfserverd
+DISTFILES += README.CSW
+VENDOR_URL = http://www.cfengine.com/community
+
+# File name regex to get notifications about upstream software releases
+# NOTE: Use this only if the automatic regex creation
+# does not work for your package
+# UFILES_REGEX = $(NAME)-(\d+(?:\.\d+)*).tar.gz
+
+# If the url used to check for software update is different of MASTER_SITES, then
+# uncomment the next line. Otherwise it is set by default to the value of MASTER_SITES
+# UPSTREAM_MASTER_SITES =
+
+#
+# CUSTOM VARIABLES
+#
+cfengine_workdir = $(localstatedir)/$(NAME)
+cfengine_workdir_bin = $(cfengine_workdir)/bin
+initddir = $(sysconfdir)/init.d
+
+EXTRA_MERGE_EXCLUDE_FILES = $(datadir)/cfengine.*
+
+PACKAGES = CSW$(NAME)rt
+CATALOGNAME_CSW$(NAME)rt = $(NAME)_rt
+SPKG_DESC_CSW$(NAME)rt = CFEngine 3 runtime and documentation
+RUNTIME_DEP_PKGS_CSW$(NAME)rt += CSWbdb48
+RUNTIME_DEP_PKGS_CSW$(NAME)rt += CSWosslrt
+RUNTIME_DEP_PKGS_CSW$(NAME)rt += CSWlibpcre0
+
+
+PACKAGES += CSW$(NAME)server
+CATALOGNAME_CSW$(NAME)server = $(NAME)_server
+SPKG_DESC_CSW$(NAME)server = CFEngine 3 server binary
+RUNTIME_DEP_PKGS_CSW$(NAME)server += CSWbdb48
+RUNTIME_DEP_PKGS_CSW$(NAME)server += CSWosslrt
+RUNTIME_DEP_PKGS_CSW$(NAME)server += CSWlibpcre0
+RUNTIME_DEP_PKGS_CSW$(NAME)server += CSW$(NAME)rt
+PKGFILES_CSW$(NAME)server += $(sbindir)/cf-serverd
+PKGFILES_CSW$(NAME)server += $(sbindir)/cf-runagent
+PKGFILES_CSW$(NAME)server += $(mandir)/.*/cf-serverd.*
+PKGFILES_CSW$(NAME)server += $(mandir)/.*/cf-runagent.*
+PKGFILES_CSW$(NAME)server += $(initddir)/csw$(NAME)-cfserverd
+PKGFILES_CSW$(NAME)server += $(docdir)/$(NAME)_server/README.CSW
+
+PACKAGES += CSW$(NAME)client
+CATALOGNAME_CSW$(NAME)client = $(NAME)_client
+SPKG_DESC_CSW$(NAME)client = CFEngine 3 client binaries
+RUNTIME_DEP_PKGS_CSW$(NAME)client += CSWbdb48
+RUNTIME_DEP_PKGS_CSW$(NAME)client += CSWosslrt
+RUNTIME_DEP_PKGS_CSW$(NAME)client += CSWlibpcre0
+RUNTIME_DEP_PKGS_CSW$(NAME)client += CSW$(NAME)rt
+PKGFILES_CSW$(NAME)client += $(sbindir)/cf-agent
+PKGFILES_CSW$(NAME)client += $(sbindir)/cf-execd
+PKGFILES_CSW$(NAME)client += $(sbindir)/cf-monitord
+PKGFILES_CSW$(NAME)client += $(mandir)/.*/cf-agent.*
+PKGFILES_CSW$(NAME)client += $(mandir)/.*/cf-execd.*
+PKGFILES_CSW$(NAME)client += $(mandir)/.*/cf-monitord.*
+PKGFILES_CSW$(NAME)client += $(cfengine_workdir_bin)/cf-agent
+PKGFILES_CSW$(NAME)client += $(initddir)/csw$(NAME)-cfexecd
+PKGFILES_CSW$(NAME)client += $(initddir)/csw$(NAME)-cfmonitord
+PKGFILES_CSW$(NAME)client += $(docdir)/$(NAME)_client/README.CSW
+
+# CFEngine provides three daemons
+# - cf-execd (client)
+# - cf-monitord (client)
+# - cf-serverd (server)
+INITSMF = $(initddir)/csw$(NAME)-cfexecd
+INITSMF += $(initddir)/csw$(NAME)-cfmonitord
+INITSMF += $(initddir)/csw$(NAME)-cfserverd
+
+# This file gets installed by CSW$(NAME)rt since it is used by
+# the server and client component
+PRESERVECONF = $(sysconfdir)/$(NAME)rc
+
+BUILD64 = 1
+
+BUILD_DEP_PKGS = CSWbdb48devel
+BUILD_DEP_PKGS += CSWlibpcre-dev
+BUILD_DEP_PKGS += CSWossldevel
+BUILD_DEP_PKGS += CSWflex
+BUILD_DEP_PKGS += CSWbison
+
+CONFIGURE_ARGS = $(DIRPATHS)
+CONFIGURE_ARGS += --disable-silent-rules
+CONFIGURE_ARGS += --with-berkeleydb=$(prefix)/bdb48
+CONFIGURE_ARGS += --with-openssl=$(prefix)
+CONFIGURE_ARGS += --with-pcre=$(prefix)
+CONFIGURE_ARGS += --with-workdir=$(cfengine_workdir)
+CONFIGURE_ARGS += --without-sqlite3
+CONFIGURE_ARGS += --without-qdbm
+CONFIGURE_ARGS += --without-postgresql
+CONFIGURE_ARGS += --without-mysql
+
+EXTRA_INC = $(prefix)/bdb48/include
+
+EXTRA_RUNPATH_DIRS = $(prefix)/bdb48/lib
+EXTRA_RUNPATH_ISALIST = $(EXTRA_RUNPATH_DIRS)
+EXTRA_LDFLAGS = -L$(prefix)/bdb48/lib/$(MM_LIBDIR)
+
+include gar/category.mk
+
+post-install-modulated: rename-cfengine-dir make-cfengine-workdir install-cfengine-links install-smf-manifests install-cfengine3rc install-cfengine3-csw-doc
+ @$(MAKECOOKIE)
+
+rename-cfengine-dir:
+ if test -d $(DESTDIR)$(datadir)/cfengine ; then \
+ mv $(DESTDIR)$(datadir)/cfengine $(DESTDIR)$(datadir)/$(NAME) ;\
+ fi
+ if test -d $(DESTDIR)$(docdir)/cfengine ; then \
+ mv $(DESTDIR)$(docdir)/cfengine $(DESTDIR)$(docdir)/$(NAME) ;\
+ fi
+
+install-smf-manifests:
+ ginstall -d $(DESTDIR)$(initddir)
+ ginstall $(WORKDIR)/csw$(NAME)-cfexecd $(DESTDIR)$(initddir)/
+ ginstall $(WORKDIR)/csw$(NAME)-cfmonitord $(DESTDIR)$(initddir)/
+ ginstall $(WORKDIR)/csw$(NAME)-cfserverd $(DESTDIR)$(initddir)/
+
+make-cfengine-workdir:
+ if test ! -d $(DESTDIR)$(cfengine_workdir) ; then \
+ ginstall -d $(DESTDIR)$(cfengine_workdir); \
+ fi
+ if test ! -d $(DESTDIR)$(cfengine_workdir_bin) ; then\
+ ginstall -d $(DESTDIR)$(cfengine_workdir_bin) ;\
+ fi
+
+install-cfengine-links: make-cfengine-workdir
+ if test ! -h $(DESTDIR)$(cfengine_workdir_bin)/cf-promises ; then \
+ ln -s $(sbindir)/cf-promises $(DESTDIR)$(cfengine_workdir_bin)/cf-promises ;\
+ fi
+ if test ! -h $(DESTDIR)$(cfengine_workdir_bin)/cf-agent ; then \
+ ln -s $(sbindir)/cf-agent $(DESTDIR)$(cfengine_workdir_bin)/cf-agent ;\
+ fi
+
+install-cfengine3rc:
+ ginstall $(WORKDIR)/$(NAME)rc $(DESTDIR)$(sysconfdir)/$(NAME)rc.CSW
+
+install-cfengine3-csw-doc: rename-cfengine-dir
+ ginstall $(WORKDIR)/README.CSW $(DESTDIR)$(docdir)/$(NAME)
Property changes on: csw/mgar/pkg/cfengine3/trunk/Makefile
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: csw/mgar/pkg/cfengine3/trunk/checksums
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/checksums (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/checksums 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1 @@
+be118dd95537221da38008845fc0d84a cfengine-3.2.3.tar.gz
Added: csw/mgar/pkg/cfengine3/trunk/files/CSWcfengine3rt.postinstall
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/files/CSWcfengine3rt.postinstall (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/files/CSWcfengine3rt.postinstall 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,31 @@
+# Takes care of creating the CFEngine 3 public/private keys
+
+CFEWORKDIR=${PKG_INSTALL_ROOT}/var/opt/csw/cfengine3
+CFEKEYDIR=${CFEWORKDIR}/ppkeys
+CF_KEYS=${PKG_INSTALL_ROOT}/opt/csw/sbin/cf-key
+
+if [ \! -d ${CFEWORKDIR} ]
+then
+ # Hmm, this is strange, since the prototype should have
+ # created this directory
+ echo "Creating ${CFEWORKDIR}"
+ mkdir -p ${CFEWORKDIR}
+fi
+
+if [ \! -d ${CFEKEYDIR} ]
+then
+ echo "Creating ${CFEKEYDIR}"
+ mkdir ${CFEKEYDIR}
+fi
+
+chmod 700 ${CFEKEYDIR}
+
+if [ -r ${CFEKEYDIR}/localhost.priv -a -r ${CFEKEYDIR}/localhost.pub ]
+then
+ echo "Keys for CFEngine exist."
+ exit 0
+else
+ ${CF_KEYS} -f ${CFEKEYDIR}/localhost
+fi
+
+exit 0
Added: csw/mgar/pkg/cfengine3/trunk/files/README.CSW
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/files/README.CSW (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/files/README.CSW 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,25 @@
+CFEngine 3
+----------
+
+* The working directory is located at /var/opt/csw/cfengine3.
+
+* Upon first installation, a private/public key will be
+ auto-generated and stored in $(sys.workdir)/ppkeys.
+
+* Symlinks to /opt/csw/sbin/cf-agent, /opt/csw/sbin/cf-promises are
+ auto-created in $(sys.workdir)/bin.
+
+* Options to the daemons can be passed by using
+ /etc/opt/csw/cfengine3rc or /opt/csw/etc/cfengine3rc. The former
+ takes precedence over the latter.
+
+* By default, /etc/opt/csw/cfengine3rc defines a class `opencsw' for
+ cf-execd and cf-serverd.
+
+* CFengine has been compiled without support for PostgreSQL, MySQL,
+ and SQLite.
+
+* Restarting the daemons (especially cf-execd) in fast sequence may
+ lead to the service going in maintenance mode when using SMF (or
+ just not having the daemon started when using legacy startup
+ scritps). This is due to the locking mechanism used by CFEngine.
Added: csw/mgar/pkg/cfengine3/trunk/files/cfengine3rc
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/files/cfengine3rc (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/files/cfengine3rc 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,17 @@
+# This file is a shell script fragment which is sourced by the
+# CFEngine startup scripts. Use it to pass additional options to the
+# various CFEngine daemons.
+#
+# This fragment will be sourced if found under /opt/csw/etc/ or
+# /etc/opt/csw/. The latter takes precedence over the former if both
+# files exist.
+#
+# By default, this file defines the class `opencsw' for cf-execd and
+# cf-serverd.
+
+# Options passed to cf-serverd
+CFSERVERD_OPTS="-D opencsw"
+# Options passed to cf-execd
+CFEXECD_OPTS="-D opencsw"
+# Options passed to cf-monitord
+CFMONITORD_OPTS=""
Added: csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfexecd
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfexecd (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfexecd 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,122 @@
+#!/sbin/sh
+#
+#
+#RC_KNUM 20
+#RC_SNUM 80
+#RC_KLEV 0,1,2,S
+#RC_SLEV 3
+#AUTOENABLE no
+#FMRI application
+
+
+NAME=cf-execd
+DAEMON=/opt/csw/sbin/${NAME}
+PIDFILE=/var/opt/csw/cfengine3/${NAME}.pid
+I=`/usr/bin/basename $0`
+
+[ -r /opt/csw/etc/cfengine3rc ] && . /opt/csw/etc/cfengine3rc
+[ -r /etc/opt/csw/cfengine3rc ] && . /etc/opt/csw/cfengine3rc
+
+OPTS="${CFEXECD_OPTS}"
+
+smf_msg() {
+ if [ -n "${SMF_FMRI}" ]
+ then
+ echo "$I: $@" >&2
+ fi
+}
+
+
+stop() {
+ if [ -r ${PIDFILE} ]
+ then
+ PID=`/bin/cat ${PIDFILE}`
+ /bin/kill ${PID}
+
+ # Now wait until the daemon is shutdown
+ while /bin/kill -0 ${PID} > /dev/null 2>&1
+ do
+ /bin/sleep 1
+ done
+ else
+ smf_msg "No pid file ${PIDFILE} found for ${NAME}. Not killing ${NAME}."
+ fi
+ return 0
+}
+
+start() {
+ if [ -r ${PIDFILE} ]
+ then
+ /bin/kill -0 `/bin/cat ${PIDFILE}` > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ smf_msg "${NAME} already running. Not starting again"
+ return 0
+ fi
+ smf_msg "Remove stale pid file ${PIDFILE} of ${NAME}"
+ rm -f ${PIDFILE}
+ fi
+
+ # Due to CFEngine's locking mechanism, stopping and starting in
+ # fast sequence may fail sometimes. This leads to SMF going into
+ # maintenance when trying to revive a died CFEngine daemon. Thus
+ # we wait some time before starting the daemon, since the start
+ # might be due to 'restart' or a died daemon
+ sleep 2
+
+ smf_msg "Start ${NAME} with options '${OPTS}'"
+
+ ${DAEMON} ${OPTS}
+ retval=$?
+ if [ ${retval} -ne 0 ]
+ then
+ smf_msg "Failed to start ${NAME} with options '${OPTS}'. Exit Code ${retval}."
+ if [ -n "${SMF_FMRI}" ]
+ then
+ exit ${SMF_EXIT_ERR_FATAL}
+ else
+ exit ${retval}
+ fi
+ fi
+
+ smf_msg "Successfuly started ${NAME} with options '${OPTS}'"
+
+ return 0
+}
+
+status() {
+ if [ -r ${PIDFILE} ]
+ then
+ /bin/kill -0 `/bin/cat ${PIDFILE}` > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ echo "${NAME} is running"
+ return 0
+ fi
+ fi
+
+ echo "${NAME} is not running"
+ return 0
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ status)
+ status
+ ;;
+ *)
+ echo "$0 {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+exit 0
Property changes on: csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfexecd
___________________________________________________________________
Added: svn:executable
+ *
Added: csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfmonitord
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfmonitord (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfmonitord 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,122 @@
+#!/sbin/sh
+#
+#
+#RC_KNUM 20
+#RC_SNUM 80
+#RC_KLEV 0,1,2,S
+#RC_SLEV 3
+#AUTOENABLE no
+#FMRI application
+
+
+NAME=cf-monitord
+DAEMON=/opt/csw/sbin/${NAME}
+PIDFILE=/var/opt/csw/cfengine3/${NAME}.pid
+I=`/usr/bin/basename $0`
+
+[ -r /opt/csw/etc/cfengine3rc ] && . /opt/csw/etc/cfengine3rc
+[ -r /etc/opt/csw/cfengine3rc ] && . /etc/opt/csw/cfengine3rc
+
+OPTS="${CFMONITORD_OPTS}"
+
+smf_msg() {
+ if [ -n "${SMF_FMRI}" ]
+ then
+ echo "$I: $@" >&2
+ fi
+}
+
+
+stop() {
+ if [ -r ${PIDFILE} ]
+ then
+ PID=`/bin/cat ${PIDFILE}`
+ /bin/kill ${PID}
+
+ # Now wait until the daemon is shutdown
+ while /bin/kill -0 ${PID} > /dev/null 2>&1
+ do
+ /bin/sleep 1
+ done
+ else
+ smf_msg "No pid file ${PIDFILE} found for ${NAME}. Not killing ${NAME}."
+ fi
+ return 0
+}
+
+start() {
+ if [ -r ${PIDFILE} ]
+ then
+ /bin/kill -0 `/bin/cat ${PIDFILE}` > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ smf_msg "${NAME} already running. Not starting again"
+ return 0
+ fi
+ smf_msg "Remove stale pid file ${PIDFILE} of ${NAME}"
+ rm -f ${PIDFILE}
+ fi
+
+ # Due to CFEngine's locking mechanism, stopping and starting in
+ # fast sequence may fail sometimes. This leads to SMF going into
+ # maintenance when trying to revive a died CFEngine daemon. Thus
+ # we wait some time before starting the daemon, since the start
+ # might be due to 'restart' or a died daemon
+ sleep 2
+
+ smf_msg "Start ${NAME} with options '${OPTS}'"
+
+ ${DAEMON} ${OPTS}
+ retval=$?
+ if [ ${retval} -ne 0 ]
+ then
+ smf_msg "Failed to start ${NAME} with options '${OPTS}'. Exit Code ${retval}."
+ if [ -n "${SMF_FMRI}" ]
+ then
+ exit ${SMF_EXIT_ERR_FATAL}
+ else
+ exit ${retval}
+ fi
+ fi
+
+ smf_msg "Successfuly started ${NAME} with options '${OPTS}'"
+
+ return 0
+}
+
+status() {
+ if [ -r ${PIDFILE} ]
+ then
+ /bin/kill -0 `/bin/cat ${PIDFILE}` > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ echo "${NAME} is running"
+ return 0
+ fi
+ fi
+
+ echo "${NAME} is not running"
+ return 0
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ status)
+ status
+ ;;
+ *)
+ echo "$0 {start|stop|restart|status}"
+ exit 1
+ ;;
+esac
+
+exit 0
Property changes on: csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfmonitord
___________________________________________________________________
Added: svn:executable
+ *
Added: csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfserverd
===================================================================
--- csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfserverd (rev 0)
+++ csw/mgar/pkg/cfengine3/trunk/files/cswcfengine3-cfserverd 2011-11-12 12:02:38 UTC (rev 16169)
@@ -0,0 +1,122 @@
+#!/sbin/sh
+#
+#
+#RC_KNUM 20
+#RC_SNUM 80
+#RC_KLEV 0,1,2,S
+#RC_SLEV 3
+#AUTOENABLE no
+#FMRI network
+
+
+NAME=cf-serverd
+DAEMON=/opt/csw/sbin/${NAME}
+PIDFILE=/var/opt/csw/cfengine3/${NAME}.pid
+I=`/usr/bin/basename $0`
+
+[ -r /opt/csw/etc/cfengine3rc ] && . /opt/csw/etc/cfengine3rc
+[ -r /etc/opt/csw/cfengine3rc ] && . /etc/opt/csw/cfengine3rc
+
+OPTS="${CFSERVERD_OPTS}"
+
+smf_msg() {
+ if [ -n "${SMF_FMRI}" ]
+ then
+ echo "$I: $@" >&2
+ fi
+}
+
+
+stop() {
+ if [ -r ${PIDFILE} ]
+ then
+ PID=`/bin/cat ${PIDFILE}`
+ /bin/kill ${PID}
+
+ # Now wait until the daemon is shutdown
+ while /bin/kill -0 ${PID} > /dev/null 2>&1
+ do
+ /bin/sleep 1
+ done
+ else
+ smf_msg "No pid file ${PIDFILE} found for ${NAME}. Not killing ${NAME}."
+ fi
+ return 0
+}
+
+start() {
+ if [ -r ${PIDFILE} ]
+ then
+ /bin/kill -0 `/bin/cat ${PIDFILE}` > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ smf_msg "${NAME} already running. Not starting again"
+ return 0
+ fi
+ smf_msg "Remove stale pid file ${PIDFILE} of ${NAME}"
+ rm -f ${PIDFILE}
+ fi
+
+ # Due to CFEngine's locking mechanism, stopping and starting in
+ # fast sequence may fail sometimes. This leads to SMF going into
+ # maintenance when trying to revive a died CFEngine daemon. Thus
+ # we wait some time before starting the daemon, since the start
+ # might be due to 'restart' or a died daemon
+ sleep 2
+
+ smf_msg "Start ${NAME} with options '${OPTS}'"
+
+ ${DAEMON} ${OPTS}
+ retval=$?
+ if [ ${retval} -ne 0 ]
+ then
+ smf_msg "Failed to start ${NAME} with options '${OPTS}'. Exit Code ${retval}."
+ if [ -n "${SMF_FMRI}" ]
+ then
+ exit ${SMF_EXIT_ERR_FATAL}
+ else
+ exit ${retval}
+ fi
+ fi
+
+ smf_msg "Successfuly started ${NAME} with options '${OPTS}'"
+
+ return 0
+}
+
+status() {
+ if [ -r ${PIDFILE} ]
+ then
+ /bin/kill -0 `/bin/cat ${PIDFILE}` > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ echo "${NAME} is running"
+ return 0
+ fi
+ fi
+
+ echo "${NAME} is not running"
+ return 0
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ status)
+ status
+ ;;
+ *)
+ echo "$0 {start|stop|restart|status}"
+ exit 1
+ ;;
+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