Skip to content

Commit 685197e

Browse files
authored
Merge pull request #85 from NethServer/fixWebserver
Fix the overwrite of database during upgrade NethServer/dev#7194
2 parents b5ad7d0 + 4192cc8 commit 685197e

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

imageroot/actions/create-vhost/10base

+10-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,16 @@ MaxFileUploads = data.get("MaxFileUploads",'20')
4848
h2hs = data.get("http2https", True)
4949
le = data.get("lets_encrypt", False)
5050

51-
with open("databases/NextFpmPort", "r+") as fp:
52-
NextFpmPort = int(fp.read() or "9000") + 1
53-
fp.seek(0)
54-
fp.write(str(NextFpmPort))
51+
# read Netxfpmport, the file could be missing so we need to handle the exception
52+
try:
53+
with open("databases/NextFpmPort", "r+") as fp:
54+
NextFpmPort = int(fp.read() or "9000") + 1
55+
fp.seek(0)
56+
fp.write(str(NextFpmPort))
57+
except FileNotFoundError:
58+
NextFpmPort = 9001
59+
with open("databases/NextFpmPort", "w") as fp:
60+
fp.write(str(NextFpmPort))
5561

5662
config['vhost'] = {}
5763
config['vhost']['ServerNames'] = ','.join(ServerNames)

imageroot/actions/get-configuration/20read

+6-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ for file in glob.iglob("databases/vhosts/*.ini"):
5353
vhosts.append(vhost)
5454

5555
configuration['virtualhost'] = vhosts
56-
# read Netxfpmport
57-
with open("databases/NextFpmPort", "r") as fp:
58-
NextFpmPort = int(fp.read() or "9000") + 1
59-
fp.close()
56+
# read Netxfpmport, the file could be missing so we need to handle the exception
57+
try:
58+
with open("databases/NextFpmPort", "r") as fp:
59+
NextFpmPort = int(fp.read() or "9000") + 1
60+
except FileNotFoundError:
61+
NextFpmPort = 9001
6062

6163
configuration['NextFpmPort'] = NextFpmPort
6264

imageroot/state/databases/NextFpmPort

-1
This file was deleted.

0 commit comments

Comments
 (0)