I'm having trouble to understand the shell environement that is used to run startup scripts. What difference with a login session?
If I set a simple starup script to print the env variables:
metadata
items:
- key: startup-script
value: ' printenv;'
I will have something like this:
Feb 20 15:16:19 xxxx startup-script[1112]: INFO startup-script: OLDPWD=/
Feb 20 15:16:19 xxxx startup-script[1112]: INFO startup-script: PATH=/usr/local/sbin:/usr/local/bin:/usr/
Feb 20 15:16:19 xxxx startup-script[1112]: INFO startup-script: PWD=/opt
Feb 20 15:16:19 xxxx startup-script[1112]: INFO startup-script: LANG=en_US.UTF-8
Feb 20 15:16:19 xxxx startup-script[1112]: INFO startup-script: SHLVL=2
Feb 20 15:16:19 gceeuw1lin0003 startup-script[1112]: INFO startup-script: _=/usr/bin/printenv
And if I execute printenv command on ssh session, I can see a lot more variables like HOSTNAME, HOME, SHELL...etc.
I'm trying to install a software at startup (proprietary software) but it's failing because of the $HOME variable.
Could not expand the path using $HOME
I tried to setup the HOME varibale in the startup script just before the software installation, but it's failing saying:
invalid command name "wm"
When I try the same installation using an interactive shell, all works fine! Even better, It works even if I force to rerun the startup scrip from my interactive session using this command:
sudo google_metadata_script_runner --script-type startup --debug
I'm looking for a logical explanation to what's happening? why it's working from the interactive shell and not from the startup script?
Any idea how to fix this?
Thank you in advance!