mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-09 07:43:01 -06:00
679343594d
Install the turbogears web gui including an init script. This patch includes a few related changes: * create a production configuration * rename the web gui startup scrip to ipa-webgui * add an init script * chkconfig on the ipa-webgui init script * make the start script properly daemonize the app when not in a development directory. * Install everything to the correct places (/usr/sbin/ipa-webgui and /usr/share/ipa/ipagui mainly). There are some things still left to do: * Sort out the logging - the config needs to be adjusted so that logging messages end up in /var/log.
100 lines
2.5 KiB
Python
100 lines
2.5 KiB
Python
#! /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():
|
|
pid = os.fork()
|
|
if pid != 0:
|
|
os._exit(0)
|
|
# become session leader
|
|
os.setsid()
|
|
|
|
# fork again to reparent to init
|
|
pid = os.fork()
|
|
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)
|
|
|
|
# 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")):
|
|
devel = True
|
|
|
|
if not devel:
|
|
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
|
|
|
|
if not devel:
|
|
try:
|
|
daemonize()
|
|
except Exception, e:
|
|
sys.stderr.write("error becoming daemon: " + str(e))
|
|
sys.exit(1)
|
|
|
|
start_server(Root())
|
|
|
|
|
|
|
|
|
|
|