3 ms·
Not literally, no, as you need an init program that performs certain steps first which bash can't do. But once those few operations are done you can pass execut
by 0xbadcafebee 6y ago
Not literally, no, as you need an init program that performs certain steps first which bash can't do. But once those few operations are done you can pass execution off to a script.
It looks like your init is running the gamut of typical linux init steps: handling signals, spawning processes, handling TTYs, running typical system start-up commands. Then it gathers host and network metrics, reports results, and operates as some kind of websocket server? All of that other stuff should live in a separate dedicated program that the init script runs. Unless I missed something and that's not possible?
- tptacek 6y agoWe can't assume any particular environment inside a VM; we don't own the "distribution", or really anything other than init itself, including libraries. We could make something work, but it'd be more effort than what we do now, which is just some trivial straight-line Rust code, in an init that was going to be Rust anyways. We wrote a little more about this here: https://fly.io/blog/docker-without-docker/ https://fly.io/blog/docker-without-docker/
- 0xbadcafebee 6y agoYeah, so you'd use an initrd as "your" environment, run your programs, pivot_root (or the modern equivalent) and then pass execution to your guest's environment, which can have its own init. I say it will eventually be rewritten as a shell script (minus the stats, which will be replaced by a monitoring agent) because people messing with embedded Linux often try writing their own compiled init to bundle with an initrd. It eventually becomes a hassle, so they either make their own feature-filled init replacement, or they go back to a shell script. Most go for the shell script. I mean, it's a DSL for composing programs. It's too powerful for what you need to do, but all its other advantages (portability, flexibility, simplicity, tracing, environment passing, universal language, rapid development, cheaper support, yadda yadda) make it a win over time. The only reason I can see not to use a shell script is if speed is your highest priority.
- tptacek 6y agoI like shell scripts too. I once wrote a shell script that converted X.509 certificates into shell scripts that generated the same X.509 certificate, field by field. Shell scripts are great. Not the right tool here, but, great.