forked from EOSIO/eosio-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.sh
executable file
·77 lines (56 loc) · 1.71 KB
/
cli.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
74
75
76
77
#!/usr/bin/env bash
# cd into current working directory.
cd $( dirname "$0")
# Start getting symlinked file
SYMLINKEDFILE=$(readlink "$0")
# Break the while loop if the symlinked file is not a symlink
while [ -n "$SYMLINKEDFILE" ]
do
# Get the filename of the symlinked file
BASENAME=$( basename "$SYMLINKEDFILE" )
# cd into the directory which containing the symlinked file
cd $( pwd -P )/$( dirname "$SYMLINKEDFILE" )
# Try getting next symlinked file if there is any
SYMLINKEDFILE=$(readlink "$( pwd -P )/$BASENAME")
done
# since the symlinked file is not a symlink, we assume it should be the path of cli.js.
# cd into this directory and we could start the shell scripts.
cd $( dirname "$SYMLINKEDFILE" )
USAGE="Usage: eosio-explorer [command]
where [command]:
init Initialize the tool by installing all dependencies, setting up
all Docker containers, etc.
start Start the tool, assumes the dependencies and Docker images are already prepared
stop_dockers Stops any currently running Docker containers gracefully
remove_dockers Remove any currently present Docker containers
"
if [ "$#" -eq 0 ]; then
./scripts/start.sh
else
case $1 in
init)
./scripts/init.sh ${@:2}
;;
start)
./scripts/start.sh ${@:2}
;;
stop_dockers)
./scripts/stop_dockers.sh ${@:2}
;;
remove_dockers)
./scripts/remove_dockers.sh ${@:2}
;;
-v|--version)
echo $(cat package.json | grep version | awk -F: '{ print $2 }' | sed 's/[",]//g')
;;
-h|--help)
echo "$USAGE"
exit
;;
*)
printf "invalid option: %s\n" "$arg" >&2
echo "$USAGE" >&2
exit 1
;;
esac
fi