forked from flynn/flynn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-examples
More file actions
executable file
·67 lines (53 loc) · 1.44 KB
/
Copy pathgenerate-examples
File metadata and controls
executable file
·67 lines (53 loc) · 1.44 KB
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
#!/bin/bash
#
# A script to generate controller examples to STDOUT.
set -e
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
source "${ROOT}/script/lib/ui.sh"
usage() {
cat <<USAGE >&2
usage: $0 <controller|router> [options]
OPTIONS:
-h Show this message
-p PORT The port to start the resource server on [default: 12345]
USAGE
}
main() {
local ip port component
case $1 in
controller) component=$1 ;;
router) component=$1 ;;
*)
usage
echo "Invalid component: $1"
exit 2
;;
esac
while getopts 'hi:p:' opt; do
case "${opt}" in
h)
usage
exit 1
;;
i) ip="${OPTARG}" ;;
p) port="${OPTARG}" ;;
c) component="${OPTARG}" ;;
?)
usage
exit 2
;;
esac
done
port="${port:-"12345"}"
export CONTROLLER_KEY="s3cr3t"
info "bootstrapping flynn" >&2
cluster_add=$("${ROOT}/script/bootstrap-flynn" &> >(tee /dev/stderr) | grep "flynn cluster add" | tail -1)
if [[ "${cluster_add:0:17}" != "flynn cluster add" ]]; then
fail "Bootstrap failed"
fi
info "generating ${component} examples..." >&2
imageid=`sudo docker images --no-trunc -q flynn/${component}-examples | tr -d '\r\n'`
imageurl="https://dl.flynn.io/images?name=flynn/${component}-examples&id=$imageid"
${ROOT}/host/bin/flynn-host run $imageurl sh -c "CONTROLLER_KEY=${CONTROLLER_KEY} PORT=${port} /bin/flynn-${component}-examples" 2>&1
}
main $@