forked from 18F/health-tracking-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.bash
58 lines (50 loc) · 1.14 KB
/
entry.bash
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
#!/bin/bash
set -e
set -u
set -o pipefail
# Possible flags on the command line
build_flag=''
serve_flag=''
# Functions invoked by flags
function build () {
pushd /site || exit
bundle config set --local path 'vendor/bundle'
bundle add jekyll --version "~> 4.2"
bundle exec jekyll build
exit $?
}
function serve () {
pushd /site || exit
bundle config set --local path 'vendor/bundle'
bundle add jekyll --version "~> 4.2"
bundle exec jekyll serve --incremental --host 0.0.0.0
exit $?
}
function print_usage () {
echo "Usage:"
echo "\t-b\t\tBuild the site. Leaves output in _site."
echo "\t-s\t\tServe the site. Visit at the exposed port."
}
# Process the flags
while getopts ':bs' flag; do
case "${flag}" in
b) build_flag='true'
;;
s) serve_flag='true'
;;
*) usage >&2
print_usage
exit 1 ;;
esac
done
# Take action based on flags.
if [[ $build_flag == 'true' ]]; then
build;
exit 0;
fi
if [[ $serve_flag == 'true' ]]; then
serve;
exit 0;
fi
# Should never get here.
echo "ERROR. Likely misuse of container."