-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleanconfig.py
47 lines (34 loc) · 1 KB
/
cleanconfig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Reads the config file and removes key, tokens, URLs, etc.
# Use: python cleanconfig.py /home/user/minetest.conf /home/user/cleanconfig.conf
# (C) 2023 Niklp, MIT License
import sys
inpath = sys.argv[1]
outpath = sys.argv[2]
print("Inputpath: " + inpath)
print("Outputpath: " + outpath)
infile = open(inpath, "r")
inlines = infile.readlines()
outfile = open(outpath, "w")
outtext = ""
for line in inlines:
split = line.split("=", 1)
outtext += split[0]
if len(split) > 1:
idx_1 = line.find("token")
idx_2 = line.find("key")
idx_3 = line.find("url")
idx_4 = line.find("seed")
if idx_1 > 0 or idx_2 > 0 or idx_3 > 0 or idx_4 > 0:
outtext += "=" + "" + "\n"
else:
outtext += "=" + split[1]
# change some values by hand
outtext += "\n" + "# CHANGED FOR GITHUB ACTIONS!" + "\n"
outtext += "port =" + "\n"
outtext += "secure.http_mods =" + "\n"
outtext += "server_announce = false" + "\n"
outtext += "archtec.ci = true" + "\n"
outfile.write(outtext)
infile.close()
outfile.close()
print("DONE")