nixos/amazon-init: add user-data shell script support
This commit is contained in:
@@ -16,6 +16,16 @@ let
|
||||
|
||||
userData=/etc/ec2-metadata/user-data
|
||||
|
||||
# Check if user-data looks like a shell script and execute it with the
|
||||
# runtime shell if it does. Otherwise treat it as a nixos configuration
|
||||
# expression
|
||||
if IFS= LC_ALL=C read -rN2 shebang < $userData && [ "$shebang" = '#!' ]; then
|
||||
# NB: we cannot chmod the $userData file, this is why we execute it via
|
||||
# `pkgs.runtimeShell`. This means we have only limited support for shell
|
||||
# scripts compatible with the `pkgs.runtimeShell`.
|
||||
exec ${pkgs.runtimeShell} $userData
|
||||
fi
|
||||
|
||||
if [ -s "$userData" ]; then
|
||||
# If the user-data looks like it could be a nix expression,
|
||||
# copy it over. Also, look for a magic three-hash comment and set
|
||||
|
||||
Reference in New Issue
Block a user