summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-03-19 18:56:59 -0400
committerJim Meyering <jim@meyering.net>2007-03-19 18:56:59 -0400
commit6d6082d62d7e5fdc4014455a09316de9e36b6786 (patch)
treeaa484d1d2ed01f9fbcb39b372e9f26f7e35e67ba /scripts
parent3797448bd957a39f43432d3399a5e2482cec533a (diff)
downloadthird_party-cobbler-6d6082d62d7e5fdc4014455a09316de9e36b6786.tar.gz
third_party-cobbler-6d6082d62d7e5fdc4014455a09316de9e36b6786.tar.xz
third_party-cobbler-6d6082d62d7e5fdc4014455a09316de9e36b6786.zip
Most of these diffs come from directory reorg/cleanup, though the main feature here is the start of a better --import command that creates significantly shorter paths and can work more reliably on mounted DVD images (losetup or otherwise). Detection of kickstarts based on paths needs to be augmented by additional means for this to really work. However, changes going in here (and still more to come) result in cleaner names for imported profiles, and substantially shorter kernel option command lines, which is needed to keep under the 255 limit. There is also some work here going in to template out all of the files for PXE, reducing the amount of code in action_sync and also making PXE setups much more customizable (menu choices, titles, random parameters, ipappend 2, etc) without patching the source. "tree" on import is also attached now to the distro, not the profile. So, whew, that's a lot.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cobbler20
-rwxr-xr-xscripts/cobbler_syslogd52
-rwxr-xr-xscripts/cobblersyslogd92
-rwxr-xr-xscripts/watcher.py63
4 files changed, 227 insertions, 0 deletions
diff --git a/scripts/cobbler b/scripts/cobbler
new file mode 100755
index 0000000..4aef615
--- /dev/null
+++ b/scripts/cobbler
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+
+"""
+Wrapper for cobbler
+
+Copyright 2006, Red Hat, Inc
+Michael DeHaan <mdehaan@redhat.com>
+
+This software may be freely redistributed under the terms of the GNU
+general public license.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+import sys
+import cobbler.cobbler as app
+sys.exit(app.main())
+
diff --git a/scripts/cobbler_syslogd b/scripts/cobbler_syslogd
new file mode 100755
index 0000000..86e77e1
--- /dev/null
+++ b/scripts/cobbler_syslogd
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+"""
+Wrapper for cobbler's remote syslog watching daemon.
+
+Copyright 2006, Red Hat, Inc
+Michael DeHaan <mdehaan@redhat.com>
+
+This software may be freely redistributed under the terms of the GNU
+general public license.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+import sys
+import os
+import cobbler.syslog_watcher as app
+
+if __name__ == "__main__":
+
+ #############################################
+ # daemonizing code: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012
+ try:
+ pid = os.fork()
+ if pid > 0:
+ # exit first parent
+ sys.exit(0)
+ except OSError, e:
+ print >>sys.stderr, "fork #1 failed: %d (%s)" % (e.errno, e.strerror)
+ sys.exit(1)
+
+ # decouple from parent environment
+ os.chdir("/")
+ os.setsid()
+ os.umask(0)
+
+ # do second fork
+ try:
+ pid = os.fork()
+ if pid > 0:
+ # print "Daemon PID %d" % pid
+ sys.exit(0)
+ except OSError, e:
+ print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror)
+ sys.exit(1)
+
+ #################
+
+ app.main()
+
diff --git a/scripts/cobblersyslogd b/scripts/cobblersyslogd
new file mode 100755
index 0000000..b8bc3f7
--- /dev/null
+++ b/scripts/cobblersyslogd
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# cobblersyslogd Cobbler kickstart status monitor
+#
+# chkconfig: 345 99 99
+# description: This is a daemon which monitors and logs remote syslog traffic \
+# from machines being provisioned from cobbler. \
+# See http://cobbler.et.redhat.com
+#
+# processname: /usr/bin/cobbler_syslogd
+
+# Sanity checks.
+[ -x /usr/bin/cobbler_syslogd ] || exit 0
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+start() {
+ echo -n $"Starting cobbler remote syslog monitor: "
+ if test -f /var/lock/subsys/cobblersyslogd ; then
+ echo_failure
+ echo
+ return 1
+ fi
+ /usr/bin/cobbler_syslogd
+ RETVAL=$?
+ echo_success
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cobblersyslogd
+ return $RETVAL
+}
+
+
+stop() {
+ echo -n $"Stopping cobbler remote syslog monitor: "
+ if ! test -f /var/lock/subsys/cobblersyslogd ; then
+ echo_failure
+ echo
+ return 1
+ fi
+ pkill cobbler_syslogd
+ RETVAL=$?
+ rm /var/lock/subsys/cobblersyslogd
+ echo_success
+ echo
+ return $RETVAL
+}
+
+mystatus() {
+ if test -f /var/lock/subsys/cobblersyslogd ; then
+ echo "cobbbler_syslogd is running..."
+ return 0
+ fi
+ echo "cobbler_syslogd is stopped"
+ echo
+ return 0
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ mystatus
+ RETVAL=$?
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ condrestart)
+ if [ -f /var/lock/subsys/cobblersyslogd ]; then
+ stop
+ start
+ fi
+ ;;
+ reload)
+ echo "can't reload configuration, you have to restart it"
+ RETVAL=$?
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+ ;;
+esac
+exit $RETVAL
+
diff --git a/scripts/watcher.py b/scripts/watcher.py
new file mode 100755
index 0000000..1074458
--- /dev/null
+++ b/scripts/watcher.py
@@ -0,0 +1,63 @@
+# cobbler mod_python handler for observing kickstart activity
+#
+# Copyright 2007, Red Hat, Inc
+# Michael DeHaan <mdehaan@redhat.com>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import time
+from mod_python import apache
+
+def outputfilter(filter):
+
+
+ # extract important info
+ request = filter.req
+ connection = request.connection
+ (address,port) = connection.remote_addr
+
+ # open the logfile (directory be set writeable by installer)
+ logfile = open("/var/log/cobbler/kicklog/%s" % address,"a+")
+
+ log_it = True
+ if request.the_request.find("cobbler_track") == -1 and request.the_request.find("ctr/") == -1":
+ log_it = False
+
+ if log_it:
+ # write the timestamp
+ t = time.localtime()
+ seconds = str(time.mktime(t))
+ logfile.write(seconds)
+ logfile.write("\t")
+ timestr = str(time.asctime(t))
+ logfile.write(timestr)
+ logfile.write("\t")
+
+ # write the IP address of the client
+ logfile.write(address)
+ logfile.write("\t")
+
+ # write the filename being requested
+ logfile.write(request.the_request)
+ # logfile.write(request.filename)
+ logfile.write("\n")
+
+ # if requesting this file, don't return it
+ if request.the_request.find("watcher.py") != -1:
+ filter.close()
+ return
+
+ # pass-through filter
+ s = filter.read()
+ while s:
+ filter.write(s)
+ s = filter.read()
+ if s is None:
+ filter.close()
+ logfile.close()
+