add a function to check for various configuration locations
This commit is contained in:
parent
0b31b6f4b1
commit
d61a78c5f1
|
@ -1,5 +1,5 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
#server: fileserver.2li.local
|
# server: fileserver.2li.local
|
||||||
#user: borg
|
# user: borg
|
||||||
repository_path: /home/andreas/test
|
repository_path: /home/andreas/test
|
||||||
password: foo
|
password: foo
|
||||||
|
|
|
@ -44,9 +44,20 @@ def restore_archive():
|
||||||
def configuration():
|
def configuration():
|
||||||
# setup the config parser
|
# setup the config parser
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
# read config file
|
# check whether the config file exists either in the home folder or next to
|
||||||
|
# the binary
|
||||||
|
home = os.getenv('HOME')
|
||||||
|
if os.path.isfile(home + '/.config/borg_interface/borg_interface.cfg'):
|
||||||
|
config.read(home + '/.config/borg_interface/borg_interface.cfg')
|
||||||
|
elif os.path.isfile(home + '/.borg_interface.cfg'):
|
||||||
|
config.read(home + '/.borg_interface.cfg')
|
||||||
|
elif os.path.isfile('borg_interface.cfg'):
|
||||||
config.read('borg_interface.cfg')
|
config.read('borg_interface.cfg')
|
||||||
# assign the repository variable
|
else:
|
||||||
|
print("Configuration file not found.")
|
||||||
|
quit()
|
||||||
|
# assign the repository variable depending wheter it's a remote or a local
|
||||||
|
# repository
|
||||||
if 'server' in config['DEFAULT']:
|
if 'server' in config['DEFAULT']:
|
||||||
repository = (config['DEFAULT']['user']
|
repository = (config['DEFAULT']['user']
|
||||||
+ "@"
|
+ "@"
|
||||||
|
|
Reference in New Issue