-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
65 lines (44 loc) · 1.99 KB
/
setup.py
File metadata and controls
65 lines (44 loc) · 1.99 KB
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
import argparse
import os
from shutil import copyfile
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Setup script for the phpdev Docker environment.')
parser.add_argument('-s', '--htdocs-source', type=str, required=False, help='The htdocs symlink source')
args = parser.parse_args()
# Get path to current directory
current_directory = os.path.dirname(os.path.realpath(__file__))
# Create php.env if it doesn't already exist
if not os.path.isfile(current_directory + '/env/php.env'):
copyfile(current_directory + '/env/php.env.dist', current_directory + '/env/php.env')
# Create .env if it doesn't already exist
if not os.path.isfile('.env'):
copyfile('.env.dist', '.env')
# Create htdocs if it doesn't already exist
htdocs = '%s/htdocs' % (os.path.dirname(os.path.realpath(__file__)))
if not os.path.exists(htdocs):
if args.htdocs_source is not None:
htdocs_source = os.path.realpath(args.htdocs_source)
if not os.path.isdir(htdocs_source):
print('The htdocs symlink source (%s) does not exist!' % (htdocs_source))
exit(1)
print('Symlinking htdocs to %s.' % (htdocs_source))
os.symlink(htdocs_source, htdocs)
else:
print('Creating %s directory.' % (htdocs))
os.mkdir(htdocs)
# Create the required storage directories
directories = [
current_directory + '/storage',
current_directory + '/storage/mariadb',
current_directory + '/storage/mysql',
current_directory + '/storage/mongodb',
current_directory + '/storage/postgres',
current_directory + '/storage/redis',
current_directory + '/storage/redis-insight',
]
for directory in directories:
if not os.path.exists(directory):
print('Creating %s directory.' % (directory))
os.mkdir(directory)
# Tell the user that we're done
print('All done!')