[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Add a slightly friendlier search path for mixminiond.conf



Update of /home/minion/cvsroot/src/minion/lib/mixminion/server
In directory moria.mit.edu:/tmp/cvs-serv16861/lib/mixminion/server

Modified Files:
	ServerMain.py 
Log Message:
Add a slightly friendlier search path for mixminiond.conf

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/server/ServerMain.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ServerMain.py	6 Jan 2003 22:09:24 -0000	1.20
+++ ServerMain.py	7 Jan 2003 03:06:49 -0000	1.21
@@ -423,7 +423,6 @@
 """.strip()
 
 def usageAndExit(cmd):
-    executable = sys.argv[0]
     print >>sys.stderr, _SERVER_USAGE %cmd
     sys.exit(0)
 
@@ -431,7 +430,7 @@
     options, args = getopt.getopt(args, "hf:", ["help", "config="])
     if args:
         usageAndExit(cmd)
-    configFile = "/etc/mixminiond.conf"
+    configFile = None
     for o,v in options:
         if o in ('-h', '--help'):
             usageAndExit(cmd)
@@ -441,6 +440,17 @@
     return readConfigFile(configFile)
 
 def readConfigFile(configFile):
+    if configFile is None:
+        if os.path.exists(os.path.expanduser("~/.mixminiond.conf")):
+            configFile = os.path.expanduser("~/.mixminiond.conf")
+        elif os.path.exists(os.path.expanduser("~/etc/mixminiond.conf")):
+            configFile = os.path.expanduser("~/etc/mixminiond.conf")
+        elif os.path.exists("/etc/mixminiond.conf"):
+            configFile = "/etc/mixminiond.conf"
+        else:
+            print >>sys.stderr, "No config file found or specified."
+            sys.exit(1)
+
     try:
         return mixminion.server.ServerConfig.ServerConfig(fname=configFile)
     except (IOError, OSError), e:
@@ -512,7 +522,7 @@
     # FFFF Ability to generate keys with particular start/end intervals
     keys=1
     usage=0
-    configFile = '/etc/miniond.conf'
+    configFile = None
     for opt,val in options:
         if opt in ('-h', '--help'):
             usage=1
@@ -559,7 +569,7 @@
         args = options = ()
     usage = 0
     removeIdentity = 0
-    configFile = '/etc/miniond.conf'
+    configFile = None
     for opt,val in options:
         if opt in ('-h', '--help'):
             usage=1