forked from platformsh-templates/magento2ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·86 lines (75 loc) · 2.23 KB
/
deploy
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python
import base64
import errno
import json
import os
import subprocess
relationships = json.loads(base64.b64decode(os.environ["PLATFORM_RELATIONSHIPS"]))
routes = json.loads(base64.b64decode(os.environ["PLATFORM_ROUTES"]))
for url, route in routes.iteritems():
if route["original_url"] == "https://{default}/":
break
db = relationships["database"][0]
redis = relationships["redis"][0]
installed = os.path.exists(".config/installed")
try:
os.unlink(".config/env.php")
except OSError as exc:
if exc.errno != errno.ENOENT:
raise
args = [
"php",
"bin/magento",
"setup:install",
"--ansi",
"--no-interaction",
"--base-url=%s" % url,
"--db-host=%s" % db["host"],
"--db-name=%s" % db["path"],
"--db-user=%s" % db["username"],
"--backend-frontname=admin",
"--language=en_US",
"--currency=USD",
"--timezone=Europe/Paris",
"--use-rewrites=1",
"--session-save=redis",
"--session-save-redis-host=%s" % redis["host"],
"--session-save-redis-port=%s" % redis["port"],
"--session-save-redis-db=0",
"--cache-backend=redis",
"--cache-backend-redis-server=%s" % redis["host"],
"--cache-backend-redis-port=%s" % redis["port"],
"--cache-backend-redis-db=1",
"--page-cache=redis",
"--page-cache-redis-server=%s" % redis["host"],
"--page-cache-redis-port=%s" % redis["port"],
"--page-cache-redis-db=2",
]
if not installed:
args += [
"--admin-firstname=admin",
"--admin-lastname=admin",
"--admin-user=admin",
"--admin-password=admin123",
]
subprocess.check_call(args)
if not installed:
# Make sure that the admin will change their password on first login.
args = [
"mysql",
"-h%s" % db["host"],
"-u%s" % db["username"],
]
if db["password"] != "":
args += [
"-p%s" % db["password"],
]
args += [
db["path"],
"-e",
"insert into admin_passwords (user_id, password_hash, expires, last_updated) values (1, '123456789:2', 1, 1435156243);"
]
subprocess.check_call(args)
with open(".config/installed", "wb") as f:
f.write("Thank you for your time!\n")