Skip to content

Commit 4e0b732

Browse files
committed
add the ability to specify a different config file
1 parent bc59091 commit 4e0b732

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

deploy_freenas.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
Source: https://github.com/danb35/deploy-freenas
1616
"""
1717

18+
import argparse
19+
import os
1820
import sys
1921
import json
2022
import requests
@@ -25,9 +27,17 @@
2527
from urllib3.exceptions import InsecureRequestWarning
2628
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
2729

28-
config = configparser.ConfigParser()
29-
config.read('deploy_config')
30-
deploy = config['deploy']
30+
parser = argparse.ArgumentParser(description='Import and activate a SSL/TLS certificate into FreeNAS.')
31+
parser.add_argument('-c', '--config', default='deploy_config', help='Path to config file, defaults to deploy_config.')
32+
args = parser.parse_args()
33+
34+
if os.path.isfile(args.config):
35+
config = configparser.ConfigParser()
36+
config.read(args.config)
37+
deploy = config['deploy']
38+
else:
39+
print("Config file", args.config, "does not exist!")
40+
exit(1)
3141

3242
USER = "root"
3343
PASSWORD = deploy.get('password')

0 commit comments

Comments
 (0)