summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKamil Kisiel <kamil@kamilkisiel.net>2011-09-17 15:37:42 -0700
committerKamil Kisiel <kamil@kamilkisiel.net>2011-09-17 15:37:42 -0700
commit4a284d9996c30ab28998a0d37c9eec052397db80 (patch)
treed3f194ad8f1b03756b897c5a0c7b791f4fbf917f /src
parent9ab937099c6a50830fc9146d68cf017084d3560d (diff)
downloadbcfg2-4a284d9996c30ab28998a0d37c9eec052397db80.tar.gz
bcfg2-4a284d9996c30ab28998a0d37c9eec052397db80.tar.bz2
bcfg2-4a284d9996c30ab28998a0d37c9eec052397db80.zip
Cleaned up path handling in bcfg2-admin init.
Now uses absolute paths so the config file works correctly if the user inputs relative paths. Also simplified the config file template a bit as a result.
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Admin/Init.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py
index f9b391ae2..aba6bbd32 100644
--- a/src/lib/Server/Admin/Init.py
+++ b/src/lib/Server/Admin/Init.py
@@ -36,9 +36,9 @@ web_debug = True
[communication]
protocol = %s
password = %s
-certificate = %s/%s
-key = %s/%s
-ca = %s/%s
+certificate = %s
+key = %s
+ca = %s
[components]
bcfg2 = %s
@@ -221,7 +221,7 @@ class Init(Bcfg2.Server.Admin.Mode):
newconfig = get_input("Store Bcfg2 configuration in [%s]: " %
self.configfile)
if newconfig != '':
- self.configfile = newconfig
+ self.configfile = os.path.abspath(newconfig)
def _prompt_repopath(self):
"""Ask for the repository path."""
@@ -229,7 +229,7 @@ class Init(Bcfg2.Server.Admin.Mode):
newrepo = get_input("Location of Bcfg2 repository [%s]: " %
self.repopath)
if newrepo != '':
- self.repopath = newrepo
+ self.repopath = os.path.abspath(newrepo)
if os.path.isdir(self.repopath):
response = get_input("Directory %s exists. Overwrite? [y/N]:" \
% self.repopath)
@@ -333,26 +333,27 @@ class Init(Bcfg2.Server.Admin.Mode):
def init_repo(self):
"""Setup a new repo and create the content of the configuration file."""
- keypath = os.path.dirname(os.path.abspath(self.configfile))
+ keypath = os.path.dirname(self.configfile)
+ kpath = os.path.join(keypath, 'bcfg2.key')
+ cpath = os.path.join(keypath, 'bcfg2.crt')
+
confdata = config % (self.repopath,
','.join(self.plugins),
self.opts['sendmail'],
self.opts['proto'],
self.password,
- keypath, 'bcfg2.crt',
- keypath, 'bcfg2.key',
- keypath, 'bcfg2.crt',
+ cpath,
+ kpath,
+ cpath,
self.server_uri)
# Create the configuration file and SSL key
create_conf(self.configfile, confdata, keypath)
- kpath = keypath + '/bcfg2.key'
- cpath = keypath + '/bcfg2.crt'
create_key(self.shostname, kpath, cpath, self.country,
self.state, self.location)
# Create the repository
- path = "%s/%s" % (self.repopath, 'etc')
+ path = os.path.join(self.repopath, 'etc')
try:
os.makedirs(path)
self._init_plugins()