-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathmanager.sh
85 lines (67 loc) · 1.5 KB
/
manager.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
78
79
80
81
82
83
84
85
#!/bin/bash
set -e
prj_path=$(cd $(dirname $0); pwd -P)
SCRIPTFILE=`basename $0`
source $prj_path/base.sh
app_image=jekyll/jekyll:3.2.1
app_container=blog-jekyll
function run_blog_container() {
cmd=$1
args=''
args="$args -v $prj_path:/opt/app"
args="$args -w /opt/app"
run_cmd "docker run --net=host -it $args --rm --name $app_container $app_image $cmd"
}
function stop_blog_container() {
stop_container $app_container
}
function into_blog() {
run_blog_container '/bin/bash'
}
function build_log() {
run_blog_container 'jekyll build -w'
}
function serve() {
run_blog_container 'jekyll serve'
}
function show_usage() {
cat <<-EOF
Usage: mamanger.sh [options]
Valid options are:
build build blog
into-blog
stop-blog
-h show this help message and exit
EOF
exit $1
}
while :; do
case $1 in
-h|-\?|--help)
show_usage
exit
;;
build)
build_log
exit
;;
serve)
serve
exit
;;
into-blog)
into_blog
exit
;;
stop-blog)
stop_blog_container
exit
;;
*) # Default case: If no more options then break out of the loop.
printf 'ERROR: no such option.\n' >&2
show_usage
exit 1
break
esac
shift
done