pack-local-script: Match mode of file outside of packing.

This commit is contained in:
Alex Vandiver 2024-02-07 12:28:01 -05:00 committed by Tim Abbott
parent 5672595c2a
commit b1f899512a
3 changed files with 3 additions and 1 deletions

0
puppet/kandra/files/install-ssh-authorized-keys Normal file → Executable file
View File

0
puppet/kandra/files/install-ssh-keys Normal file → Executable file
View File

View File

@ -13,10 +13,12 @@ set -eu
var="$1" var="$1"
file="$2" file="$2"
mode="$(stat -c "%a" "$file")"
encoded="$(gzip --stdout "$file" | base64)" encoded="$(gzip --stdout "$file" | base64)"
cat <<embedded-shell-output cat <<embedded-shell-output
$var="\$(mktemp)" $var="\$(mktemp)"
chmod 755 "\$$var" chmod "$mode" "\$$var"
base64 -d <<"encoded-shell-script" | gzip -d > "\$$var" base64 -d <<"encoded-shell-script" | gzip -d > "\$$var"
$encoded $encoded
encoded-shell-script encoded-shell-script