Solved How to set environment variables inside a "jexec" call?

I would like to call a command inside a jail using jexec(8) while setting environment variables for that particular call.

In a shell inside the jail I would call: KEYCLOAK_ADMIN=admin KEYCLOAK_ADMIN_PASSWORD=admin ./kc.sh show-config

How can I trigger this call outside of the jail? I tried passing the variables before the executable name (both in a single string parameter to jexec and as multiple parameters) but neither worked:
Bash:
    jexec "$JID" \
        KEYCLOAK_ADMIN=admin \
        KEYCLOAK_ADMIN_PASSWORD=admin \
        /usr/local/share/java/keycloak/bin/kc.sh show-config
# jexec: execvp: KEYCLOAK_ADMIN=admin: No such file or directory

    jexec "$JID" \
        "KEYCLOAK_ADMIN=admin  KEYCLOAK_ADMIN_PASSWORD=admin  /usr/local/share/java/keycloak/bin/kc.sh show-config"

# jexec: execvp: KEYCLOAK_ADMIN=admin  KEYCLOAK_ADMIN_PASSWORD=admin  /usr/local/share/java/keycloak/bin/kc.sh show-config: No such file or directory

I am not quite sure if I set the variables before "jexec" would they be passed to the shell inside the jail? I would find that weird.
 
FOO=BAR BAZ=OOF jexec vnetjail /bin/sh -c 'echo $FOO $BAZ'
I need to go with the env solution because I sometimes go my jexec two deep:
Code:
[18:44 r730-01 dvl ~/bin] % sudo PAGER=cat jexec dev-ingress01 jexec freshports echo $PAGER                
more

For example, when doing this:

Code:
$ sudo jexec dvl-ingress01 jexec freshports /usr/bin/env PAGER=cat freebsd-update fetch install

Setting that variable allows the command to proceed without pausing for user input.
 
Back
Top