-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·73 lines (59 loc) · 1.62 KB
/
main.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
70
71
72
73
#! /bin/bash
dir="$(pwd)"
date="[$(date)]"
find_running_instance()
{
docker ps | grep nodebb-alpine
return $?
}
nodebb_stop()
{
docker stop nodebb-alpine
docker rm nodebb-alpine
}
show_usage()
{
echo "This is a bash script for manage NodeBB-alpine"
echo "./main [ACTION]"
echo
echo "ACTION:"
echo "network <network_name> Connect to a network"
echo "stop Stop NodeBB-alpine"
echo "build Build NodeBB-alpine"
echo "debug Start in to bash"
echo "--help, -h ,help Show this message"
echo
echo "If no [ACTION], start normally"
}
if [[ "$1" == debug ]]; then
flag='--entrypoint /bin/sh'
echo "$date" 'Debug Mode'
elif [[ "$1" == network ]]; then
if [[ "$2" != "" ]]; then
flag="--network $2"
echo Connect to "$2"
fi
elif [[ "$1" == stop ]]; then
echo "$date" 'Stoping NodeBB-alpine......'
nodebb_stop
exit
elif [[ "$1" == build ]]; then
echo "$date" 'Build NodeBB-alpine:testing ......'
docker build . --tag nodebb-alpine:testing
exit
elif [[ "$1" == --help ]] || [[ "$1" == -h ]] || [[ "$1" == help ]]; then
show_usage
exit
else
echo "$date" 'Normal Mode'
fi
if [ ! -d "$dir"/node ]; then
mkdir "$dir"/node
fi
# shellcheck disable=SC2086
docker run -it \
-p 4567:4567 \
--mount type=bind,source="$dir"/node,target=/home/node/ \
--name nodebb-alpine \
$flag \
nodebb-alpine:testing