forked from makerspace/makeradmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_env.py
executable file
·48 lines (45 loc) · 1.78 KB
/
create_env.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
48
import argparse
import os
import secrets
parser = argparse.ArgumentParser(description="Create a default '.env' file with secrets if it doesn't exist")
parser.add_argument("--force", "-f", dest="force", action="store_true", help="overwrite existing '.env' file")
args = parser.parse_args()
config = {
"MYSQL_DB": "makeradmin",
"MYSQL_PORT": "3306",
"MYSQL_USER": "makeradmin",
"MYSQL_PASS": secrets.token_hex(16),
"MYSQL_ROOT_PASSWORD": secrets.token_hex(16),
# Note: This must fit into the access_tokens table in the database
"TEST_SERVICE_TOKEN": secrets.token_hex(16),
"MAILGUN_DOMAIN": "",
"MAILGUN_KEY": "",
"MAILGUN_FROM": "MakerAdmin <[email protected]>",
"MAILGUN_TO_OVERRIDE": "",
"HOST_BACKEND": "http://localhost:8010",
"HOST_FRONTEND": "http://localhost:8009",
"HOST_PUBLIC": "http://localhost:8011",
"ADMIN_EMAIL": "",
"STRIPE_PRIVATE_KEY": os.environ.get("STRIPE_PRIVATE_KEY", ""),
"STRIPE_PUBLIC_KEY": os.environ.get("STRIPE_PUBLIC_KEY", ""),
"STRIPE_SIGNING_SECRET": "",
"STRIPE_CURRENCY": "sek",
"ACCESSY_CLIENT_ID": "",
"ACCESSY_CLIENT_SECRET": "",
"ACCESSY_LABACCESS_GROUP": "",
"ACCESSY_SPECIAL_LABACCESS_GROUP": "",
"ACCESSY_DO_MODIFY": "false",
"CORS_ALLOWED_ORIGINS": "http://localhost:8009,http://localhost:8011,http://localhost:8080",
"FIRSTRUN_AUTO_ADMIN_FIRSTNAME": "",
"FIRSTRUN_AUTO_ADMIN_LASTNAME": "",
"FIRSTRUN_AUTO_ADMIN_EMAIL": "",
"FIRSTRUN_AUTO_ADMIN_PASSWORD": "",
"ELKS46_API_USER": "",
"ELKS46_API_KEY": "",
}
if not args.force and os.path.isfile(".env"):
print(".env file already exists, touching")
os.utime(".env", None)
else:
with open(".env", "w") as f:
f.write("\n".join(key + "=" + value for (key, value) in config.items()))