From 4e8d09d05069baf219f474509a52041c863cca5d Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Wed, 7 Dec 2011 13:17:37 -0600
Subject: runit-scripts: additional scripts -certmaster -func -powermate
 -rsyslog -xymon

---
 abs/core/runit-scripts/PKGBUILD                    |  2 +-
 .../runitscripts/services/certmaster/run           | 29 +++++++++
 .../runit-scripts/runitscripts/services/funcd/run  | 20 ++++++
 .../runitscripts/services/hobbit-client/run        | 74 ----------------------
 .../runit-scripts/runitscripts/services/hobbit/run |  9 ---
 .../runitscripts/services/powermate/finish         | 21 ++++++
 .../runitscripts/services/powermate/run            |  7 ++
 .../runitscripts/services/rsyslog/run              | 10 +++
 .../runitscripts/services/xymon-client/run         | 60 ++++++++++++++++++
 .../runitscripts/services/xymon-server/run         |  9 +++
 10 files changed, 157 insertions(+), 84 deletions(-)
 create mode 100644 abs/core/runit-scripts/runitscripts/services/certmaster/run
 create mode 100644 abs/core/runit-scripts/runitscripts/services/funcd/run
 delete mode 100755 abs/core/runit-scripts/runitscripts/services/hobbit-client/run
 delete mode 100755 abs/core/runit-scripts/runitscripts/services/hobbit/run
 create mode 100644 abs/core/runit-scripts/runitscripts/services/powermate/finish
 create mode 100644 abs/core/runit-scripts/runitscripts/services/powermate/run
 create mode 100644 abs/core/runit-scripts/runitscripts/services/rsyslog/run
 create mode 100644 abs/core/runit-scripts/runitscripts/services/xymon-client/run
 create mode 100644 abs/core/runit-scripts/runitscripts/services/xymon-server/run

diff --git a/abs/core/runit-scripts/PKGBUILD b/abs/core/runit-scripts/PKGBUILD
index 3792e08..95f7b05 100755
--- a/abs/core/runit-scripts/PKGBUILD
+++ b/abs/core/runit-scripts/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=runit-scripts
 pkgver=2.1.1
-pkgrel=39
+pkgrel=41
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license="BSD"
diff --git a/abs/core/runit-scripts/runitscripts/services/certmaster/run b/abs/core/runit-scripts/runitscripts/services/certmaster/run
new file mode 100644
index 0000000..0f5add7
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/certmaster/run
@@ -0,0 +1,29 @@
+#!/bin/bash
+if [ ! -e /etc/pki/certmaster/ca/certmaster.key ]
+then
+    /usr/bin/certmaster daemon
+    while [ ! -e /etc/pki/certmaster/ca/certmaster.key ]
+    do
+	sleep 5
+    done
+    killall -9 certmaster
+fi
+    setfacl --remove-all /etc/pki/certmaster/ca/certmaster.key
+
+    for i in nobody http
+    do 
+       setfacl -d -R -m u:$i:rX /etc/pki/certmaster/
+       setfacl -R -m u:$i:rX /etc/pki/certmaster/
+
+       setfacl -R -m  mask:rwx /etc/pki/certmaster/
+       setfacl -R -m u:$i:rX /etc/pki/certmaster/ca/certmaster.key
+
+       setfacl -d -R -m u:$i:rX /var/lib/certmaster
+       setfacl -R -m u:$i:rX /var/lib/certmaster
+       setfacl -d -R -m u:$i:rX /var/lib/certmaster/certmaster
+       setfacl -R -m u:$i:rX /var/lib/certmaster/certmaster
+       setfacl -d -R -m u:$i:rX /var/lib/certmaster/certmaster/certs
+       setfacl -R -m u:$i:rX /var/lib/certmaster/certmaster/certs
+   done 
+
+exec  /usr/bin/certmaster
diff --git a/abs/core/runit-scripts/runitscripts/services/funcd/run b/abs/core/runit-scripts/runitscripts/services/funcd/run
new file mode 100644
index 0000000..adc57ae
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/funcd/run
@@ -0,0 +1,20 @@
+#!/bin/bash
+setfacl --remove-all /etc/pki/certmaster/ca/certmaster.key
+
+for i in nobody http
+do 
+  setfacl -d -R -m u:$i:rX /etc/pki/certmaster/
+  setfacl -R -m u:$i:rX /etc/pki/certmaster/
+         
+  setfacl -R -m  mask:rwx /etc/pki/certmaster/
+  setfacl -R -m u:$i:rX /etc/pki/certmaster/ca/certmaster.key
+
+  setfacl -d -R -m u:$i:rX /var/lib/certmaster
+  setfacl -R -m u:$i:rX /var/lib/certmaster
+  setfacl -d -R -m u:$i:rX /var/lib/certmaster/certmaster
+  setfacl -R -m u:$i:rX /var/lib/certmaster/certmaster
+  setfacl -d -R -m u:$i:rX /var/lib/certmaster/certmaster/certs
+  setfacl -R -m u:$i:rX /var/lib/certmaster/certmaster/certs
+done
+
+DISPLAY=127.0.0.1:0  exec  /usr/bin/funcd
diff --git a/abs/core/runit-scripts/runitscripts/services/hobbit-client/run b/abs/core/runit-scripts/runitscripts/services/hobbit-client/run
deleted file mode 100755
index a28c6f8..0000000
--- a/abs/core/runit-scripts/runitscripts/services/hobbit-client/run
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-export TERM=linux
-. /etc/rc.conf
-. /etc/rc.d/functions
-stat_runit "Starting hobbit client"
-
-#----------------------------------------------------------------------------#
-# Hobbit client bootup script.                                               #
-#                                                                            #
-# This invokes hobbitlaunch, which in turn runs the Hobbit client and any    #
-# extensions configured.                                                     #
-#                                                                            #
-# Copyright (C) 2005-2006 Henrik Storner <henrik@hswn.dk>                    #
-# "status" section (C) Scott Smith 2006                                      #
-#                                                                            #
-# This program is released under the GNU General Public License (GPL),       #
-# version 2. See the file "COPYING" for details.                             #
-#                                                                            #
-#----------------------------------------------------------------------------#
-#
-# $Id: runclient.sh,v 1.13 2006/07/14 21:25:19 henrik Rel $
-
-# Default settings for this client
-MACHINEDOTS="`uname -n`"			# This systems hostname
-BBOSTYPE="`uname -s | tr '[A-Z]' '[a-z]'`"	# This systems operating system in lowercase
-BBOSSCRIPT="hobbitclient-$BBOSTYPE.sh"
-
-# Commandline mods for the defaults
-while test "$1" != ""
-do
-	case "$1" in
-	  --hostname=*)
-	  	MACHINEDOTS="`echo $1 | sed -e 's/--hostname=//'`"
-		;;
-	  --os=*)
-	  	BBOSTYPE="`echo $1 | sed -e 's/--os=//' | tr '[A-Z]' '[a-z]'`"
-		;;
-	  --class=*)
-	        CONFIGCLASS="`echo $1 | sed -e 's/--class=//' | tr '[A-Z]' '[a-z]'`"
-		;;
-	  --help)
-	  	echo "Usage: $0 [--hostname=CLIENTNAME] [--os=rhel3|linux22] [--class=CLASSNAME] start|stop"
-		exit 0
-		;;
-	  start)
-	  	CMD=$1
-		;;
-	  stop)
-	  	CMD=$1
-		;;
-	  restart)
-	  	CMD=$1
-		;;
-	  status)
-	  	CMD=$1
-		;;
-	esac
-
-	shift
-done
-
-OLDDIR="`pwd`"
-cd "`dirname $0`"
-HOBBITCLIENTHOME="/data/srv/hobbit/client"
-cd "$OLDDIR"
-
-MACHINE="`echo $MACHINEDOTS | sed -e 's/\./,/g'`"
-
-export MACHINE MACHINEDOTS BBOSTYPE BBOSSCRIPT HOBBITCLIENTHOME CONFIGCLASS
-
-
-
-su nobody -c "$HOBBITCLIENTHOME/bin/hobbitlaunch --config=$HOBBITCLIENTHOME/etc/clientlaunch.cfg --log=$HOBBITCLIENTHOME/logs/clientlaunch.log --pidfile=$HOBBITCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid --no-daemon"
-
diff --git a/abs/core/runit-scripts/runitscripts/services/hobbit/run b/abs/core/runit-scripts/runitscripts/services/hobbit/run
deleted file mode 100755
index d36243b..0000000
--- a/abs/core/runit-scripts/runitscripts/services/hobbit/run
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-exec 2>&1
-export TERM=linux
-. /etc/rc.conf
-. /etc/rc.d/functions
-stat_runit "Starting hobbit server"
-
-
-exec su nobody -c "/data/srv/hobbit/server/bin/hobbitlaunch --config=/data/srv/hobbit/server/etc/hobbitlaunch.cfg --env=/data/srv/hobbit/server/etc/hobbitserver.cfg --log=/var/log/hobbit/hobbitlaunch.log --pidfile=/var/log/hobbit/hobbitlaunch.pid --no-daemon"
diff --git a/abs/core/runit-scripts/runitscripts/services/powermate/finish b/abs/core/runit-scripts/runitscripts/services/powermate/finish
new file mode 100644
index 0000000..b1d27fd
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/powermate/finish
@@ -0,0 +1,21 @@
+#!/bin/bash
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /usr/MythVantage/bin/install_functions.sh
+
+[ -e /etc/sv/powermate/.runtime ] || mkdir -p /etc/sv/powermate/.runtime
+touch /etc/sv/powermate/.runtime/`date +%s`
+numfiles=`/usr/bin/file_time_offset.py   -s4 -d/etc/sv/powermate/.runtime `
+if [ $numfiles -gt 3 ]
+then
+	 rm -f /etc/sv/powermate/.runtime/* 2>/dev/null
+	 sv stop powermate
+	 printhl "    powermate is not able to start, disabling it"
+fi
+
+
+
+
+
+ in_kernel_support "enable"
diff --git a/abs/core/runit-scripts/runitscripts/services/powermate/run b/abs/core/runit-scripts/runitscripts/services/powermate/run
new file mode 100644
index 0000000..f33a769
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/powermate/run
@@ -0,0 +1,7 @@
+#!/bin/sh
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+stat_runit "powermate support"
+
+DISPLAY=127.0.0.1:0  /usr/LH/bin/powermate-myth.py 
diff --git a/abs/core/runit-scripts/runitscripts/services/rsyslog/run b/abs/core/runit-scripts/runitscripts/services/rsyslog/run
new file mode 100644
index 0000000..e7b018d
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/rsyslog/run
@@ -0,0 +1,10 @@
+#!/bin/sh
+exec 2>&1
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+stat_runit "Starting rsyslog"
+
+
+exec /usr/sbin/rsyslogd -n -c5
+
diff --git a/abs/core/runit-scripts/runitscripts/services/xymon-client/run b/abs/core/runit-scripts/runitscripts/services/xymon-client/run
new file mode 100644
index 0000000..a454c6b
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/xymon-client/run
@@ -0,0 +1,60 @@
+#!/bin/sh
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+stat_runit "Starting xymon client"
+
+
+
+# Default settings for this client
+MACHINEDOTS="`uname -n`"                        # This systems hostname
+SERVEROSTYPE="`uname -s | tr '[ABCDEFGHIJKLMNOPQRSTUVWXYZ/]' '[abcdefghijklmnopqrstuvwxyz_]'`"  # This systems operating system in lowercase
+XYMONOSSCRIPT="xymonclient-$SERVEROSTYPE.sh"
+
+# Command-line mods for the defaults
+while test "$1" != ""
+do
+        case "$1" in
+          --hostname=*)
+                MACHINEDOTS="`echo $1 | sed -e 's/--hostname=//'`"
+                ;;
+          --os=*)
+                SERVEROSTYPE="`echo $1 | sed -e 's/--os=//' | tr '[ABCDEFGHIJKLMNOPQRSTUVWXYZ/]' '[abcdefghijklmnopqrstuvwxyz_]'`"
+                ;;
+          --class=*)
+                CONFIGCLASS="`echo $1 | sed -e 's/--class=//' | tr '[ABCDEFGHIJKLMNOPQRSTUVWXYZ/]' '[abcdefghijklmnopqrstuvwxyz_]'`"
+                ;;
+          --help)
+                echo "Usage: $0 [--hostname=CLIENTNAME] [--os=rhel3|linux22] [--class=CLASSNAME] start|stop"
+                exit 0
+                ;;
+          start)
+                CMD=$1
+                ;;
+          stop)
+                CMD=$1
+                ;;
+          restart)
+                CMD=$1
+                ;;
+          status)
+                CMD=$1
+                ;;
+        esac
+
+        shift
+done
+
+XYMONCLIENTHOME="`dirname $0`"
+XYMONCLIENTHOME="/data/srv/xymon/client"
+export MACHINEDOTS SERVEROSTYPE XYMONOSSCRIPT XYMONCLIENTHOME CONFIGCLASS
+
+MACHINE="`echo $MACHINEDOTS | sed -e 's/\./,/g'`"
+export MACHINE
+
+
+sudo -u nobody  MACHINE=$MACHINE XYMONCLIENTHOME=$XYMONCLIENTHOME $XYMONCLIENTHOME/bin/xymonlaunch --config=$XYMONCLIENTHOME/etc/clientlaunch.cfg --log=$XYMONCLIENTHOME/logs/clientlaunch.log --pidfile=$XYMONCLIENTHOME/logs/clientlaunch.$MACHINEDOTS.pid --no-daemon
+
+
+
+
diff --git a/abs/core/runit-scripts/runitscripts/services/xymon-server/run b/abs/core/runit-scripts/runitscripts/services/xymon-server/run
new file mode 100644
index 0000000..b850c0a
--- /dev/null
+++ b/abs/core/runit-scripts/runitscripts/services/xymon-server/run
@@ -0,0 +1,9 @@
+#!/bin/sh
+exec 2>&1
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+stat_runit "Starting xymon server"
+
+
+exec sudo -u nobody  /data/srv/xymon/server/bin/xymonlaunch --config=/data/srv/xymon/server/etc/tasks.cfg --env=/data/srv/xymon/server/etc/xymonserver.cfg --log=/var/log/hobbit/xymonlaunch.log --pidfile=/var/log/hobbit/xymonlaunch.pid --no-daemon
-- 
cgit v0.12

