summaryrefslogtreecommitdiffstats
path: root/scripts/cobbler_syslogd
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cobbler_syslogd')
-rwxr-xr-xscripts/cobbler_syslogd52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/cobbler_syslogd b/scripts/cobbler_syslogd
new file mode 100755
index 00000000..86e77e15
--- /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()
+