[Freeipa-devel] [PATCH] fix small bugs and add ds_newinst.pl fallback
Karl MacMillan
kmacmill at redhat.com
Wed Aug 1 15:12:53 UTC 2007
Just committed a patch (below) for a few small bugs that evaded my
testing yesterday (thanks Rob) and made dsinstance.py fallback to
ds_newinst.pl if the newer setup-ds.pl is not present. And for anyone
that missed it yesterday, there was what I hope is the last of the tree
reorg.
Karl
[?1034hdiff -r 5f83fa3c16c2 ipa-server/ipa-install/ipa-server-install
--- a/ipa-server/ipa-install/ipa-server-install Tue Jul 31 17:12:26 2007 -0400
+++ b/ipa-server/ipa-install/ipa-server-install Wed Aug 01 11:06:05 2007 -0400
@@ -34,7 +34,7 @@ from optparse import OptionParser
from optparse import OptionParser
import ipaserver.dsinstance
import ipaserver.krbinstance
-import ipaserver.util.run as run
+from ipaserver.util import run
def parse_options():
parser = OptionParser(version=VERSION)
@@ -117,7 +117,7 @@ def main():
ds.restart()
# Restart apache
- run(["/sbin/server", "httpd", "restart"])
+ run(["/sbin/service", "httpd", "restart"])
return 0
diff -r 5f83fa3c16c2 ipa-server/ipaserver/dsinstance.py
--- a/ipa-server/ipaserver/dsinstance.py Tue Jul 31 17:12:26 2007 -0400
+++ b/ipa-server/ipaserver/dsinstance.py Wed Aug 01 10:46:45 2007 -0400
@@ -24,8 +24,6 @@ import shutil
import shutil
import logging
import pwd
-import os
-import stat
from util import *
@@ -52,13 +50,10 @@ def realm_to_suffix(realm_name):
return ",".join(terms)
def find_server_root():
- try:
- mode = os.stat(SERVER_ROOT_64)[ST_MODE]
- if stat.IS_DIR(mode):
- return SERVER_ROOT_64
- except:
+ if dir_exists(SERVER_ROOT_64):
+ return SERVER_ROOT_64
+ else:
return SERVER_ROOT_32
-
INF_TEMPLATE = """
[General]
@@ -137,8 +132,12 @@ class DsInstance:
logging.debug(inf_txt)
inf_fd = write_tmp_file(inf_txt)
logging.debug("writing inf template")
- args = ["/usr/sbin/setup-ds.pl", "--silent", "--logfile", "-", "-f", inf_fd.name, ]
- logging.debug("calling ds_newinst.pl")
+ if file_exists("/usr/sbin/setup-ds.pl"):
+ args = ["/usr/sbin/setup-ds.pl", "--silent", "--logfile", "-", "-f", inf_fd.name]
+ logging.debug("calling setup-ds.pl")
+ else:
+ args = ["/usr/sbin/ds_newinst.pl", inf_fd.name]
+ logging.debug("calling ds_newinst.pl")
run(args)
logging.debug("completed creating ds instance")
logging.debug("restarting ds instance")
diff -r 5f83fa3c16c2 ipa-server/ipaserver/util.py
--- a/ipa-server/ipaserver/util.py Tue Jul 31 17:12:26 2007 -0400
+++ b/ipa-server/ipaserver/util.py Wed Aug 01 10:59:50 2007 -0400
@@ -24,6 +24,8 @@ import tempfile
import tempfile
import logging
import subprocess
+import os
+import stat
def realm_to_suffix(realm_name):
s = realm_name.split(".")
@@ -56,3 +58,23 @@ def run(args, stdin=None):
if p.returncode != 0:
raise subprocess.CalledProcessError(p.returncode, args[0])
+
+def file_exists(filename):
+ try:
+ mode = os.stat(filename)[stat.ST_MODE]
+ if stat.S_ISREG(mode):
+ return True
+ else:
+ return False
+ except:
+ return False
+
+def dir_exists(filename):
+ try:
+ mode = os.stat(filename)[stat.ST_MODE]
+ if stat.S_ISDIR(mode):
+ return True
+ else:
+ return False
+ except:
+ return False
More information about the Freeipa-devel
mailing list