Jip-Hop / jailmaker

Persistent Linux 'jails' on TrueNAS SCALE to install software (k3s, docker, portainer, podman, etc.) with full access to all files via bind mounts thanks to systemd-nspawn!
GNU Lesser General Public License v3.0
419 stars 35 forks source link

Feature Request: Accepting config template from stdin #208

Closed Lockszmith-GH closed 1 week ago

Lockszmith-GH commented 3 weeks ago
jlmkr create --start --config <template file path> <jail-name>

is such a great feature, I would recommend exapding it to allow input form stdin, which would allow something like:

jlmkr create --start --config - nixos < <( curl -sL https://raw.githubusercontent.com/Jip-Hop/jailmaker/develop/templates/nixos/config )

or even:

jlmkr create --start --config - nixos < <( curl -sL https://raw.githubusercontent.com/Jip-Hop/jailmaker/develop/templates/nixos/config | sed -e 's|/br1|/br0|')

The common convetion in linux is to read from stdin when a dash (-) is passed a file name, so following that seems like a safe option.

Jip-Hop commented 3 weeks ago

Try it like this:

jlmkr create --start --config=<( curl -sL https://raw.githubusercontent.com/Jip-Hop/jailmaker/develop/templates/nixos/config) nixos
Lockszmith-GH commented 3 weeks ago

Yes, I thought of that, this will work if I'm in a root login (yes, yes, I know - I should be in it already), but if runing via sudo, the file-descriptor does not pass across the different contexts. The pipeline does not have this limitation.

$ sudo jlmkr create --start --config <(cat $SCALE_POOL_ROOT/jailmaker/templates/nixos/config) nixostest
USE THIS SCRIPT AT YOUR OWN RISK!
IT COMES WITHOUT WARRANTY AND IS NOT SUPPORTED BY IXSYSTEMS.
Creating jail nixostest from config template /dev/fd/63.
Failed to read config template /dev/fd/63.
Jip-Hop commented 3 weeks ago

Yes, I see. PR is welcome if you feel like implementing this! 😉 The config file handling needs a bugfix too.

Lockszmith-GH commented 3 weeks ago

I'll take a look later today, felx my Python a bit :)

Jip-Hop commented 2 weeks ago

This should now work with jlmkr on the develop branch.

curl -sL https://raw.githubusercontent.com/Jip-Hop/jailmaker/develop/templates/docker/config | jlmkr create --start --config - docker

Please test and provide feedback.

Lockszmith-GH commented 1 week ago

I did, and I love it