summaryrefslogtreecommitdiffstats
path: root/install/tools/ipa-server-certinstall
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2012-05-31 14:34:09 +0200
committerMartin Kosek <mkosek@redhat.com>2012-05-31 14:37:27 +0200
commit0ca29fac9af4cd437a8536f28ffd25923ec3f8cd (patch)
tree6804ca5316f511d83ee6898f19eea8b9ef9092ea /install/tools/ipa-server-certinstall
parent9e877585e213a9fccec8ff9b3dcb876b2ec65696 (diff)
downloadfreeipa.git-0ca29fac9af4cd437a8536f28ffd25923ec3f8cd.tar.gz
freeipa.git-0ca29fac9af4cd437a8536f28ffd25923ec3f8cd.tar.xz
freeipa.git-0ca29fac9af4cd437a8536f28ffd25923ec3f8cd.zip
Move install script error handling to a common function
All of our install/admin scripts had a try/except block calling the main function and handling common exceptions. These were copy-pasted from each other and modified to various levels of sophistication. This refactors them out of installers to a single function, which includes a final pass/fail message for all of the scripts. Non-install scripts that set up the same log handler levels for stderr and log file are not changed, as it's not possible to log to only the logfile without changing the logger configuration. https://fedorahosted.org/freeipa/ticket/2071
Diffstat (limited to 'install/tools/ipa-server-certinstall')
-rwxr-xr-xinstall/tools/ipa-server-certinstall17
1 files changed, 8 insertions, 9 deletions
diff --git a/install/tools/ipa-server-certinstall b/install/tools/ipa-server-certinstall
index 901678b2..3b19f045 100755
--- a/install/tools/ipa-server-certinstall
+++ b/install/tools/ipa-server-certinstall
@@ -31,6 +31,7 @@ from ipapython.ipautil import user_input
from ipaserver.install import certs, dsinstance, httpinstance, installutils
from ipalib import api
+from ipapython.ipa_log_manager import *
from ipaserver.plugins.ldap2 import ldap2
def get_realm_name():
@@ -120,12 +121,17 @@ def import_cert(dirname, pkcs12_fname, pkcs12_passwd, db_password):
return server_cert
def main():
+ if os.geteuid() != 0:
+ sys.exit("\nYou must be root to run this script.\n")
+
installutils.check_server_configuration()
options, pkcs12_fname = parse_options()
cfg = dict(in_server=True,)
+ standard_logging_setup("/var/log/ipa/default.log")
+
api.bootstrap(**cfg)
api.finalize()
@@ -165,12 +171,5 @@ def main():
return 0
-try:
- if not os.geteuid()==0:
- sys.exit("\nYou must be root to run this script.\n")
-
- main()
-except SystemExit, e:
- sys.exit(e)
-except RuntimeError, e:
- sys.exit(e)
+if __name__ == '__main__':
+ installutils.run_script(main, operation_name='ipa-server-certinstall')