Skip to content

Commit 6e4ff4b

Browse files
committed
Make installation of FTP certificate optional
1 parent 9da85b2 commit 6e4ff4b

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

deploy_config.example

+3
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ password = YourSuperSecurePassword#@#$*
3636
# port sets the port to use to connect. Default is 80. If protocol is https,
3737
# this MUST be set to your https port.
3838
# port = 443
39+
40+
# set ftp_enabled to true if you have the FTP service enabled on your FreeNAS. Default is false.
41+
# ftp_enabled = true

deploy_freenas.py

+18-16
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
FULLCHAIN_PATH = deploy.get('fullchain_path',"/root/.acme.sh/" + DOMAIN_NAME + "/fullchain.cer")
5151
PROTOCOL = deploy.get('protocol','http://')
5252
PORT = deploy.get('port','80')
53+
FTP_ENABLED = deploy.getboolean('ftp_enabled',fallback=False)
5354
now = datetime.now()
5455
cert = "letsencrypt-%s-%s-%s-%s" %(now.year, now.strftime('%m'), now.strftime('%d'), ''.join(c for c in now.strftime('%X') if
5556
c.isdigit()))
@@ -122,23 +123,24 @@
122123
print (r)
123124
sys.exit(1)
124125

125-
# Set our cert as active for FTP plugin
126-
r = requests.put(
127-
PROTOCOL + FREENAS_ADDRESS + ':' + PORT + '/api/v1.0/services/ftp/',
128-
verify=VERIFY,
129-
auth=(USER, PASSWORD),
130-
headers={'Content-Type': 'application/json'},
131-
data=json.dumps({
132-
"ftp_ssltls_certfile": cert,
133-
}),
134-
)
126+
if FTP_ENABLED:
127+
# Set our cert as active for FTP plugin
128+
r = requests.put(
129+
PROTOCOL + FREENAS_ADDRESS + ':' + PORT + '/api/v1.0/services/ftp/',
130+
verify=VERIFY,
131+
auth=(USER, PASSWORD),
132+
headers={'Content-Type': 'application/json'},
133+
data=json.dumps({
134+
"ftp_ssltls_certfile": cert,
135+
}),
136+
)
135137

136-
if r.status_code == 200:
137-
print ("Setting active certificate successful")
138-
else:
139-
print ("Error setting active certificate!")
140-
print (r)
141-
sys.exit(1)
138+
if r.status_code == 200:
139+
print ("Setting active FTP certificate successful")
140+
else:
141+
print ("Error setting active FTP certificate!")
142+
print (r)
143+
sys.exit(1)
142144

143145
# Reload nginx with new cert
144146
try:

0 commit comments

Comments
 (0)