summaryrefslogtreecommitdiffstats
path: root/ipa-server/ipa-gui/ipa_webgui
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2008-01-18 16:20:36 -0500
committerRob Crittenden <rcritten@redhat.com>2008-01-18 16:20:36 -0500
commit042fb11fa107718a831d468d16188e02f6ae3712 (patch)
treee0e8ee6701800b8f03702cb338f8efa211b18046 /ipa-server/ipa-gui/ipa_webgui
parentaaa3cfd58ca0c62325d7637b67c6711660624f5d (diff)
downloadfreeipa-042fb11fa107718a831d468d16188e02f6ae3712.tar.gz
freeipa-042fb11fa107718a831d468d16188e02f6ae3712.tar.xz
freeipa-042fb11fa107718a831d468d16188e02f6ae3712.zip
Fix issues reported by rpmlint.
- Removing shebangs (#!) from a bunch of python libraries - Don't use a variable name in init scripts for the lock file - Keep the init script name consistent with the binary name, so renamed ipa-kpasswd.init to ipa_kpasswd.init - Add status option to the init scripts - Move most python scripts out of /usr/share/ipa and into the python site-packages directories (ipaserver and ipaclient) - Remove unnecessary sys.path.append("/usr/share/ipa") - Fix the license string in the spec files - Rename ipa-webgui to ipa_webgui everywhere - Fix a couple of issues reported by pychecker in ipa-python
Diffstat (limited to 'ipa-server/ipa-gui/ipa_webgui')
-rw-r--r--ipa-server/ipa-gui/ipa_webgui110
1 files changed, 110 insertions, 0 deletions
diff --git a/ipa-server/ipa-gui/ipa_webgui b/ipa-server/ipa-gui/ipa_webgui
new file mode 100644
index 000000000..c496d7cc9
--- /dev/null
+++ b/ipa-server/ipa-gui/ipa_webgui
@@ -0,0 +1,110 @@
+#! /usr/bin/python -E
+#
+# Copyright (C) 2007 Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; version 2 only
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+import os, sys
+
+def daemonize():
+ # fork once so the parent can exit
+ try:
+ pid = os.fork()
+ except OSError, e:
+ raise Exception, "%s [%d]" % (e.strerror, e.errno)
+
+ if pid != 0:
+ os._exit(0)
+
+ # become session leader
+ os.setsid()
+
+ # fork again to reparent to init
+ try:
+ pid = os.fork()
+ except OSError, e:
+ raise Exception, "%s [%d]" % (e.strerror, e.errno)
+
+ if pid != 0:
+ os._exit(0)
+
+ os.chdir("/")
+ os.umask(0)
+
+ import resource
+ maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
+ if (maxfd == resource.RLIM_INFINITY):
+ maxfd = 1024
+
+ # close all file descriptors
+ for fd in range(0, maxfd):
+ try:
+ os.close(fd)
+ except OSError:
+ pass
+
+ # stdin
+ os.open("/dev/null", os.O_RDWR)
+ # stdout
+ os.open("/dev/null", os.O_RDWR)
+ # stderr
+ os.open("/dev/null", os.O_RDWR)
+
+def main():
+ # To make development easier, we detect if we are in the development
+ # environment to load a different configuration and avoid becoming
+ # a daemon
+ devel = False
+ if os.path.exists(os.path.join(os.path.dirname(__file__), "Makefile.am")):
+ devel = True
+
+ if not devel:
+ try:
+ daemonize()
+ except Exception, e:
+ sys.stderr.write("error becoming daemon: " + str(e))
+ sys.exit(1)
+
+ sys.path.append("/usr/share/ipa/")
+
+ # this must be after sys.path is changed to work correctly
+ import pkg_resources
+ pkg_resources.require("TurboGears")
+ pkg_resources.require("ipa_gui")
+
+
+ from turbogears import update_config, start_server
+ import cherrypy
+ cherrypy.lowercase_api = True
+
+ # Load the config - look for a local file first for development
+ # and then the system config file
+ if devel:
+ update_config(configfile="dev.cfg",
+ modulename="ipagui.config")
+ else:
+ update_config(configfile="/usr/share/ipa/ipa_webgui.cfg",
+ modulename="ipagui.config.app")
+
+ from ipagui.controllers import Root
+
+ start_server(Root())
+
+try:
+ main()
+except Exception, e:
+ print "failed to start web gui: %s" % str(e)
+ sys.exit(1)