summaryrefslogtreecommitdiff
path: root/plinth.py
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-07-12 17:21:54 -0400
committerbnewbold <bnewbold@robocracy.org>2012-07-12 22:25:50 -0400
commitf1e764f2e5728113f191456236d02fdae6e7680a (patch)
tree46484b2871311fd213c1df2e2b228a0db8635903 /plinth.py
parent337560b0d197fb3d1b4fd7cb1fdecc687c9f9758 (diff)
integrate exmachina configuration management layer
- add exmachina code and test code - modify plinth.py to listen for shared secret on stdin at start (if appropriate flag is set) and try to connect to exmachina daemon - use exmachina to read and set /etc/hostname as a demo - update plinth init.d script to start exmachina and share keys - update docs with new deps and run instructions
Diffstat (limited to 'plinth.py')
-rwxr-xr-xplinth.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/plinth.py b/plinth.py
index 2eff29f..adab110 100755
--- a/plinth.py
+++ b/plinth.py
@@ -17,6 +17,9 @@ from util import *
from logger import Logger
#from modules.auth import AuthController, require, member_of, name_is
+from exmachina.exmachina import ExMachinaClient
+import socket
+
__version__ = "0.2.14"
__author__ = "James Vasile"
__copyright__ = "Copyright 2011, James Vasile"
@@ -71,9 +74,17 @@ def parse_arguments():
parser = argparse.ArgumentParser(description='Plinth web interface for the FreedomBox.')
parser.add_argument('--pidfile', default="",
help='specify a file in which the server may write its pid')
+ parser.add_argument('--listen-exmachina-key', default=False, action='store_true',
+ help='listen for JSON-RPC shared secret key on stdin at startup')
args=parser.parse_args()
if args.pidfile:
cfg.pidfile = args.pidfile
+ if args.listen_exmachina_key:
+ # this is where we optionally try to read in a shared secret key to
+ # authenticate connections to exmachina
+ cfg.exmachina_secret_key = sys.stdin.readline().strip()
+ else:
+ cfg.exmachina_secret_key = None
def setup():
parse_arguments()
@@ -85,6 +96,13 @@ def setup():
except AttributeError:
pass
+ try:
+ cfg.exmachina = ExMachinaClient(
+ secret_key=cfg.exmachina_secret_key or None)
+ except socket.error:
+ cfg.exmachina = None
+ print "couldn't connect to exmachina daemon, but continuing anyways..."
+
os.chdir(cfg.file_root)
cherrypy.config.update({'error_page.404': error_page_404})
cherrypy.config.update({'error_page.500': error_page_500})