Skip to content

Commit 26d6c3f

Browse files
authored
Merge pull request #10 from fritz-fritz/fritz-fritz-patch-1
Implement Remote Deploy Variables
2 parents 21e3ae6 + 0d1233a commit 26d6c3f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

deploy_freenas.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
PASSWORD = "ReallySecurePassword"
2828

2929
USER = "root"
30+
FREENAS_ADDRESS = "localhost"
31+
VERIFY = False # Or True (Caution! False disables certificate checking)
3032
PRIVATEKEY_PATH = "/root/.acme.sh/" + DOMAIN_NAME + "/" + DOMAIN_NAME + ".key"
3133
FULLCHAIN_PATH = "/root/.acme.sh/" + DOMAIN_NAME + "/fullchain.cer"
3234
PROTOCOL = 'http://'
@@ -43,8 +45,8 @@
4345

4446
# Update or create certificate
4547
r = requests.post(
46-
PROTOCOL + 'localhost:' + PORT + '/api/v1.0/system/certificate/import/',
47-
verify=False,
48+
PROTOCOL + FREENAS_ADDRESS + ':' + PORT + '/api/v1.0/system/certificate/import/',
49+
verify=VERIFY,
4850
auth=(USER, PASSWORD),
4951
headers={'Content-Type': 'application/json'},
5052
data=json.dumps({
@@ -64,8 +66,8 @@
6466
# Download certificate list
6567
limit = {'limit': 0} # set limit to 0 to disable paging in the event of many certificates
6668
r = requests.get(
67-
PROTOCOL + 'localhost:' + PORT + '/api/v1.0/system/certificate/',
68-
verify=False,
69+
PROTOCOL + FREENAS_ADDRESS + ':' + PORT + '/api/v1.0/system/certificate/',
70+
verify=VERIFY,
6971
params=limit,
7072
auth=(USER, PASSWORD))
7173

@@ -87,8 +89,8 @@
8789

8890
# Set our cert as active
8991
r = requests.put(
90-
PROTOCOL + 'localhost:' + PORT + '/api/v1.0/system/settings/',
91-
verify=False,
92+
PROTOCOL + FREENAS_ADDRESS + ':' + PORT + '/api/v1.0/system/settings/',
93+
verify=VERIFY,
9294
auth=(USER, PASSWORD),
9395
headers={'Content-Type': 'application/json'},
9496
data=json.dumps({
@@ -106,8 +108,8 @@
106108
# Reload nginx with new cert
107109
try:
108110
r = requests.post(
109-
PROTOCOL + 'localhost:' + PORT + '/api/v1.0/system/settings/restart-httpd-all/',
110-
verify=False,
111+
PROTOCOL + FREENAS_ADDRESS + ':' + PORT + '/api/v1.0/system/settings/restart-httpd-all/',
112+
verify=VERIFY,
111113
auth=(USER, PASSWORD),
112114
)
113115
except requests.exceptions.ConnectionError:

0 commit comments

Comments
 (0)