forked from polydawn/repeatr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.sh
executable file
·148 lines (123 loc) · 4.61 KB
/
demo.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
set -eo pipefail
if [ -x .gopath/bin/repeatr ]; then PATH=$PWD/.gopath/bin/:$PATH; fi
if [ -x repeatr ]; then PATH=$PWD:$PATH; fi
if [ "$1" != "-t" ]; then straight=true; fi; export straight;
demodir="demo";
cnbrown="$(echo -ne "\E[0;33m")" # prompt
clblack="$(echo -ne "\E[1;30m")" # aside
clbrown="$(echo -ne "\E[1;33m")" # command
clblue="$(echo -ne "\E[1;34m")" # section docs
cnone="$(echo -ne "\E[0m")"
awaitack() {
[ "$straight" != true ] && return;
echo -ne "${cnbrown}waiting for ye to hit enter, afore the voyage heave up anchor and make headway${cnone}"
read -es && echo -ne "\E[F\E[2K\r"
}
tellRunning() {
echo -e "${clblack}# running \`${clbrown}$@${clblack}\` >>>${cnone}"
}
rm -rf "$demodir"
mkdir -p "$demodir" && cd "$demodir" && demodir="$(pwd)"
echo "$demodir"
echo "$(which repeatr)"
export REPEATR_BASE="$demodir/repeatr_base"
echo -e "${clblue}# Repeatr says hello!${cnone}"
echo -e "${clblue}# Without a command, it provides help.${cnone}"
(
tellRunning "repeatr"
time repeatr
)
echo -e "${clblue} ----------------------------${cnone}\n\n"
awaitack
echo -e "${clblue}# To suck in data, use the pack command:${cnone}"
echo
(
tellRunning "repeatr pack --help"
time repeatr pack --help
tellRunning "repeatr pack --kind=tar"
time repeatr pack --kind=tar
)
echo
echo -e "${clblue}# This determines the data identity,${cnone}"
echo -e "${clblue}# Uploads it to a warehouse,${cnone}"
echo -e "${clblue}# And outputs the config to request it again later.${cnone}"
echo -e "${clblue} ----------------------------${cnone}\n\n"
awaitack
echo -e "${clblue}# The \`repeatr run\` command takes a job description and executes it.${cnone}"
echo -e "${clblue}# Stdout goes to your terminal; any 'output' specifications are saved/uploaded.${cnone}"
echo -e "${clblue}# This first run might take a while -- it's downloading an operating system image first!${cnone}"
(
mkdir -p "${demodir}/local-warehouse"
tellRunning "repeatr run some-json-config-files.conf"
time repeatr run $CI_FLAGS <(cat <<-EOF
{
"inputs": {
"/": {
"type": "tar",
"hash": "uJRF46th6rYHt0zt_n3fcDuBfGFVPS6lzRZla5hv6iDoh5DVVzxUTMMzENfPoboL",
"silo": "http+ca://repeatr.s3.amazonaws.com/assets/"
}
},
"action": {
"command": [ "echo", "Hello from repeatr!" ]
},
"outputs": {
"/var/log": {
"type": "tar",
"silo": "file+ca://${demodir}/local-warehouse"
}
}
}
EOF
)
)
echo -e "${clblue} ----------------------------${cnone}\n\n"
awaitack
echo -e "${clblue}# The \`repeatr run\` command can used cached assets to start jobs faster.${cnone}"
echo -e "${clblue}# Here we use the same rootfs image of ubuntu, so it starts instantly.${cnone}"
(
tellRunning "time repeatr run some-json-config-files.conf"
time repeatr run $CI_FLAGS <(cat <<-EOF
{
"inputs": {
"/": {
"type": "tar",
"hash": "uJRF46th6rYHt0zt_n3fcDuBfGFVPS6lzRZla5hv6iDoh5DVVzxUTMMzENfPoboL",
"silo": "http+ca://repeatr.s3.amazonaws.com/assets/"
}
},
"action": {
"command": [ "echo", "Hello from repeatr!" ]
},
"outputs": {
"/var/log": {
"type": "tar",
"silo": "file+ca://${demodir}/local-warehouse"
}
}
}
EOF
)
)
echo -e "${clblue}# Also, note that the output is the same hash?${cnone}"
echo -e "${clblue}# Given the same inputs, this command produces the same outputs, every time. ;)${cnone}"
echo -e "${clblue} ----------------------------${cnone}\n\n"
awaitack
echo -e "${clblue}# We also included an output spec in those last two commands.${cnone}"
echo -e "${clblue}# That means repeatr uploaded our data to the 'warehouse' we gave it --${cnone}"
echo -e "${clblue}# warehouses act like permanent storage for your data.${cnone}"
echo -e "${clblue}# We just used a local filesystem, so let's see how that looks:${cnone}"
(
tellRunning "ls -lah \$demodir/local-warehouse"
ls -lah "${demodir}/local-warehouse"
)
echo -e "${clblue}# Content addressible storage means the same data gets de-duplicated automatically --${cnone}"
echo -e "${clblue}# since both of our jobs produced the same output, it's just here stored once.${cnone}"
echo -e "${clblue}# Everything in a warehouse has guaranteed integrity based on the hashes.${cnone}"
echo -e "${clblue}# If a warehouse suffers disk corruption? You're covered -- you'll know immediately.${cnone}"
echo -e "${clblue}# If a warehouse gets hacked? You're covered -- if the attacker changed anything, you'll know immediately!${cnone}"
echo -e "${clblue}# Here we used a local filesystem, but other warehousing options include S3, for example.${cnone}"
echo -e "${clblue} ----------------------------${cnone}\n\n"
awaitack
echo "${clblue}# That's all! Neat, eh?${cnone}"