I hope I can explain this correctly; I am only somewhat familiar with docker.
I have a script that I run after Home Assistant OS updates; it updates the alpine operating system with some extra packages and creates three symlinks in /usr/local/bin for three scripts in /config/shell_scripts. Up until now, it’s run perfectly when I run it manually over ssh.
Then I decided to create an automation to run it automatically after an HAOS update, and while the package updates work, the script says those symlinks exist already so it doesn’t create them; they do not exist, HAOS deletes them after an update (and Core updates might too, but I usually update them together so never checked).
After a lot of frustration, I logged into Home Assistant with root on the 22222 port and found it’s checking and finding the previously created symlinks from earlier HAOS updates inside /mnt/data/docker/overlay2/…/usr/local/bin and /var/lib/docker/overlay2/…/usr/local/bin. At least, that’s my guess; googling docker and overlays has been a trip.
So my question: how do I structure the script so that the symlink check is within the docker container’s version of /usr/local/bin so it will create the symlink?
I get the answer is probably super obvious, but I am not seeing it. The only other thing I can think to do is export /homeassistant/shell_scripts to PATH but while that works over ssh, I haven’t tested that running as a shell script service and I really want to automate this process.
Screenshot of full script attached; here’s the short version I’m using for testing. This has been checked with and without variables for paths.
#!/bin/bash
# variables
bin_home="/usr/local/bin"
shell_home="/homeassistant/shell_scripts"
# add packages
pkgs="coreutils figlet iproute2 iw jq procps-ng sed util-linux wireless-tools"
apk add $pkgs
echo "Packages Updated"
ln -s "$shell_home/lib_comp" "$bin_home/lib_comp"
ln -s "$shell_home/ipa_status" "$bin_home/ipa_status"
ln -s "$shell_home/ssh_text" "$bin_home/ssh_text"
echo "Done"
It took me until I put Home Assistant on my server in a docker container to realize what was going on there. I use docker more now, but it’s really, really nothing like this.
That’s what I’ve been doing manually over regular ssh (not the 22222 port one).
That’s what I think I need to do, but the only ‘hard’ links–at least according to multiple find -name/find -iname searches on the ssh 22222 port–are all in /mnt/data/docker/overlay2 and /var/lib/docker/overlay2. I get there’s a working pattern with the overlays but dear God why.
Okay that makes sense. I guess the first step is to get the container structure and volume.
Thanks so much! I’ll update if I find the solution or die trying.