mirror of https://github.com/zulip/zulip.git
24 lines
671 B
Plaintext
24 lines
671 B
Plaintext
|
#!/usr/bin/env bash
|
||
|
|
||
|
# This tool generates code in shell which is meant to be inline'd into
|
||
|
# a larger script; called with a variable name and a path, it produces
|
||
|
# a script which will result in that variable being set to the path to
|
||
|
# the contents of that path.
|
||
|
#
|
||
|
# This is used in bootstrap-aws-installer to bundle local files into
|
||
|
# the EC2 user data, so that those canonical versions can be used to
|
||
|
# bootstrap the host.
|
||
|
set -eu
|
||
|
|
||
|
var="$1"
|
||
|
file="$2"
|
||
|
|
||
|
encoded="$(gzip --stdout "$file" | base64)"
|
||
|
cat <<embedded-shell-output
|
||
|
$var="\$(mktemp)"
|
||
|
chmod 755 "\$$var"
|
||
|
base64 -d <<"encoded-shell-script" | gzip -d > "\$$var"
|
||
|
$encoded
|
||
|
encoded-shell-script
|
||
|
embedded-shell-output
|