-
Notifications
You must be signed in to change notification settings - Fork 4
/
command.sh
70 lines (64 loc) · 1.39 KB
/
command.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
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
#!/bin/bash
help () {
echo "It receive only below argument." 1>&2
echo "----" 1>&2
echo "init {YOUR_DOMAIN}" 1>&2
echo "build" 1>&2
echo "log parent|child|bridge" 1>&2
echo "run" 1>&2
echo "stop" 1>&2
exit 1
}
container_name_error () {
echo "Container name only receive below name." 1>&2
echo "----" 1>&2
echo "parent" 1>&2
echo "child" 1>&2
echo "bridge" 1>&2
exit 1
}
domain_name_error () {
echo "init command must be use domain name." 1>&2
echo "----" 1>&2
echo "e.g." 1>&2
echo "init dev.wshino.com" 1>&2
exit 1
}
if [ $# -gt 2 ]
then
help
fi
if [ $1 = "init" ]
then
if [ $# -ne 2 ]
then
domain_name_error
else
cp ./substrate-overlay-token/docker/default.conf .
sed -ien "s/{YOUR_DOMAIN}/$2/g" default.conf
cp ./substrate-overlay-token/docker-compose.yaml .
sed -ien "s/{YOUR_DOMAIN}/$2/g" docker-compose.yaml
fi
elif [ $1 = "build" ]
then
cd substrate-overlay-token && \
sudo docker build -t overlaytoken:0.1 . && \
./scripts/build.sh && \
cargo build --release
elif [ $1 = "run" ]
then
sudo docker-compose up -d
elif [ $1 = "log" ]
then
if [ $2 = "parent" ] || [ $2 = "child" ] || [ $2 = "bridge" ]
then
sudo docker-compose logs -f --tail=10 $2
else
container_name_error
fi
elif [ $1 = "stop" ]
then
sudo docker-compose stop
else
help
fi