seperis

joined 1 year ago
[–] [email protected] 2 points 2 months ago

The shell integration is why this happened.; I wanted to run the update script as a service so it could be triggered when the Supervisor or Core versions changed so it would automatically symlink my scripts in /usr/local/bin in the ssh_addon container. The shell integration runs in the homeassistant container, so that's when it became complicated.

[–] [email protected] 2 points 2 months ago (2 children)

So it can be done, it just--required a lot of steps and me making a mapping spreadsheet of all the containers. But! Automations and scripts run in the homeassistant container, while when you ssh, you're going into the ssh addon container which should have been obvious and really was once I finished mapping all the containers.

Goal: I need /usr/local/bin in the ssh container so I can run scripts over ssh and access my function library script easily without ./path/to/script.

Summary: ssh into HAOS from the homeassistant container with an HAOS root user (port 22222), run docker exec to get into the ssh addon container, then make your symlinks for /usr/local/bin.

(Note: this is ridiculously complicated and I know there has to be a better way. But this works so I win.)

  1. Get access to HAOS itself as root: https://developers.home-assistant.io/docs/operating-system/debugging. Verify you can login successfully.
  2. In homeassistant container:
  • a. create an .ssh folder (/config/.ssh)
  • b. add the authorized_keys file you made for step one.
  • c. add the public and private keys you made for step one (should be in the ssh addon container).
  • d. set permissions;
chmod 600 /config/.ssh/authorized_keys
chmod 600 /config/.ssh/PRIVATE_KEY
chmod 644 /config/.ssh/PUBLIC_KEY
chmod 700 /config/.ssh
  • e. In /config/shell_scripts.yaml or wherever you put your shell scripts, add the script you want to use to update /usr/local/bin: UPDATE_BIN_SCRIPT: /config/shell_scripts/UPDATE_BIN_SCRIPT
  • f. Restart HA.
  • g. Check it in Developer Tools->Services

I have no idea how consistent the ssh addon container name is usually but it's different on all three of my installs, so insert your container name for SSH_ADDON_CONTAINER_NAME

Steps: login to HAOS, go into the SSH Container, and do the update. This is horribly messy but hey, it works.

UPDATE_BIN_SCRIPT

#!/bin/bash

# OPTIONAL: Update some of the very outdated alpine packages in both homeassistant and the ssh addon (figlet makes cool ascii art of my server
# name).   You'll need to run it twice; once for the homeassistant container, then again in the ssh container.  Assuming you want to update packages,
# anyway
# update homeassistant container packages
apk add coreutils figlet iproute2 iw jq ncurses procps-ng sed util-linux wireless-tools

# ssh into HAOS and access docker container
ssh -i /config/.ssh/PRIVATE_KEY -p 22222 root@HA_IP_ADDRESS << EOF
	docker exec SSH_ADDON_CONTAINER_NAME \
	bash -c \
       'apk add coreutils figlet iproute2 iw jq ncurses procps-ng sed util-linux wireless-tools; \
	if [ ! -h /usr/local/bin/SCRIPT1 ]; then echo "SCRIPT1 does not exist"; \
	ln -s /homeassistant/shell_scripts/SCRIPT1 /usr/local/bin/SCRIPT1; echo "Link created"; \
	else echo "Link exists";fi; \
	if [ ! -h /usr/local/bin/SCRIPT2 ]; then echo "SCRIPT2 does not exist"; \
	ln -s /homeassistant/shell_scripts/SCRIPT2 /usr/local/bin/SCRIPT2; echo "Link created"; \
	else echo "Link exists";fi'
EOF

echo "Done"

I am going to feel really stupid when I find out there's a much easier way.

[–] [email protected] 2 points 2 months ago

Docker containers are designed to be immutable. The moment they’re stopped and recreated, any changes to them ads thrown out. You’re supposed to add a layer to your Docker image if you want to add command lines and such. That’s why it’ll keep deleting your stuff every time you update.

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.

Running the script inside Docker should put it in the right place, but I wouldn’t advice doing it that way.

That's what I've been doing manually over regular ssh (not the 22222 port one).

To work around the path issue, maybe consider using hard links rather than soft links?

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.

Alternatively, you could figure out where HAOS stores the Docker config and add a volume definition of your own. You’ll probably be able to put all of your files in /usr/local/bin by adding a line like “- /path/home/host:/usr/local/bin” in the right place. I don’t know where this config is stored, though.

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.

 

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"
 

So my Home Assistant Blue suffered a tragedy last year and I temporarily switched to using a Pi 4. Then Ameridroid had the Yellow (PoE!) available, and here I am with a Yellow, waiting for the CM4 ( CM4108032) and SSD to arrive tomorrow, and realizing I have no idea what to expect or if there is anything I should expect when I start the config and move this weekend.

Background: I've run HA for roughly four years now on Pi4, Odroid, and in Docker on my server, but since moving it to the Pi while waiting for the Yellow to come in stock, I've only done basic maintenance and working on other projects, so on a guess, I'm going to have to brush up my python and yaml. And anything that's changed that I may have missed.

This will be a scratch initial installation; after linking up my integrations and getting my naming conventions consistent, I'll start copying my yaml files and code over and decide how much of my interface I want to keep.

Any advice would be appreciated if there's anything that's very different with the Yellow hardware. I use two SmartThings Hubs for zigbee, zwave, and matter over Thread control for the most part but have been dipping my toes into direct zigbee control (just not that well yet) and trying to get direct matter over thread to work (not going well at all). And do I need my skynet dongle or Sonoff zigbee dongle or will the built in module work across the board?

 

I know how awkward that title is and I apologize.

OS: Home Assistant 11.2

Core: 2023.12.3

Computer: Raspberry Pi 4 Model B Rev 1.5

Explanation: I run a set of data collection scripts on my home network and one of the pieces of data is getting the computer model. In all my other SBCs, the below symlink gets that data.

Symlink: /proc/device-tree/model

File Location: /sys/firmware/devicetree/base/model

The symlink is broken and when I went to check the firmware directory, it is completely empty. The last update date for /sys/firmware according to ls -la is December 10 at 2:40 which when I checked my backups, is when core_2023.12.0 installed.

Attached is what should be in the firmware folder on my other Raspberry Pi 4 Model B Rev 1.5 right now.

I did a find from root for either the model file or anything vaguely resembling it and I can't find it. Anyone else have this problem or is it just happening to me? Or am I missing something?

[–] [email protected] 2 points 1 year ago

Both specific and in general 1.) Nectar mattress. The only mattresses i'd ever bought were from amazon and very on sale. Important Life Advice: whatever you have to do to make i happen, get a good mattress. Even my bed approves and it thinks everything is beneath it, including me.

2.) My bed.

Oh boy, here we go. This goddamn bed.

I bought it roughly twenty years ago and it literally took my entire tax return at my first job and then some to get it and the very first piece of furniture I personally picked out and bought for myself which may explain absolutely nothing about how I ended up like this.

It's fairly straightforward, plain four poster queen bed but so incredibly melodramatic no matter the room I put it in, this thing will dramatically not fit and carry on like it's actually in a castle tower in 1700s Frances waiting for a princess to sleep in it (it did not act like this at the store, okay). It has an unnecessary number of parts (some really could have been consolidated and a couple I'm not sure even have a function other than to add time to assembling it) every piece of it is awkward to move, even the parts that have no reason to be and don't look like they are, and every single piece is ten times heavier than than look or is reasonable, sane, or really should even be possible. The wood is dark and does a very cool dark gleaming thing, and it takes hours to clean and oil it to a soft gleam (so. goddamn. many. parts). Twenty-four hours later it's sitting there dull and dramatically telling everyone who sees it I never clean it and also use substandard wood oil

It takes a very base minimum of two people to even attempt to put it together and you better not have plans for the rest of the day because it doesn't matter how many times you have done this, somehow, you will always get six parts wrong because whoever designed this has another job making complicated puzzle locks that you will never solve and will die mad about it (this person is a sadist). Just looking at it in any given bedroom I live in, it makes me feel I should be wearing something long, white, and flowy while waiting for my angsty vampire lover to visit me in the dead of the night and not taking my night's sleep shorts and a tank top.

This bed is a snobby, judgemental asshole who acts like I didn't buy it at the goddamn Roomstore at ten percent off because it was a floor model.

But. it's a goddamn tank that's been in substandard moving vans and the backs of multiple trucks and dropped down stairs and sometimes forgets to at least look scuffed. It will survive all the wars and still give its occupants a great night's sleep. Those deceptively slim posts are strong enough to joust with a burglar, beat him to death, and then put back and rehang my very melodramatic bed curtains on them (though I'll need a little hysterical strength to hold them up for very long; I am not kidding how stupid heavy those thing are and should not be). I love this bed, it is my soulmate, and it is where I will sleep until I move to a convenient grave. I hope all of you are able to have one of these in your life and if you already do, you have my condolences; but it's ride or die now.

3.) The best headphones I can afford and a budget for potential upgrade/replace every two years (you don't have to use that timeline,but it works for me). Related: Sonos speakers. No, they are not the best in any class but they are good to really good in multiple speaker classes and are affordable--if you budget strictly and buy a piece at a time or watch for amazon sales like it's your job--for normal people.

4.) Kindle may actually be the most important single decision I have made in my life. I like books; I didn't want to use a screen. I did it and a decade and change greater with slowly degrading eyesight I bless the day I decided to try it every day. Currently on an Oasis.

5.) Giving up and budgeting specifically to pay a ridiculous amount of money for my jeans. Sure, the receipts legit horrifies me, but they fit perfectly,, are crazy comfortable, can pretty much survive anything I do to them (and I am hard on my clothes) and some have been with me since before the Obama administration and don't even have a loose thread on them. I have literally every single pair i ever bought and they still look great (and I never add up the cost of them all and what thing I could have bought with that much money, God).