-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sh
executable file
·41 lines (34 loc) · 895 Bytes
/
init.sh
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
#!/bin/bash
#title : init.sh
#description : Initializes by creating `.env` and external NETWORK defined in `.env`
#author : abmruman
#usage : `./scripts/init.sh` OR `make init`
set -e
echo
# Create env from env.example if it doesn't exist
if [ -f ".env" ]
then
echo -e "env file exists"
else
echo -e "Copying env file"
cp env.example .env
fi
echo
# Create network if necessary
eval $(egrep '^NETWORK' .env | xargs)
eval $(egrep '^NETWORK_EXTERNAL' .env | xargs)
echo -e "NETWORK: $NETWORK"
echo -e "NETWORK_EXTERNAL: $NETWORK_EXTERNAL"
echo
if [ ! -z "$NETWORK" ] && [ ! -z "$NETWORK_EXTERNAL" ]
then
if [ "$NETWORK_EXTERNAL" = "true" ]
then
docker network ls | grep "$NETWORK" || docker network create "$NETWORK"
else
echo -e "Skipping network creation, not external"
fi
else
echo -e "\nNETWORK not defined, creation not necessary\n"
fi
echo