#!/usr/bin/env bash # PROVIDE: zenoss # REQUIRE: mysql # KEYWORD: SHUTDOWN # # Add the following to /etc/rc.conf to enable this service # # zenoss_enable="YES" # ### ### STRAIGHT OUT OF THE zenoss original Linux script ### Modified by Beto Meijome - beto@octantis.com.au for FreeBSD (rcNG) ### # # Zenoss is a monitoring program written by Zenoss, Inc. . /etc/rc.subr name="zenoss" rcvar=`set_rcvar` start_cmd="ze_start" stop_cmd="ze_stop" status_cmd="ze_status" restart_cmd="ze_restart" extra_commands="restart status" my_scriptname="/usr/local/etc/rc.d/$name" # read configuration and set defaults load_rc_config "$name" : ${zenoss_enable="NO"} if [ -z "$ZENHOME" ] ; then for d in $HOME /home/zenoss ; do for f in .bash_login .bash_profile .profile .bashrc ; do if [ -z "$ZENHOME" ] ; then [ -f $d/$f ] && . $d/$f fi done done fi if [ -z "$ZENHOME" ] ; then ZENHOME=/usr/local/zenoss; export ZENHOME fi if [ `id -u` -eq 0 ] ; then USERNAME=`ls -l $ZENHOME/var/Data.fs | awk '{ print $3 }'` if [ "$USERNAME" = "root" -o -z "$USERNAME" ] ; then echo Unable to determine the right user to run zenoss exit 1 fi chown -R $USERNAME $ZENHOME/var exec sudo -u $USERNAME $my_scriptname $@ fi . $ZENHOME/bin/zenfunctions C= C="$C zeoctl" C="$C zopectl" C="$C zenxevent" C="$C zenmodeler" C="$C zenperfsnmp" C="$C zenperfxmlrpc" C="$C zenprocess" C="$C zenping" C="$C zensyslog" C="$C zenstatus" C="$C zenactions" C="$C zentrap" C="$C zencommand" CMDS=$C reverse() { args= for i do args="$i $args" shift done echo $args } clean_FUNC() { ## The OTHER zenoss rc scripts dont understand BSD faststart , forcestart,etc... ##need to collapse them into start or stop ## But we (BSD) need the full cmd, so we dont modify FUNC case "$FUNC" in faststart) FUNC2="start" ;; forcestart) FUNC2="start" ;; faststop) FUNC2="stop" ;; forcestop) FUNC2="stop" ;; *) FUNC2=$FUNC ;; esac } FUNC=$CMD issue() { #Cleanup FUNC for zenoss original scripts. # Original FUNC is left as is. clean_FUNC for cmd in $CMDS do echo -n "Daemon: $cmd " $ZENHOME/bin/$cmd "$FUNC2" done } ze_start(){ issue } ze_stop(){ CMDS=`reverse $CMDS` issue } ze_restart(){ CMDS=`reverse $CMDS` FUNC=stop issue CMDS=`reverse $CMDS` FUNC=start issue } ze_status(){ issue } run_rc_command "$CMD"