Use apt-get commands

I have solved it, all command were actually fine, but I opened an session in docker itself, to see what went wrong, because it worked in an ssh session from ssh addon … Seems ssh add-on is running alpine 3.13 and HassOs is running 3.12 and that apk is not part of 3.12 …
So I needed to modify script to download another apk version

Hmm I’m having a small issue: Where do you put the following:

shell_command: 
setup: /config/scripts/setup.sh

Does this go in /config/configuration.yaml or another location?

I put the following in the /config/configuration.yaml file:

shell_command:
  setup: /config/shell/setup.sh

My /config/automations

- id: '1635091517986'
  alias: startup
  description: Adds APK packages to HomeAssistant through apk package manager at boot
  trigger:
  - platform: homeassistant
    event: start
  action:
  - service: shell_command.setup
  initial_state: 'on'

Here is /config/shell/setup.sh:

#! /bin/sh

# apk_add_packages_at_boot.sh
# Script taken from: https://community.home-assistant.io/t/use-apt-get-commands/236873/4

apk update
apk add git-lfs

My log files however say this:

startup: Error executing script. Service not found for call_service at pos 1: Unable to find service shell_command.setup

try to do it manually first

3 Likes

@elRadix

OK - I tried manually. I could install the package. Being this is a docker image however, the added file isn’t going to stay after reboot.

In doing some reading – I think I’m approaching things a little wrong, With what you’re telling me to do I’m adding git-lfs package inside the docker container – homeassistant. I think however I want to add git lfs inside the Home Assistant OS – not the container. I can add this package inside the OS – however after a reboot it’s gone as well.

Based on the information I’m gathering, it looks like there is a great method to add permanent packages inside the homeassistant OS :frowning:

I have the script running at each reboot executing the shell command
you can also execute the the shell command manually in dev tools

automation:

- id: hass_1
  initial_state: true
  alias: System Startup Notification
  trigger:
    platform: homeassistant
    event: start
  action:
    - service: notify.telegram
      data:
        message: Home Assistant back online! at {{now().strftime("%H:%M:%S")}}
    - service: shell_command.setup

setup: !secret shell_command_setup
shell_command_setup: "/config/scripts/setup.sh"

setup. sh

#!/bin/sh
echo "Updating Image with Easyplus Tools"
apk update
apk add -u busybox
apk add busybox-extras
apk add expect
apk add sshpass
pip3 install pexpect
echo "Easyplus Tools Installed"
sh /config/scripts/ssh-login-alert-telegram/deploy.sh
1 Like

What files are you putting the following commands in:

setup: !secret shell_command_setup

shell_command_setup: "/config/scripts/setup.sh"

How do you add packages to the HassOS system? When I access it, I get “apk add…” Apk not found …

Is there also a way to make it permanent after a reboot?

I need to compile something, inside the HassOS itself, I need to add the linux-headers

1 Like

any idea here? having the same issue,
trying to install htop inside haas OS

HassOS is based on buildroot, not possible to add packages there… You can however add packages in the homeassistant container

@pergola.fabio yes, so it means i cant install htop inside HassOS?

no, not inside hassos, only inside homeassistant container

see below

remember, you need todo it again on an HA update, or just add in an automation

image

@pergola.fabio yes got it, but sometimes you need analyze hassos instead of homeassistant container. my homeassistant was eating 50% cpu constantly and to find out the issue i need to login into hassos and find out the problematic process… it wont be possible on container level.

HassOS isnt alpine, its buildroot, there is no package installer there

top is in both os and HA container
The community SSH and web terminal has htop pre-installed

1 Like

but thats avail only within docker/container not inside hassOS

What does top not show that htop would?
or glances for that matter.

same … but htop just more convenient.

I think you all might be better off installing HA core on top of your own OS such as Raspbian, then all these problems go away and you can do what you want with packages in the OS :slight_smile:

1 Like

I manually have to type in “resize” to size terminal properly in tmux all the time when resizing windows. Normally adding xterm package solves this issue, not sure what problem is with ha. I have this running under BHYVE virtualization in FreeBSD.