/srv/irclogs.ubuntu.com/2019/07/11/#cloud-init.txt

infogulchHi!20:27
infogulchI found that $USER is not set in a runcmd script, but whoami says root.  What kind of shell environment should I expect in a runcmd script?20:29
bitfehlerinfogulch: no shell at all, I would say. the command gets run straight out of cloud-init20:32
bitfehleryou could of course run "bash -c 'command you actuallly want'"20:32
bitfehlerbut that may or may not make sense. what are you trying to achieve?20:33
infogulchWell i'm using the second mode.  From the docs: "If the item is a string, it will be written to a file and interpreted using sh."20:33
infogulchI'm writing it as:   runcmd: |\n[shell commands....]20:33
infogulchwhich i guess is basically equivalent to "sh -c 'commands...'"20:34
bitfehleroh right. also, apparently $USER is not set by the shell, but even before it on regular login: https://unix.stackexchange.com/questions/76354/who-sets-user-and-username-environment-variables20:35
bitfehlerwhich you don't have (a login)20:36
infogulchAh ok that explains it20:36
infogulchHmm that makes me wonder what else I'm missing20:36
bitfehlerso i suppose everything you can find in the POSIX shell standard should work20:36
infogulchOk.  I guess I'm not intimately familiar with the posix shell standard20:39
infogulchThank you!20:41
Odd_Blokeinfogulch: I haven't done this myself, but if you run `env > /tmp/env` in a runcmd, you should get an idea of what you can expect.20:46
infogulchThat's a good idea thank you20:47

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!