-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to source bash script on login #735
Comments
What path did you place Edit - To be clear was it within the addon or added externally? |
I guess it is in addon since the /root/config/docsalvager/.bashrc file appears both when accessed via the HA Addon in HA as well as via sftp. I know of no other way to get Linux commandline access to the HomeAssistant OS 12.3 host. Though I've been programming Unix/Linux systems for over 40 years, I'm new to Docker containers and very confused by all the security that prevents access to the real operating system. |
I had the same issue and worked around it by writing a file by using the init_commands for the addon. For example, I had this:
which gave me a
You could write I realise that I could have installed the system package pytest via the addon package mechanism, but I preferred this approach. -paul |
Problem/Motivation
Attempting to customize login shell such as having a bash alias invoked to list files the way I want, but the only way this works is to type out the command after ssh login. I have SFTP enabled so login user has to be root. Login correctly puts me in the Docker container's copy of /root.
Expected behavior
Successful login and sourcing of the .bashrc file.
Actual behavior
Any file created in /root is lost on restart but can create persistent files in ./config, ./homeassistant, etc. so did that and set the init_commands field in the addon configuration to source that file...
. ./config/docsalvager/.bashrc
(yes the "docsalvager" directory I created persisted)
The .bashrc file contains only 1 line...
alias ll='ls -la'
After restart of the addon, it refuses to start in Home Assistant and any attempt to login remotely (which was working before) fails with...
ssh: connect to host ha01 port 22: Connection refused
NOTE that zsh is turned off in the configuration.
Relevant lines in the addon log...
/etc/s6-overlay/s6-rc.d/init-user/run: line 112: ./config/docsalvager/.bashrc: No such file or directory [16:33:56] FATAL: Failed executing init command: . ./config/docsalvager/.bashrc s6-rc: warning: unable to start service init-user: command exited 1 /run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs/current if you have in-container logging) for more information. /run/s6/basedir/scripts/rc.init: fatal: stopping the container.
Further experimentation revealed that the init_commands field requires full pathnames so the correct entry is...
. /root/config/docsalvager/.bashrc
On using this, the addon started but still failed to source the .bashrc file.
Steps to reproduce
See above.
Proposed changes
The addon should start and display relevant error messages if there is a problem with the sourced file. Otherwise, it should source the file.
The text was updated successfully, but these errors were encountered: