Skip to content

Multi-line init commands are implicitly split by startup script #976

@ntninja

Description

@ntninja

I have this in my configuration.yaml for this great add-on:

init_commands:
  - cp -ar /data/system/* /
  - pip install --break-system-packages mpremote
  - |
    cat >> ~/.zshrc <<'EOF'
    # Use GNU nano as default editor in shell
    export EDITOR=nano

    # Enable command-not-found integration
    command_not_found_handler() {
        /usr/libexec/command-not-found "$@";
    }
    EOF

As you can see it attempts to append several configuration lines to the Zshell configuration file on addon startup.

The newlines are correctly stored in the addon options (/mnt/data/supervisor/addons/data/a0d7b954_ssh/options.json):

{
  
  "init_commands": [
    "cp -ar /data/system/* /",
    "pip install --break-system-packages mpremote",
    "cat >> ~/.zshrc <<'EOF'\n# Use GNU nano as default editor in shell\nexport EDITOR=nano\n\n# Enable command-not-found integration\ncommand_not_found_handler() {\n    /usr/libexec/command-not-found \"$@\";\n}\nEOF\n"
  ]
}

However the add-on’s startup script breaks them into multiple lines:
https://github.com/hassio-addons/addon-ssh/blob/50c387cb56f30ea3acfd401a7978136ea392cc5a/ssh/rootfs/etc/s6-overlay/s6-rc.d/init-user/run#L110-L115

Causing errors when executing this code:

/etc/s6-overlay/s6-rc.d/init-user/run: line 112: warning: here-document at line 112 delimited by end-of-file (wanted `EOF')
/etc/s6-overlay/s6-rc.d/init-user/run: eval: line 113: syntax error: unexpected end of file
[21:04:49] FATAL: Failed executing init command: command_not_found_handler() {
s6-rc: warning: unable to start service init-user: command exited 1
/run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs/current if you have in-container logging) for more information.
/run/s6/basedir/scripts/rc.init: fatal: stopping the container.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions