diff --git a/cf-execd b/cf-execd index 52ea7b0..20b6f7f 100644 --- a/cf-execd +++ b/cf-execd @@ -1,34 +1,185 @@ -#! /bin/sh +#!/bin/bash # -# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # All rights reserved. # -# Author: Petr Ostadal, feedback to http://www.suse.de/feedback +# Author: Christian Wittmer, Scorpio IT, Deidesheim, Germany # # /etc/init.d/cf-execd -# # and its symbolic link -# # /usr/sbin/rccf-execd # +# LSB compatible service control script; see http://www.linuxbase.org/spec/ +# Please send feedback to http://www.suse.de/feedback/ +# +# Note: This template uses functions rc_XXX defined in /etc/rc.status on +# UnitedLinux/SUSE/Novell based Linux distributions. However, it will work +# on other distributions as well, by using the LSB (Linux Standard Base) +# or RH functions or by open coding the needed functions. +# Read http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/ if you prefer not +# to use this template. +# +# chkconfig: 345 60 40 +# description: cfengine's execution agent +# ### BEGIN INIT INFO # Provides: cf-execd -# Required-Start: $local_fs $remote_fs -# Should-Start: $time sendmail -# Required-Stop: $local_fs $remote_fs -# Should-Stop: $time sendmail +# Required-Start: $local_fs $remote_fs $network +# Should-Start: $time smtp +# Required-Stop: $local_fs $remote_fs $network +# Should-Stop: $time smtp # Default-Start: 3 5 # Default-Stop: 0 1 2 6 -# Short-Description: cf-execd daemon is a wrapper for local execution of cfagent -# Description: The cf-execd is a wrapper for local execution of cfagent. -# It may be used to capture cfagent output and send it as mail when run -# cron cron, e.g. +# Short-Description: cfengine's execution agent +# Description: Start cfengine's execution agent +# The executor daemon is a scheduler and wrapper for +# execution of cf-agent. It collects the output of the +# agent and can email it to a specified address. It can +# splay the start time of executions across the network +# and work as a class-based clock for scheduling. ### END INIT INFO +# -cfexecd_BIN=/usr/sbin/cf-execd -test -x $cfexecd_BIN || exit 5 +# Note on runlevels: +# 0 - halt/poweroff 6 - reboot +# 1 - single user 2 - multiuser without network exported +# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm) +# +# Note on script names: +# http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/scrptnames.html +# A registry has been set up to manage the init script namespace. +# http://www.lanana.org/ +# Please use the names already registered or register one or use a +# vendor prefix. -. /etc/rc.status + +# Check for missing binaries (stale symlinks should not happen) +# Note: Special treatment of stop for LSB conformance +CF_EXE_BIN=/usr/sbin/cf-execd +test -x $CF_EXE_BIN || { echo "$CF_EXE_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +## Check for existence of needed config file and read it +#FOO_CONFIG=/etc/sysconfig/FOO +#test -r $FOO_CONFIG || { echo "$FOO_CONFIG not existing"; +# if [ "$1" = "stop" ]; then exit 0; +# else exit 6; fi; } + +## Read config +#. $FOO_CONFIG + +# some VARS +CF_PIDFILE="/var/run/cf-execd.pid" +SVC_NAME="cfengine's execution agent" + +# Source LSB init functions +# providing start_daemon, killproc, pidofproc, +# log_success_msg, log_failure_msg and log_warning_msg. +# This is currently not used by UnitedLinux based distributions and +# not needed for init scripts for UnitedLinux only. If it is used, +# the functions from rc.status should not be sourced or used. +#. /lib/lsb/init-functions + +# 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 be verbose in local rc status and clear it afterwards +# rc_status -v -r ditto and clear both the local and overall rc status +# rc_status -s display "skipped" and exit with status 3 +# rc_status -u display "unused" and exit with status 3 +# rc_failed set local and overall rc status to failed +# rc_failed set local and overall rc status to +# rc_reset clear both the local and overall rc status +# rc_exit exit appropriate to overall rc status +# rc_active checks whether a service is activated by symlinks + +# Use the SUSE rc_ init script functions; +# emulate them on LSB, RH and other systems + +# Default: Assume sysvinit binaries exist +start_daemon() { /sbin/start_daemon ${1+"$@"}; } +killproc() { /sbin/killproc ${1+"$@"}; } +pidofproc() { /sbin/pidofproc ${1+"$@"}; } +checkproc() { /sbin/checkproc ${1+"$@"}; } +if test -e /etc/rc.status; then + # SUSE rc script library + . /etc/rc.status +else + export LC_ALL=POSIX + _cmd=$1 + declare -a _SMSG + if test "${_cmd}" = "status"; then + _SMSG=(running dead dead unused unknown reserved) + _RC_UNUSED=3 + else + _SMSG=(done failed failed missed failed skipped unused failed failed reserved) + _RC_UNUSED=6 + fi + if test -e /lib/lsb/init-functions; then + # LSB + . /lib/lsb/init-functions + echo_rc() + { + if test ${_RC_RV} = 0; then + log_success_msg " [${_SMSG[${_RC_RV}]}] " + else + log_failure_msg " [${_SMSG[${_RC_RV}]}] " + fi + } + # TODO: Add checking for lockfiles + # checkproc() { return pidofproc ${1+"$@"} >/dev/null 2>&1; } + checkproc() { return $( pidofproc ${1+"$@"} >/dev/null 2>&1; echo $?; ); } + elif test -e /etc/init.d/functions; then + # RHAT + . /etc/init.d/functions + echo_rc() + { + #echo -n " [${_SMSG[${_RC_RV}]}] " + if test ${_RC_RV} = 0; then + success " [${_SMSG[${_RC_RV}]}] " + else + failure " [${_SMSG[${_RC_RV}]}] " + fi + } + checkproc() { return $( status ${1+"$@"}; echo $?; ); } + start_daemon() { return $( daemon ${1+"$@"}; echo $?; ); } + else + # emulate it + echo_rc() { echo " [${_SMSG[${_RC_RV}]}] "; } + fi + rc_reset() { _RC_RV=0; } + rc_failed() + { + if test -z "$1"; then + _RC_RV=1; + elif test "$1" != "0"; then + _RC_RV=$1; + fi + return ${_RC_RV} + } + rc_check() + { + return rc_failed $? + } + rc_status() + { + rc_failed $? + if test "$1" = "-r"; then _RC_RV=0; shift; fi + if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi + if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi + if test "$1" = "-v"; then echo_rc; shift; fi + if test "$1" = "-r"; then _RC_RV=0; shift; fi + return ${_RC_RV} + } + rc_exit() { exit ${_RC_RV}; } + rc_active() + { + if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi + if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi + return 1 + } +fi # Reset status of this service rc_reset @@ -51,31 +202,47 @@ rc_reset case "$1" in start) - echo -n "Starting cf-execd " + echo -n "Starting $SVC_NAME " ## Start daemon with startproc(8). If this fails ## the return value is set appropriately by startproc. - - - eval startproc $cfexecd_BIN + start_daemon $CF_EXE_BIN + #start_daemon -p $CF_PIDFILE $CF_EXE_BIN # Remember status and be verbose rc_status -v + + # update PIDFILE + echo $(pidofproc $CF_EXE_BIN) > $CF_PIDFILE ;; stop) - echo -n "Shutting down cf-execd " + echo -n "Shutting down $SVC_NAME " ## Stop daemon with killproc(8) and if this fails ## killproc sets the return value according to LSB. - - killproc -TERM $cfexecd_BIN + ### Usage on RH: killproc [-p pidfile] [ -d delay] {program} [-signal]" + killproc $CF_EXE_BIN -TERM + #killproc -p $CF_PIDFILE $CF_EXE_BIN -TERM # Remember status and be verbose rc_status -v - ;; - try-restart) - ## Do a restart only if the service was active before. - ## Note: try-restart is not (yet) part of LSB (as of 1.2) - $0 status >/dev/null && $0 restart + # remove PIDFILE + if [ -f $CF_PIDFILE ]; then + rm -f $CF_PIDFILE + fi + ;; + try-restart|condrestart) + ## Do a restart only if the service was active before. + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + if test "$1" = "condrestart"; then + echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset # Not running is not a failure. + fi # Remember status and be quiet rc_status ;; @@ -88,11 +255,38 @@ case "$1" in # 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 the service if it + ## is running. + + #echo -n "Reload service $SVC_NAME " + ## if it supports it: + #killproc -HUP $CF_EXE_BIN + #touch /var/run/FOO.pid + #rc_status -v + + ## Otherwise: + $0 try-restart + rc_status + ;; reload) - exit 3 - ;; + ## Like force-reload, but if daemon does not support + ## signaling, do nothing (!) + + # If it supports signaling: + #echo -n "Reload service $SVC_NAME " + #killproc -HUP $CF_EXE_BIN + #touch /var/run/FOO.pid + #rc_status -v + + ## Otherwise if it does not support reload: + rc_failed 3 + rc_status -v + ;; status) - echo -n "Checking for service cf-execd " + echo -n "Checking for service $SVC_NAME " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. @@ -105,13 +299,14 @@ case "$1" in # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) # NOTE: checkproc returns LSB compliant status values. - checkproc $cfexecd_BIN + checkproc $CF_EXE_BIN + #checkproc -p $CF_PIDFILE $CF_EXE_BIN # NOTE: rc_status knows that we called this init script with # "status" option and adapts its messages accordingly. rc_status -v ;; *) - echo "Usage: $0 {start|stop|status|try-restart|restart}" + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" exit 1 ;; esac diff --git a/cf-monitord b/cf-monitord index 2432b3b..c3c1da8 100644 --- a/cf-monitord +++ b/cf-monitord @@ -1,35 +1,186 @@ -#! /bin/sh +#!/bin/bash # -# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # All rights reserved. # -# Author: Petr Ostadal, feedback to http://www.suse.de/feedback +# Author: Christian Wittmer, Scorpio IT, Deidesheim, Germany # # /etc/init.d/cf-monitord -# # and its symbolic link -# # /usr/sbin/rccf-monitord # +# LSB compatible service control script; see http://www.linuxbase.org/spec/ +# Please send feedback to http://www.suse.de/feedback/ +# +# Note: This template uses functions rc_XXX defined in /etc/rc.status on +# UnitedLinux/SUSE/Novell based Linux distributions. However, it will work +# on other distributions as well, by using the LSB (Linux Standard Base) +# or RH functions or by open coding the needed functions. +# Read http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/ if you prefer not +# to use this template. +# +# chkconfig: 345 70 30 +# description: cfengine's monitoring agent +# ### BEGIN INIT INFO # Provides: cf-monitord # Required-Start: $local_fs $remote_fs -# Should-Start: $time sendmail -# Required-Stop: $local_fs $emote_fs -# Should-Stop: $time sendmail +# Should-Start: $time smtp +# Required-Stop: $local_fs $remote_fs +# Should-Stop: $time smtp # Default-Start: 3 5 # Default-Stop: 0 1 2 6 -# Short-Description: cf-monitord daemon for collecting random events -# Description: Start cf-monitord to allow collecting random events, -# which are an excellent source of entropy for random number generation. -# It is used by cfkey program to produce random number from this source -# of randomness. +# Short-Description: cfengine's monitoring agent +# Description: Start cfengine's monitoring agent +# The monitoring agent is a machine-learning, sampling +# daemon which learns the normal state of the current +# host and classifies new observations in terms of the +# patterns formed by previous ones. The data are made +# available to and read by cf-agent for classification +# of responses to anomalous states. ### END INIT INFO +# -cfmonitord_BIN=/usr/sbin/cf-monitord -test -x $cfmonitord_BIN || exit 5 +# Note on runlevels: +# 0 - halt/poweroff 6 - reboot +# 1 - single user 2 - multiuser without network exported +# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm) +# +# Note on script names: +# http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/scrptnames.html +# A registry has been set up to manage the init script namespace. +# http://www.lanana.org/ +# Please use the names already registered or register one or use a +# vendor prefix. -. /etc/rc.status + +# Check for missing binaries (stale symlinks should not happen) +# Note: Special treatment of stop for LSB conformance +CF_MON_BIN=/usr/sbin/cf-monitord +test -x $CF_MON_BIN || { echo "$CF_MON_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +## Check for existence of needed config file and read it +#FOO_CONFIG=/etc/sysconfig/FOO +#test -r $FOO_CONFIG || { echo "$FOO_CONFIG not existing"; +# if [ "$1" = "stop" ]; then exit 0; +# else exit 6; fi; } + +## Read config +#. $FOO_CONFIG + +# some VARS +CF_PIDFILE="/var/run/cf-monitord.pid" +SVC_NAME="cfengine's monitoring agent" + +# Source LSB init functions +# providing start_daemon, killproc, pidofproc, +# log_success_msg, log_failure_msg and log_warning_msg. +# This is currently not used by UnitedLinux based distributions and +# not needed for init scripts for UnitedLinux only. If it is used, +# the functions from rc.status should not be sourced or used. +#. /lib/lsb/init-functions + +# 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 be verbose in local rc status and clear it afterwards +# rc_status -v -r ditto and clear both the local and overall rc status +# rc_status -s display "skipped" and exit with status 3 +# rc_status -u display "unused" and exit with status 3 +# rc_failed set local and overall rc status to failed +# rc_failed set local and overall rc status to +# rc_reset clear both the local and overall rc status +# rc_exit exit appropriate to overall rc status +# rc_active checks whether a service is activated by symlinks + +# Use the SUSE rc_ init script functions; +# emulate them on LSB, RH and other systems + +# Default: Assume sysvinit binaries exist +start_daemon() { /sbin/start_daemon ${1+"$@"}; } +killproc() { /sbin/killproc ${1+"$@"}; } +pidofproc() { /sbin/pidofproc ${1+"$@"}; } +checkproc() { /sbin/checkproc ${1+"$@"}; } +if test -e /etc/rc.status; then + # SUSE rc script library + . /etc/rc.status +else + export LC_ALL=POSIX + _cmd=$1 + declare -a _SMSG + if test "${_cmd}" = "status"; then + _SMSG=(running dead dead unused unknown reserved) + _RC_UNUSED=3 + else + _SMSG=(done failed failed missed failed skipped unused failed failed reserved) + _RC_UNUSED=6 + fi + if test -e /lib/lsb/init-functions; then + # LSB + . /lib/lsb/init-functions + echo_rc() + { + if test ${_RC_RV} = 0; then + log_success_msg " [${_SMSG[${_RC_RV}]}] " + else + log_failure_msg " [${_SMSG[${_RC_RV}]}] " + fi + } + # TODO: Add checking for lockfiles + # checkproc() { return pidofproc ${1+"$@"} >/dev/null 2>&1; } + checkproc() { return $( pidofproc ${1+"$@"} >/dev/null 2>&1; echo $?; ); } + elif test -e /etc/init.d/functions; then + # RHAT + . /etc/init.d/functions + echo_rc() + { + #echo -n " [${_SMSG[${_RC_RV}]}] " + if test ${_RC_RV} = 0; then + success " [${_SMSG[${_RC_RV}]}] " + else + failure " [${_SMSG[${_RC_RV}]}] " + fi + } + checkproc() { return $( status ${1+"$@"}; echo $?; ); } + start_daemon() { return $( daemon ${1+"$@"}; echo $?; ); } + else + # emulate it + echo_rc() { echo " [${_SMSG[${_RC_RV}]}] "; } + fi + rc_reset() { _RC_RV=0; } + rc_failed() + { + if test -z "$1"; then + _RC_RV=1; + elif test "$1" != "0"; then + _RC_RV=$1; + fi + return ${_RC_RV} + } + rc_check() + { + return rc_failed $? + } + rc_status() + { + rc_failed $? + if test "$1" = "-r"; then _RC_RV=0; shift; fi + if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi + if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi + if test "$1" = "-v"; then echo_rc; shift; fi + if test "$1" = "-r"; then _RC_RV=0; shift; fi + return ${_RC_RV} + } + rc_exit() { exit ${_RC_RV}; } + rc_active() + { + if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi + if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi + return 1 + } +fi # Reset status of this service rc_reset @@ -52,31 +203,46 @@ rc_reset case "$1" in start) - echo -n "Starting cf-monitord " + echo -n "Starting $SVC_NAME " ## Start daemon with startproc(8). If this fails ## the return value is set appropriately by startproc. - - - eval startproc $cfmonitord_BIN + start_daemon $CF_MON_BIN + #start_daemon -p $CF_PIDFILE $CF_MON_BIN # Remember status and be verbose rc_status -v + + # update PIDFILE + echo $(pidofproc $CF_MON_BIN) > $CF_PIDFILE ;; stop) - echo -n "Shutting down cf-monitord " + echo -n "Shutting down $SVC_NAME " ## Stop daemon with killproc(8) and if this fails ## killproc sets the return value according to LSB. - - killproc -TERM $cfmonitord_BIN + killproc $CF_MON_BIN -TERM + killproc -p $CF_PIDFILE $CF_MON_BIN -TERM # Remember status and be verbose rc_status -v - ;; - try-restart) - ## Do a restart only if the service was active before. - ## Note: try-restart is not (yet) part of LSB (as of 1.2) - $0 status >/dev/null && $0 restart + # remove PIDFILE + if [ -f $CF_PIDFILE ]; then + rm -f $CF_PIDFILE + fi + ;; + try-restart|condrestart) + ## Do a restart only if the service was active before. + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + if test "$1" = "condrestart"; then + echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset # Not running is not a failure. + fi # Remember status and be quiet rc_status ;; @@ -89,11 +255,38 @@ case "$1" in # 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 the service if it + ## is running. + + #echo -n "Reload service $SVC_NAME " + ## if it supports it: + #killproc -HUP $CF_MON_BIN + #touch /var/run/FOO.pid + #rc_status -v + + ## Otherwise: + $0 try-restart + rc_status + ;; reload) - exit 3 - ;; + ## Like force-reload, but if daemon does not support + ## signaling, do nothing (!) + + # If it supports signaling: + #echo -n "Reload service $SVC_NAME " + #killproc -HUP $CF_MON_BIN + #touch /var/run/FOO.pid + #rc_status -v + + ## Otherwise if it does not support reload: + rc_failed 3 + rc_status -v + ;; status) - echo -n "Checking for service cf-monitord " + echo -n "Checking for service $SVC_NAME " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. @@ -106,13 +299,14 @@ case "$1" in # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) # NOTE: checkproc returns LSB compliant status values. - checkproc $cfmonitord_BIN + checkproc $CF_MON_BIN + #checkproc -p $CF_PIDFILE $CF_MON_BIN # NOTE: rc_status knows that we called this init script with # "status" option and adapts its messages accordingly. rc_status -v ;; *) - echo "Usage: $0 {start|stop|status|try-restart|restart}" + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" exit 1 ;; esac diff --git a/cf-serverd b/cf-serverd index 4b91f28..c5a27c4 100644 --- a/cf-serverd +++ b/cf-serverd @@ -1,34 +1,185 @@ -#! /bin/sh +#!/bin/bash # -# Copyright (c) 2005 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # All rights reserved. # -# Author: Petr Ostadal, feedback to http://www.suse.de/feedback +# Author: Christian Wittmer, Scorpio IT, Deidesheim, Germany # # /etc/init.d/cf-serverd -# # and its symbolic link -# # /usr/sbin/rccf-serverd # +# LSB compatible service control script; see http://www.linuxbase.org/spec/ +# Please send feedback to http://www.suse.de/feedback/ +# +# Note: This template uses functions rc_XXX defined in /etc/rc.status on +# UnitedLinux/SUSE/Novell based Linux distributions. However, it will work +# on other distributions as well, by using the LSB (Linux Standard Base) +# or RH functions or by open coding the needed functions. +# Read http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/ if you prefer not +# to use this template. +# +# chkconfig: 345 60 40 +# description: cfengine's server agent +# ### BEGIN INIT INFO # Provides: cf-serverd # Required-Start: $local_fs $remote_fs -# Should-Start: $time sendmail -# Required-Stop: $local_fs $remote_fs -# Should-Stop: $time sendmail +# Should-Start: $time smtp +# Required-Stop: $local_fs $remote_fs +# Should-Stop: $time smtp # Default-Start: 3 5 # Default-Stop: 0 1 2 6 -# Short-Description: cf-serverd daemon for starting cfengine remotely -# Description: The cf-serverd is a file server and protective wrapper for -# starting cfengine remotely. It performs access control based on RSA -# authentication and IP address. +# Short-Description: cfengine's server agent +# Description: Start cfengine's execution agent +# The server daemon provides two services: it acts as a +# file server for remote file copying and it allows an +# authorized cf-runagent to start start a cf-agent process +# and set certain additional classes with role-based access +# control. ### END INIT INFO +# -cfserverd_BIN=/usr/sbin/cf-serverd -test -x $cfserverd_BIN || exit 5 +# Note on runlevels: +# 0 - halt/poweroff 6 - reboot +# 1 - single user 2 - multiuser without network exported +# 3 - multiuser w/ network (text mode) 5 - multiuser w/ network and X11 (xdm) +# +# Note on script names: +# http://www.linuxbase.org/spec/refspecs/LSB_1.3.0/gLSB/gLSB/scrptnames.html +# A registry has been set up to manage the init script namespace. +# http://www.lanana.org/ +# Please use the names already registered or register one or use a +# vendor prefix. -. /etc/rc.status + +# Check for missing binaries (stale symlinks should not happen) +# Note: Special treatment of stop for LSB conformance +CF_SRV_BIN=/usr/sbin/cf-serverd +test -x $CF_SRV_BIN || { echo "$CF_SRV_BIN not installed"; + if [ "$1" = "stop" ]; then exit 0; + else exit 5; fi; } + +## Check for existence of needed config file and read it +#FOO_CONFIG=/etc/sysconfig/FOO +#test -r $FOO_CONFIG || { echo "$FOO_CONFIG not existing"; +# if [ "$1" = "stop" ]; then exit 0; +# else exit 6; fi; } + +## Read config +#. $FOO_CONFIG + +# some VARS +CF_PIDFILE="/var/run/cf-serverd.pid" +SVC_NAME="cfengine's server agent" + +# Source LSB init functions +# providing start_daemon, killproc, pidofproc, +# log_success_msg, log_failure_msg and log_warning_msg. +# This is currently not used by UnitedLinux based distributions and +# not needed for init scripts for UnitedLinux only. If it is used, +# the functions from rc.status should not be sourced or used. +#. /lib/lsb/init-functions + +# 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 be verbose in local rc status and clear it afterwards +# rc_status -v -r ditto and clear both the local and overall rc status +# rc_status -s display "skipped" and exit with status 3 +# rc_status -u display "unused" and exit with status 3 +# rc_failed set local and overall rc status to failed +# rc_failed set local and overall rc status to +# rc_reset clear both the local and overall rc status +# rc_exit exit appropriate to overall rc status +# rc_active checks whether a service is activated by symlinks + +# Use the SUSE rc_ init script functions; +# emulate them on LSB, RH and other systems + +# Default: Assume sysvinit binaries exist +start_daemon() { /sbin/start_daemon ${1+"$@"}; } +killproc() { /sbin/killproc ${1+"$@"}; } +pidofproc() { /sbin/pidofproc ${1+"$@"}; } +checkproc() { /sbin/checkproc ${1+"$@"}; } +if test -e /etc/rc.status; then + # SUSE rc script library + . /etc/rc.status +else + export LC_ALL=POSIX + _cmd=$1 + declare -a _SMSG + if test "${_cmd}" = "status"; then + _SMSG=(running dead dead unused unknown reserved) + _RC_UNUSED=3 + else + _SMSG=(done failed failed missed failed skipped unused failed failed reserved) + _RC_UNUSED=6 + fi + if test -e /lib/lsb/init-functions; then + # LSB + . /lib/lsb/init-functions + echo_rc() + { + if test ${_RC_RV} = 0; then + log_success_msg " [${_SMSG[${_RC_RV}]}] " + else + log_failure_msg " [${_SMSG[${_RC_RV}]}] " + fi + } + # TODO: Add checking for lockfiles + # checkproc() { return pidofproc ${1+"$@"} >/dev/null 2>&1; } + checkproc() { return $( pidofproc ${1+"$@"} >/dev/null 2>&1; echo $?; ); } + elif test -e /etc/init.d/functions; then + # RHAT + . /etc/init.d/functions + echo_rc() + { + #echo -n " [${_SMSG[${_RC_RV}]}] " + if test ${_RC_RV} = 0; then + success " [${_SMSG[${_RC_RV}]}] " + else + failure " [${_SMSG[${_RC_RV}]}] " + fi + } + checkproc() { return $( status ${1+"$@"}; echo $?; ); } + start_daemon() { return $( daemon ${1+"$@"}; echo $?; ); } + else + # emulate it + echo_rc() { echo " [${_SMSG[${_RC_RV}]}] "; } + fi + rc_reset() { _RC_RV=0; } + rc_failed() + { + if test -z "$1"; then + _RC_RV=1; + elif test "$1" != "0"; then + _RC_RV=$1; + fi + return ${_RC_RV} + } + rc_check() + { + return rc_failed $? + } + rc_status() + { + rc_failed $? + if test "$1" = "-r"; then _RC_RV=0; shift; fi + if test "$1" = "-s"; then rc_failed 5; echo_rc; rc_failed 3; shift; fi + if test "$1" = "-u"; then rc_failed ${_RC_UNUSED}; echo_rc; rc_failed 3; shift; fi + if test "$1" = "-v"; then echo_rc; shift; fi + if test "$1" = "-r"; then _RC_RV=0; shift; fi + return ${_RC_RV} + } + rc_exit() { exit ${_RC_RV}; } + rc_active() + { + if test -z "$RUNLEVEL"; then read RUNLEVEL REST < <(/sbin/runlevel); fi + if test -e /etc/init.d/S[0-9][0-9]${1}; then return 0; fi + return 1 + } +fi # Reset status of this service rc_reset @@ -51,31 +202,47 @@ rc_reset case "$1" in start) - echo -n "Starting cf-serverd " + echo -n "Starting $SVC_NAME " ## Start daemon with startproc(8). If this fails ## the return value is set appropriately by startproc. - - - eval startproc $cfserverd_BIN + start_daemon $CF_SRV_BIN + #start_daemon -p $CF_PIDFILE $CF_SRV_BIN # Remember status and be verbose rc_status -v + + # update PIDFILE + echo $(pidofproc $CF_SRV_BIN) > $CF_PIDFILE ;; stop) - echo -n "Shutting down cf-serverd " + echo -n "Shutting down $SVC_NAME " ## Stop daemon with killproc(8) and if this fails ## killproc sets the return value according to LSB. - - killproc -TERM $cfserverd_BIN + ### Usage on RH: killproc [-p pidfile] [ -d delay] {program} [-signal]" + killproc $CF_SRV_BIN -TERM + #killproc -p $CF_PIDFILE $CF_SRV_BIN -TERM # Remember status and be verbose rc_status -v - ;; - try-restart) - ## Do a restart only if the service was active before. - ## Note: try-restart is not (yet) part of LSB (as of 1.2) - $0 status >/dev/null && $0 restart + # remove PIDFILE + if [ -f $CF_PIDFILE ]; then + rm -f $CF_PIDFILE + fi + ;; + try-restart|condrestart) + ## Do a restart only if the service was active before. + ## Note: try-restart is now part of LSB (as of 1.9). + ## RH has a similar command named condrestart. + if test "$1" = "condrestart"; then + echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" + fi + $0 status + if test $? = 0; then + $0 restart + else + rc_reset # Not running is not a failure. + fi # Remember status and be quiet rc_status ;; @@ -88,11 +255,38 @@ case "$1" in # 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 the service if it + ## is running. + + #echo -n "Reload service $SVC_NAME " + ## if it supports it: + #killproc -HUP $CF_SRV_BIN + #touch /var/run/FOO.pid + #rc_status -v + + ## Otherwise: + $0 try-restart + rc_status + ;; reload) - exit 3 - ;; + ## Like force-reload, but if daemon does not support + ## signaling, do nothing (!) + + # If it supports signaling: + #echo -n "Reload service $SVC_NAME " + #killproc -HUP $CF_SRV_BIN + #touch /var/run/FOO.pid + #rc_status -v + + ## Otherwise if it does not support reload: + rc_failed 3 + rc_status -v + ;; status) - echo -n "Checking for service cf-serverd " + echo -n "Checking for service $SVC_NAME " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. @@ -105,13 +299,14 @@ case "$1" in # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.) # NOTE: checkproc returns LSB compliant status values. - checkproc $cfserverd_BIN + checkproc $CF_SRV_BIN + #checkproc -p $CF_PIDFILE $CF_SRV_BIN # NOTE: rc_status knows that we called this init script with # "status" option and adapts its messages accordingly. rc_status -v ;; *) - echo "Usage: $0 {start|stop|status|try-restart|restart}" + echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" exit 1 ;; esac diff --git a/cf3-Reference.pdf b/cf3-Reference.pdf new file mode 100644 index 0000000..dc3e855 --- /dev/null +++ b/cf3-Reference.pdf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a523780fff9f66811e29f10a9642d0653cd6c09ca55558717bd3e02470cfea2e +size 7522390 diff --git a/cfengine-3.0.5p1.tar.bz2 b/cfengine-3.0.5p1.tar.bz2 deleted file mode 100644 index 20c9b57..0000000 --- a/cfengine-3.0.5p1.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6e987f2ed81186dbb616eaca11130faf5365e0412a83ca84bc90dac49b747bff -size 1191652 diff --git a/cfengine-3.2.0.tar.gz b/cfengine-3.2.0.tar.gz new file mode 100644 index 0000000..aeca510 --- /dev/null +++ b/cfengine-3.2.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6212488d9b68d585bcc27766309f646d2ca576374777752c238c0e7e5e8b6a1 +size 1139534 diff --git a/cfengine.changes b/cfengine.changes index 5a67c03..b5a65c2 100644 --- a/cfengine.changes +++ b/cfengine.changes @@ -1,3 +1,105 @@ +------------------------------------------------------------------- +Fri Sep 30 20:07:48 UTC 2011 - coolo@suse.com + +- add libtool as buildrequire to make the spec file more reliable + +------------------------------------------------------------------- +Sat Sep 17 22:48:09 UTC 2011 - jengelh@medozas.de + +- Remove redundant tags/sections from specfile + +------------------------------------------------------------------- +Wed Aug 31 17:42:52 UTC 2011 - chris@computersalat.de + +- lib pkging policy + * new subpkg: libpromises1, devel + * disable-static lib +- rpmlint + * incorrect-fsf-address + * run-level 4, init scripts +- subpkg doc + * documentation + * added cf3-Reference.pdf as {S:1} + +------------------------------------------------------------------- +Mon Aug 29 09:24:29 UTC 2011 - chris@computersalat.de + +- update to 3.2.0 + * New bootstrap method with single-command bootstrapping: + - cf-agent --bootstrap --policy-server 123.456.789.123 + - Associated policy template files are added, partially maintained + by CFEngine + - See for upgrade procedure + * Bug fixes for file-editing, package versioning, and embedded + database corruption (We recommend using TokyoCabinet instead of + BerkeleyDB if building from source). + * Improved upgrade path for Nova. + * Patches for improved run-agent concurrency + * Reorganization of documentation and community resources + * 100% on regression test suite on 3 operating systems + (Ubuntu, Debian, SuSE on x86-64 hardware) + * Support for multiple release environments + * package_policy update and addupdate now check if user-supplied + version is larger than currently installed - updates only if so + * Help text of cf-report -r corrected - a list of key hashes is + required, not ip addresses. + * New Emacs mode for CFEngine policy files (thanks to Ted Zlatanov!) + - After beta 1: + * Warnings are on edit_line changes can now give greater degree of information + without spamming promise logs + * Class expressions parser accepts '||' as an alias for '|' again. + * Invalidation of package list cache on installation/removal of + packages. + - After beta 2: + * New option cf-key -r to remove host key by IP or hostname. + * Added detection of network interfaces which belong to BSD jails. + * Improve robustness of multi-threaded code, in particular fix + problems with spurious acces denials in server and losing of + authentication rules after policy reload. + * cf-promises accepts option -b matching cf-agent, which causes it + to do not complain about missing bundlesequence. + * New functions and(), not(), or() and concat() to ease use of + ifvarclass() clause. + * Full list of issues fixed is available on + https://cfengine.com/bugtracker/changelog_page.php +- some cleanup + * ./configure .... -> %configure with default datadir + * macro usage + * use default install to docdir, add missing AUTHORS, LICENSE + +------------------------------------------------------------------- +Wed Aug 24 15:07:33 UTC 2011 - chris@computersalat.de + +- fix init scripts + o RH, CentOS: fix return of checkproc, start_daemon + +------------------------------------------------------------------- +Tue Aug 9 15:56:24 UTC 2011 - chris@computersalat.de + +- update init scripts + o complete rewrite, used skeleton.compat + +------------------------------------------------------------------- +Mon Aug 8 15:52:16 UTC 2011 - chris@computersalat.de + +- update to 3.1.5 + * New class parser, '||' is no longer allowed in expressions (use '|'). + * Class setting in the promise types insert_lines, delete_lines, + replace_patterns, field_edits, vars, classes is restored. + * suspiciousnames implemented. + * New function getvalues(). + * New functions parse{read,int,string}array to match + read{read,int,string}array. + * Testsuite added to check for core functionality. + * Syslog prefix is fixed to say 'cf3' instead of 'community'. +- see ChangeLog file for more info +- {name} macro +- add BuildReq postgresql-devel (PostgreSQL connector) +- remove Author from desc +- no autoreconf +- keep libs +- build support for CentOS, RHEL + ------------------------------------------------------------------- Mon Aug 23 15:10:03 CEST 2010 - anicka@suse.cz diff --git a/cfengine.spec b/cfengine.spec index b428773..625b853 100644 --- a/cfengine.spec +++ b/cfengine.spec @@ -1,7 +1,7 @@ # -# spec file for package cfengine (Version 3.0.5p1) +# spec file for package cfengine # -# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -15,24 +15,37 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # -# norootforbuild Name: cfengine -BuildRequires: bison db-devel flex mysql-devel openssl-devel pcre-devel texlive +%define libname libpromises +%define libsoname %{libname}1 + +Summary: A Tool to Maintain Complicated Networks +Version: 3.2.0 +Release: 1 License: GPLv2+ Group: Productivity/Networking/System -AutoReqProv: on -Version: 3.0.5p1 -Release: 1 -Summary: A Tool to Maintain Complicated Networks Url: http://www.cfengine.org/ -Source: %{name}-%{version}.tar.bz2 +Source: %{name}-%{version}.tar.gz +Source1: http://www.cfengine.org/manuals/cf3-Reference.pdf Source2: cf-monitord Source3: cf-execd Source4: cf-serverd BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: bison +BuildRequires: db-devel +BuildRequires: flex +BuildRequires: libtool +BuildRequires: mysql-devel +BuildRequires: openssl-devel +BuildRequires: pcre-devel +BuildRequires: postgresql-devel + +%if 0%{?suse_version} PreReq: %install_info_prereq +BuildRequires: texlive +%endif %description GNU cfengine is an abstract programming language for system @@ -40,66 +53,145 @@ administrators of huge heterogeneous networks. With cfengine, system administrators have an easy and elegant way to maintain complicated networks. +%package -n %{libsoname} +Summary: Shared library of cfengine +Group: System/Libraries +%description -n %{libsoname} +This package contains the shared libpromises (cfengine) library. + +%package devel +Summary: Development package for cfengine +Group: Development/Libraries/C and C++ +Requires: %{libsoname} = %{version} +Requires: glibc-devel + +%description devel +A high-speed character set detection library + +This package contains the files needed to compile programs that use the +libguess library. + +%package doc +Summary: A Tool to Maintain Complicated Networks (docs) +Group: Productivity/Networking/System +%if 0%{?rhel_version} || 0%{?centos_version} +BuildRequires: texinfo +BuildRequires: tetex tetex-dvips tetex-latex +%endif + +%description doc +Full documentation for cfengine -Authors: --------- - Mark Burgess %prep %setup -q +##### rpmlint +#### wrong-file-end-of-line-encoding +#### incorrect-fsf-address +### http://www.fsf.org/about/contact/ +find ./examples -type f -name "*.cf" -exec perl -p -i -e 's|\r\n|\n|,s|^# Foundation.*|# Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA|' {} \; %build +%if 0%{?suse_version} %{suse_update_config -f} -autoreconf -fi -CC=gcc CFLAGS="$RPM_OPT_FLAGS" \ - ./configure --prefix=/usr \ - --libdir=%{_libdir} \ - --mandir=%{_mandir} \ - --infodir=%{_infodir} \ - --datadir=/var/lib/cfengine/inputs \ - --docdir=%{_docdir}/cfengine \ - --with-workdir=/var/lib/cfengine -make +%endif +#autoreconf -fi +CC=gcc CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" \ +%configure \ + --disable-static \ + --docdir=%{_docdir}/%{name} \ + --with-workdir=/var/lib/%{name} +%{__make} %{?_smp_mflags} + +# --datadir=/var/lib/%{name}/inputs \ %install -make "DESTDIR=$RPM_BUILD_ROOT" install -install -d $RPM_BUILD_ROOT/{usr/sbin,etc/init.d} -install -m 744 %{S:2} %{S:3} %{S:4} $RPM_BUILD_ROOT/etc/init.d/ -ln -sf ../../etc/init.d/cf-monitord $RPM_BUILD_ROOT/%{_sbindir}/rccf-monitord -ln -sf ../../etc/init.d/cf-execd $RPM_BUILD_ROOT/%{_sbindir}/rccf-execd -ln -sf ../../etc/init.d/cf-serverd $RPM_BUILD_ROOT/%{_sbindir}/rccf-serverd -mkdir -p $RPM_BUILD_ROOT/var/lib/cfengine/bin -ln -sf ../../../../usr/sbin/cf-promises $RPM_BUILD_ROOT/var/lib/cfengine/bin/cf-promises -rm -rf $RPM_BUILD_ROOT/%{_libdir}/libpromises.la -rm -rf $RPM_BUILD_ROOT/%{_libdir}/libpromises.a -mkdir -p $RPM_BUILD_ROOT/var/lib/cfengine/inputs/ -cp $RPM_BUILD_ROOT/usr/share/doc/packages/cfengine/inputs/* $RPM_BUILD_ROOT/var/lib/cfengine/inputs/ -chmod 0644 $RPM_BUILD_ROOT/var/lib/cfengine/inputs/* +%if 0%{?rhel_version} || 0%{?centos_version} || 0%{?fedora_version} +[ -d %{buildroot} ] && [ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot} +%endif +%{__make} "DESTDIR=%{buildroot}" install +%{__install} -d %{buildroot}/{usr/sbin,etc/init.d,/var/lib/%{name}/bin} -%clean -[ -d %{buildroot} -a "%{buildroot}" != "" ] && rm -rf %{buildroot} +# install missing AUTHORS LICENSE {S:1} +%{__install} -m0644 AUTHORS LICENSE %{S:1} %{buildroot}/%{_docdir}/%{name}/ -%post -%install_info --name=cfengine --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz +# install init scripts +%{__install} -m 0755 %{S:2} %{S:3} %{S:4} %{buildroot}/etc/init.d/ +%{__ln_s} -f ../../etc/init.d/cf-monitord %{buildroot}/%{_sbindir}/rccf-monitord +%{__ln_s} -f ../../etc/init.d/cf-execd %{buildroot}/%{_sbindir}/rccf-execd +%{__ln_s} -f ../../etc/init.d/cf-serverd %{buildroot}/%{_sbindir}/rccf-serverd +%{__ln_s} -f ../../../..%{_sbindir}/cf-promises %{buildroot}/var/lib/%{name}/bin/cf-promises -%postun -%install_info_delete --name=cfengine --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz -%insserv_cleanup +## FIXME: what is the purpose of theses libs ? +## are they really needed ? +#rm -rf %{buildroot}/%{_libdir}/libpromises.la +#{__rm} -rf %{buildroot}/%{_libdir}/libpromises.a %preun %stop_on_removal cf-monitord %stop_on_removal cf-serverd %stop_on_removal cf-execd +%post +%if 0%{?suse_version} +%if 0%{?suse_version} > 1010 +%install_info --name=%{name} --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz +%else +: +%endif +%else +%install_info --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz +%endif +/sbin/ldconfig + +%postun +%if 0%{?suse_version} +%if 0%{?suse_version} > 1010 +%install_info_delete --name=%{name} --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz +%else +: +%endif +%else +%install_info_delete --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz +%endif +%insserv_cleanup +/sbin/ldconfig +for i in execd monitord serverd; do + %restart_on_update cf-${i} +done + +%post -n %{libsoname} -p /sbin/ldconfig + +%postun -n %{libsoname} -p /sbin/ldconfig + %files %defattr(-,root,root) -%doc AUTHORS ChangeLog README COPYING +%{_docdir}/%{name}/LICENSE +%exclude %{_docdir}/%{name}/AUTHORS +%exclude %{_docdir}/%{name}/ChangeLog +%exclude %{_docdir}/%{name}/README +%exclude %{_docdir}/%{name}/example_config +%exclude %{_docdir}/%{name}/examples /usr/sbin/* +%{_datadir}/%{name} %{_mandir}/man?/* -%dir /var/lib/cfengine -/var/lib/cfengine/* -%config(noreplace) /var/lib/cfengine/inputs/* -%attr(0755,root,root) %config /etc/init.d/* +%dir /var/lib/%{name} +/var/lib/%{name}/* +%config %attr(0755,root,root) /etc/init.d/* + +%files -n %{libsoname} +%defattr(-,root,root) +%{_libdir}/%{libname}.la +%{_libdir}/%{libname}.so.* + +%files devel +%defattr(-,root,root) +%{_libdir}/%{libname}.so + +%files doc +%defattr(-,root,root) +%{_docdir}/%{name} +%exclude %{_docdir}/%{name}/LICENSE %changelog