update setup script
This commit is contained in:
parent
beb9c2472d
commit
64a28233df
|
@ -69,7 +69,8 @@
|
||||||
"users": [
|
"users": [
|
||||||
{
|
{
|
||||||
"id": "{{ uuid }}",
|
"id": "{{ uuid }}",
|
||||||
"alterId": 64
|
"alterId": 64,
|
||||||
|
"security": "none"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
49
setup.py
49
setup.py
|
@ -11,25 +11,39 @@ def randomString(stringLength=16):
|
||||||
letters = string.ascii_lowercase
|
letters = string.ascii_lowercase
|
||||||
return ''.join(random.choice(letters) for i in range(stringLength))
|
return ''.join(random.choice(letters) for i in range(stringLength))
|
||||||
|
|
||||||
|
def read_conf(f):
|
||||||
|
ret = {}
|
||||||
|
f = open(f, "r")
|
||||||
|
lines = f.readlines()
|
||||||
|
for line in lines:
|
||||||
|
eline = line.split(' ')
|
||||||
|
if len(eline) >= 2:
|
||||||
|
ret[eline[0]] = eline[1]
|
||||||
|
return ret
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print("Usage: python setup.py [options]\n\n\
|
print("Usage: python setup.py [options]\n\n\
|
||||||
options:\n\
|
options:\n\
|
||||||
-h : show usage.\n\
|
-h : show usage.\n\
|
||||||
-d domain : your domain - mydomain.tld.\n\
|
-d domain : your domain - mydomain.tld.\n\
|
||||||
|
[-u uuid] : the uuid of the user. Optional.\n\
|
||||||
|
[-p path] : the path of the websocket. Optional.\n\
|
||||||
[-s subdomain] : your subdomain. Optional.\n\
|
[-s subdomain] : your subdomain. Optional.\n\
|
||||||
[-e email] : your email. Optional.\n")
|
[-e email] : your email. Optional.\n\
|
||||||
|
[-c conf] : load config from file. Optional.\n\n")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
email = None
|
email = None
|
||||||
subdomain = None
|
subdomain = None
|
||||||
domain = None
|
domain = None
|
||||||
|
conf_file = None
|
||||||
uid = os.getuid()
|
uid = os.getuid()
|
||||||
gid = os.getgid()
|
gid = os.getgid()
|
||||||
v_uuid = uuid.uuid4()
|
v_uuid = None
|
||||||
v_path = randomString()
|
v_path = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts , args = getopt.getopt(sys.argv[1:], "hd:s:e:")
|
opts , args = getopt.getopt(sys.argv[1:], "hd:s:e:c:u:p:")
|
||||||
except getopt.GetoptError as err:
|
except getopt.GetoptError as err:
|
||||||
print(str(err))
|
print(str(err))
|
||||||
usage()
|
usage()
|
||||||
|
@ -56,6 +70,33 @@ def main():
|
||||||
print("Can specify maximum ONE email.")
|
print("Can specify maximum ONE email.")
|
||||||
else:
|
else:
|
||||||
email = a
|
email = a
|
||||||
|
elif o == "-c":
|
||||||
|
conf_file = a
|
||||||
|
elif o == "-u":
|
||||||
|
v_uuid = a
|
||||||
|
elif o == "-s":
|
||||||
|
v_path = a
|
||||||
|
|
||||||
|
# overwrite stuff with conf file
|
||||||
|
conf = read_conf(conf_file)
|
||||||
|
|
||||||
|
if "d" in conf:
|
||||||
|
domain = conf["d"]
|
||||||
|
if "s" in conf:
|
||||||
|
subdomain = conf["s"]
|
||||||
|
if "e" in conf:
|
||||||
|
email = conf["e"]
|
||||||
|
if "u" in conf:
|
||||||
|
v_uuid = conf["u"]
|
||||||
|
if "p" in conf:
|
||||||
|
v_path = conf["p"]
|
||||||
|
|
||||||
|
# generate settings if not specified
|
||||||
|
if v_uuid == None:
|
||||||
|
v_uuid = uuid.uuid4()
|
||||||
|
|
||||||
|
if v_path == None:
|
||||||
|
v_path = randomString()
|
||||||
|
|
||||||
if domain == None:
|
if domain == None:
|
||||||
print("Must specify a domain.")
|
print("Must specify a domain.")
|
||||||
|
|
Loading…
Reference in New Issue