[X2Go-Commits] [x2gobroker] 01/03: Provide configuration alternative to having /etc/defaults/* scripts parsed in by init scripts. Make X2Go Session Broker ready for being run via systemd.

git-admin at x2go.org git-admin at x2go.org
Mon Feb 24 10:57:47 CET 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gobroker.

commit 6c1febecda29cf05ef4ec4a90cb7b3ed3b298bdd
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Mon Feb 24 10:41:58 2014 +0100

    Provide configuration alternative to having /etc/defaults/* scripts parsed in by init scripts. Make X2Go Session Broker ready for being run via systemd.
---
 debian/changelog         |    3 ++
 etc/broker/defaults.conf |   85 ++++++++++++++++++++++++++++++++++++++++++++++
 x2gobroker/defaults.py   |   60 ++++++++++++++++++++++++++++++++
 3 files changed, 148 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 04a875e..97cd1b2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -80,6 +80,9 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low
     - Be more precise in Debian et al. init scripts when checking if the service
       is already running.
     - Add JSON WebUI backend for X2Go Session Broker.
+    - Provide configuration alternative to having /etc/defaults/* scripts parsed
+      in by init scripts. Make X2Go Session Broker ready for being run via
+      systemd.
   * debian/control:
     + Replace LDAP support with session brokerage support in LONG_DESCRIPTION.
     + Fix SYNOPSIS texts.
diff --git a/etc/broker/defaults.conf b/etc/broker/defaults.conf
new file mode 100644
index 0000000..f2b1031
--- /dev/null
+++ b/etc/broker/defaults.conf
@@ -0,0 +1,85 @@
+[common]
+# X2Go Broker Session Broker (common) configuration for Debian
+
+# The posix user/group ID the broker runs under (do not change!)
+# if you change those nonetheless, make sure that the log file
+# directory (default: /var/log/x2gobroker) and files in there are
+# writable by that user
+#X2GOBROKER_DAEMON_USER=x2gobroker
+#X2GOBROKER_DAEMON_GROUP=x2gobroker
+
+# The posix user under which the x2gobroker-agent can be launched on
+# remote X2Go Servers.
+#X2GOBROKER_AGENT_USER=x2gobroker
+
+# Control debug mode (0=disable, 1=enable).
+#
+# Apart from verbose logging in /var/log/x2gobroker/*.log, this will
+# also make the broker available through http GET method requests
+# (otherwise: POST method requests only) and you will be able to test
+# the broker through your web browser
+#
+# This value has an effect on all (Python-based) X2Go Session Broker
+# services and can be overridden in /etc/default/x2gobroker-* files.
+#X2GOBROKER_DEBUG=0
+
+# Default X2Go Session Broker backend (available: zeroconf, inifile)
+#X2GOBROKER_DEFAULT_BACKEND=inifile
+
+# Path to the X2Go Session Broker's configuration file
+#X2GOBROKER_CONFIG=/etc/x2go/x2gobroker.conf
+
+# Path to the X2Go Session Broker's session profiles file (when using the inifile backend)
+#X2GOBROKER_SESSIONPROFILES=/etc/x2go/broker/x2gobroker-sessionprofiles.conf
+
+# Path to the X2Go Session Broker's agent command
+#X2GOBROKER_AGENT_CMD=/usr/lib/x2go/x2gobroker-agent
+
+# The unix socket file for communication between the broker and the authentication service.
+#X2GOBROKER_AUTHSERVICE_SOCKET=/run/x2gobroker/x2gobroker-authservice.socket
+
+[daemon]
+# X2Go Session Broker configuration for Debian
+
+# Bind standalone daemon to this address:port
+#DAEMON_BIND_ADDRESS=127.0.0.1:8080
+
+# Control debug mode (0=disable, 1=enable).
+#
+# Apart from verbose logging in /var/log/x2gobroker/*.log, this will
+# also make the broker available through http GET method requests
+# (otherwise: POST method requests only) and you will be able to
+# test the broker through your web browser.
+#
+# This option can also be configured in /etc/default/python-x2go.
+# The value configured here overrides the value from python-x2go
+# defaults and only sets the x2gobroker-daemon into debug mode.
+#X2GOBROKER_DEBUG=0
+
+##########################################################
+###                                                    ###
+### Enable SSL Support                                 ###
+###   o You have to create your own SSL certificates   ###
+###   o You have to actively uncomment the below SSL   ###
+###     relevant line to enable https:// in x2gobroker ###
+###                                                    ###
+##########################################################
+
+# SSL certificate file
+#X2GOBROKER_SSL_CERTFILE=/etc/x2go/broker/ssl/broker.crt
+
+# SSL key file (ensure permissions are set to root:x2gobroker:0640)
+#X2GOBROKER_SSL_KEYFILE=/etc/x2go/broker/ssl/broker.key
+
+[authservice]
+# X2Go Session Broker (PAM Authentication Service) configuration for Debian
+
+# Control debug mode (0=disable, 1=enable) of the X2Go Broker Authentication
+# Service.
+#
+# Logging is (by default) written to /var/log/x2gobroker/*log.
+#
+# This option can also be configured in /etc/default/python-x2go.
+# The value configured here overrides the value from python-x2go
+# defaults and only sets the x2gobroker-authservice into debug mode.
+#X2GOBROKER_DEBUG=0
diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py
index d4b0593..e65fd31 100644
--- a/x2gobroker/defaults.py
+++ b/x2gobroker/defaults.py
@@ -21,21 +21,41 @@
 
 # modules
 import os
+import sys
 import uuid
 import getpass
 import socket
+import ConfigParser
 
 import logging
 from loggers import logger_broker, logger_access, logger_error, X2GOBROKER_DAEMON_USER
 
 X2GOBROKER_USER =  getpass.getuser()
 
+PROG_NAME = os.path.basename(sys.argv[0])
+
+iniconfig_loaded = None
+iniconfig_section = '-'.join(PROG_NAME.split('-')[1:])
+X2GOBROKER_DEFAULTS = "/etc/x2go/broker/defaults.conf"
+if os.path.isfile(X2GOBROKER_DEFAULTS) and os.access(X2GOBROKER_DEFAULTS, os.R_OK):
+    iniconfig = ConfigParser.SafeConfigParser()
+    iniconfig.optionxform = str
+    iniconfig_loaded = iniconfig.read(X2GOBROKER_DEFAULTS)
+
 if os.environ.has_key('X2GOBROKER_DAEMON_GROUP'):
     X2GOBROKER_DAEMON_GROUP=os.environ['X2GOBROKER_DAEMON_GROUP']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DAEMON_GROUP'):
+    X2GOBROKER_DAEMON_GROUP=iniconfig.get(iniconfig_section, 'X2GOBROKER_DAEMON_GROUP')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DAEMON_GROUP'):
+    X2GOBROKER_DAEMON_GROUP=iniconfig.get('common', 'X2GOBROKER_DAEMON_GROUP')
 else:
     X2GOBROKER_DAEMON_GROUP="x2gobroker"
 if os.environ.has_key('X2GOBROKER_AGENT_USER'):
     X2GOBROKER_AGENT_USER=os.environ['X2GOBROKER_AGENT_USER']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AGENT_USER'):
+    X2GOBROKER_AGENT_USER=iniconfig.get(iniconfig_section, 'X2GOBROKER_AGENT_USER')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AGENT_USER'):
+    X2GOBROKER_AGENT_USER=iniconfig.get('common', 'X2GOBROKER_AGENT_USER')
 else:
     X2GOBROKER_AGENT_USER="x2gobroker"
 
@@ -45,14 +65,26 @@ else:
 
 if os.environ.has_key('X2GOBROKER_DEBUG'):
     X2GOBROKER_DEBUG = ( os.environ['X2GOBROKER_DEBUG'].lower() in ('1', 'on', 'true', 'yes', ) )
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DEBUG'):
+    X2GOBROKER_DEBUG=iniconfig.get(iniconfig_section, 'X2GOBROKER_DEBUG')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DEBUG'):
+    X2GOBROKER_DEBUG=iniconfig.get('common', 'X2GOBROKER_DEBUG')
 else:
     X2GOBROKER_DEBUG = False
 if os.environ.has_key('X2GOBROKER_DEBUG_INTERACTIVELY'):
     X2GOBROKER_DEBUG_INTERACTIVELY = ( os.environ['X2GOBROKER_DEBUG_INTERACTIVELY'].lower() in ('1', 'on', 'true', 'yes', ) )
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DEBUG_INTERACTIVELY'):
+    X2GOBROKER_DEBUG_INTERACTIVELY=iniconfig.get(iniconfig_section, 'X2GOBROKER_DEBUG_INTERACTIVELY')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DEBUG_INTERACTIVELY'):
+    X2GOBROKER_DEBUG_INTERACTIVELY=iniconfig.get('common', 'X2GOBROKER_DEBUG_INTERACTIVELY')
 else:
     X2GOBROKER_DEBUG_INTERACTIVELY = False
 if os.environ.has_key('X2GOBROKER_TESTSUITE'):
     X2GOBROKER_TESTSUITE = ( os.environ['X2GOBROKER_TESTSUITE'].lower() in ('1', 'on', 'true', 'yes', ) )
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_TESTSUITE'):
+    X2GOBROKER_TESTSUITE=iniconfig.get(iniconfig_section, 'X2GOBROKER_TESTSUITE')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_TESTSUITE'):
+    X2GOBROKER_TESTSUITE=iniconfig.get('common', 'X2GOBROKER_TESTSUITE')
 else:
     X2GOBROKER_TESTSUITE = False
 
@@ -68,21 +100,37 @@ if X2GOBROKER_TESTSUITE:
 
 if os.environ.has_key('X2GOBROKER_CONFIG'):
     X2GOBROKER_CONFIG = os.environ['X2GOBROKER_CONFIG']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_CONFIG'):
+    X2GOBROKER_CONFIG=iniconfig.get(iniconfig_section, 'X2GOBROKER_CONFIG')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_CONFIG'):
+    X2GOBROKER_CONFIG=iniconfig.get('common', 'X2GOBROKER_CONFIG')
 else:
     X2GOBROKER_CONFIG = "/etc/x2go/x2gobroker.conf"
 
 if os.environ.has_key('X2GOBROKER_SESSIONPROFILES'):
     X2GOBROKER_SESSIONPROFILES = os.environ['X2GOBROKER_SESSIONPROFILES']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_SESSIONPROFILES'):
+    X2GOBROKER_SESSIONPROFILES=iniconfig.get(iniconfig_section, 'X2GOBROKER_SESSIONPROFILES')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_SESSIONPROFILES'):
+    X2GOBROKER_SESSIONPROFILES=iniconfig.get('common', 'X2GOBROKER_SESSIONPROFILES')
 else:
     X2GOBROKER_SESSIONPROFILES = "/etc/x2go/broker/x2gobroker-sessionprofiles.conf"
 
 if os.environ.has_key('X2GOBROKER_AGENT_CMD'):
     X2GOBROKER_AGENT_CMD = os.environ['X2GOBROKER_AGENT_CMD']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AGENT_CMD'):
+    X2GOBROKER_AGENT_CMD=iniconfig.get(iniconfig_section, 'X2GOBROKER_AGENT_CMD')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AGENT_CMD'):
+    X2GOBROKER_AGENT_CMD=iniconfig.get('common', 'X2GOBROKER_AGENT_CMD')
 else:
     X2GOBROKER_AGENT_CMD = "/usr/lib/x2go/x2gobroker-agent"
 
 if os.environ.has_key('X2GOBROKER_AUTHSERVICE_SOCKET'):
     X2GOBROKER_AUTHSERVICE_SOCKET=os.environ['X2GOBROKER_AUTHSERVICE_SOCKET']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_SOCKET'):
+    X2GOBROKER_AUTHSERVICE_SOCKET=iniconfig.get(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_SOCKET')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AUTHSERVICE_SOCKET'):
+    X2GOBROKER_AUTHSERVICE_SOCKET=iniconfig.get('common', 'X2GOBROKER_AUTHSERVICE_SOCKET')
 else:
     if os.path.isdir('/run'):
         RUNDIR = '/run'
@@ -92,16 +140,28 @@ else:
 
 if os.environ.has_key('X2GOBROKER_DEFAULT_BACKEND'):
     X2GOBROKER_DEFAULT_BACKEND = os.environ['X2GOBROKER_DEFAULT_BACKEND']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DEFAULT_BACKEND'):
+    X2GOBROKER_DEFAULT_BACKEND=iniconfig.get(iniconfig_section, 'X2GOBROKER_DEFAULT_BACKEND')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DEFAULT_BACKEND'):
+    X2GOBROKER_DEFAULT_BACKEND=iniconfig.get('common', 'X2GOBROKER_DEFAULT_BACKEND')
 else:
     X2GOBROKER_DEFAULT_BACKEND = "inifile"
 
 if os.environ.has_key('X2GOBROKER_SSL_CERTFILE'):
     X2GOBROKER_SSL_CERTFILE = os.environ['X2GOBROKER_SSL_CERTFILE']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_SSL_CERTFILE'):
+    X2GOBROKER_SSL_CERTFILE=iniconfig.get(iniconfig_section, 'X2GOBROKER_SSL_CERTFILE')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_SSL_CERTFILE'):
+    X2GOBROKER_SSL_CERTFILE=iniconfig.get('common', 'X2GOBROKER_SSL_CERTFILE')
 else:
     X2GOBROKER_SSL_CERTFILE = ""
 
 if os.environ.has_key('X2GOBROKER_SSL_KEYFILE'):
     X2GOBROKER_SSL_KEYFILE = os.environ['X2GOBROKER_SSL_KEYFILE']
+elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_SSL_KEYFILE'):
+    X2GOBROKER_SSL_KEYFILE=iniconfig.get(iniconfig_section, 'X2GOBROKER_SSL_KEYFILE')
+elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_SSL_KEYFILE'):
+    X2GOBROKER_SSL_KEYFILE=iniconfig.get('common', 'X2GOBROKER_SSL_KEYFILE')
 else:
     X2GOBROKER_SSL_KEYFILE = ""
 

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git



More information about the x2go-commits mailing list