Skip to content

Commit 404e0e7

Browse files
committed
tf: Add some interactive user goodies
Alias of dc=docker-compose alias for 700% effeciency gains. Alias tink for even more gains! Automatically cd'ing to /root/sandbox/compose for interactive logins because that probably makes a lot of sense. And a `tink` wrapper/helper script that calls docker-compose underneath. Much nicer than `dc` calls everywhere and will even work with `watch`. Signed-off-by: Manuel Mendez <[email protected]>
1 parent 8c67d0b commit 404e0e7

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

deploy/terraform/setup.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ setup_compose_env_overrides() {
126126
done
127127
}
128128

129+
create_tink_helper_script() {
130+
cat >/usr/local/bin/tink <<-'EOF'
131+
#!/usr/bin/env bash
132+
133+
exec docker-compose -f /root/sandbox/compose/docker-compose.yml exec tink-cli tink "$@"
134+
EOF
135+
chmod +x /usr/local/bin/tink
136+
}
137+
138+
tweak_bash_interactive_settings() {
139+
grep -q 'cd /root/sandbox/compose' ~root/.bashrc || echo 'cd /root/sandbox/compose' >>~root/.bashrc
140+
readarray aliases <<-EOF
141+
dc=docker-compose
142+
EOF
143+
for alias in "${aliases[@]}"; do
144+
grep -q "$alias" ~root/.bash_aliases || echo "alias $alias" >>~root/.bash_aliases
145+
done
146+
}
147+
129148
main() {
130149
worker_mac=$1
131150
layer2_ip=192.168.56.4
@@ -143,6 +162,9 @@ main() {
143162
extract_compose_files
144163
setup_compose_env_overrides "$worker_mac"
145164
docker-compose -f /root/sandbox/compose/docker-compose.yml up -d
165+
166+
create_tink_helper_script
167+
tweak_bash_interactive_settings
146168
}
147169

148170
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then

docs/quickstarts/TERRAFORMEM.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This option will also show you how to create a machine to provision.
5353
5454
# watch the workflow events and status for workflow completion
5555
# once the workflow is complete (see the expected output below for completion), move on to the next step
56-
wid=$(docker exec -it compose_tink-cli_1 tink workflow get --no-headers | awk '/^\|/ {print $2}'); docker exec -it compose_tink-cli_1 watch -n1 "tink workflow events ${wid}; tink workflow state ${wid}"
56+
wid=$(tink workflow get --no-headers | awk '/^\|/ {print $2}'); watch -n1 "tink workflow events ${wid}; tink workflow state ${wid}"
5757
```
5858
5959
<details>

0 commit comments

Comments
 (0)