-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicebt
executable file
·144 lines (126 loc) · 4.54 KB
/
icebt
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env bash
# If no commands, show credits
if [ $# == 0 ]; then
cat ./.cli/credits
exit 0
else
# If a start command, run the docker-compose up command
# $? == the status code return by ./cli/configInit.sh
# $? = 0 indicates success
if [ $1 == 'start' ]; then
shift 1
.cli/configure.sh
if [ $? -eq "0" ]; then
docker-compose up $@
fi
exit 0
fi
# If a stop command, run the docker-compose up command
if [ $1 == 'stop' ]; then
shift 1
docker-compose down $@
exit 0
fi
# If a build command, run the standard docker-compose build command
# $? == the status code return by ./cli/configInit.sh
# $? = 0 indicates success
if [ $1 == 'build' ]; then
shift 1
.cli/configure.sh
if [ $? -eq "0" ]; then
docker-compose build $@
fi
exit 0
fi
# If a rebuild command, run the docker-compose build command with no cache
# option set against it.
# $? == the status code return by ./cli/configInit.sh
# $? = 0 indicates success
if [ $1 == 'rebuild' ]; then
shift 1
.cli/configure.sh
if [ $? -eq "0" ]; then
docker-compose build --no-cache $@
fi
exit 0
fi
# If a composer command is ran route it to the composer container and run it
if [ $1 == 'composer' ]; then
shift 1
docker-compose run composer $@
exit 0
fi
# If a config init command is ran, copy config.yml.dist to config.yml
if [ $1 == 'config-init' ]; then
if [ ! -f config.yml ]; then
cp dist.config.yml config.yml
echo "config.yml created."
echo "Patching in Sentry Secret Key"
./icebt sentry create-secret
echo "Success! Go configure!"
else
echo "config.yml already exists!"
fi
exit 0
fi
# If a sentry command is ran
if [ $1 == 'sentry' ]; then
if [ $2 == 'create-secret' ]; then
if [ ! -f config.yml ]; then
echo "Error: No config.yml file found."
echo "To create one run: ./icebt config-init"
exit 1
fi
echo "Generating Sentry secret key...";
docker pull sentry &> /dev/null
secretKeyRaw=$(docker run --rm sentry config generate-secret-key)
secretKey=${secretKeyRaw/|/}
echo "Finalising..."
docker rmi sentry &> /dev/null
sed -i '' -e "s|@sentry\.secret|$secretKey|g" ./config.yml
echo "Secret key generated."
echo "> Key: $secretKey"
echo "Attempted to patch key into config.yml at @sentry.secret."
echo "Please check config.yml's sentry settings to ensure this has completed correctly."
echo "If key hasn't patched please enter it in at sentry:secret before continuing."
while true; do
read -p "Do you need to initialise Sentry? [y|N] " yn
yn=${yn:-n}
case $yn in
[Yy"yes"]* ) ./icebt sentry init; break;;
[Nn"no"]* ) exit;;
* ) exit;;
esac
done
exit 0;
fi
if [ $2 == 'init' ]; then
echo "Initialising Sentry."
. ./.cli/yamlParse.sh
eval $(yamlParse ./config.yml)
if [ -z $sentry_secret ] || [ $sentry_secret == "@sentry.secret" ]; then
echo "Coult not initialise Sentry, no secret set under sentry:secret in ./config.yml;"
echo "To create a secret run: ./icebt sentry create-secret"
exit 1
fi
.cli/configure.sh
if [ $? -eq "0" ]; then
echo "Creating required services (this could take a while, please be patient)..."
docker-compose up &> /dev/null
echo "Starting required services..."
docker-compose exec sentry sentry upgrade
echo "Cleaning up... (this could take a while, please be patient)..."
docker-compose stop sentry &> /dev/null
docker-compose rm -v -y sentry &> /dev/null
docker-compose down &> /dev/null
echo "Success: Sentry initialisation completed."
fi
exit 0
fi
echo "No sentry option recieved, closing."
exit 0
fi
# Pass any unhandled commands direct to docker-compose
docker-compose $@
exit 0
fi