/
githubmirror
/
zulip
Обзор
Документация
Войти
/
githubmirror
/
zulip
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tools/setup/pack-local-script
25 строк
707 B
Alex Vandiver
pack-local-script: Match mode of file outside of packing.
07 фев 2024, 21:42
07 фев 2024, 21:42
b1f8995
Код
Авторство
О чём код?
#!/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" mode="$(stat -c "%a" "$file")" encoded="$(gzip --stdout "$file" | base64)" cat <<embedded-shell-output $var="\$(mktemp)" chmod "$mode" "\$$var" base64 -d <<"encoded-shell-script" | gzip -d > "\$$var" $encoded encoded-shell-script embedded-shell-output