Problem with custom addon exec /run.sh: no such file or directory

Hi
I have tried to create a custom addon, raspap, which I will want to run with it’s own USB wlan and lan adapter. It doesn’t need to talk to HA in anyway. I just want the dockerfile to run on the same Pi and give it access to the USB ports.

There is a docker image available for RaspAP, which I want to use as the base image for the Addon.

I have done these files:

config.yaml

name: "RaspAP"
description: "RaspAP running in a Docker container"
version: "1.0.0"
slug: "raspap"
init: false
arch:
  - armhf
  - armv7
  - aarch64
host_network: true
privileged:
  - SYS_ADMIN
devices:
  - /dev/ttyUSB0
  - /dev/ttyUSB1
map:
  - config:rw
ports:
  80/tcp: 80

Dockerfile

ARG BUILD_FROM
FROM ghcr.io/raspap/raspap-docker:latest

# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh

CMD [ "/run.sh" ]

run.sh

#!/usr/bin/with-contenv bashio

# Make cgroups writable for ARM devices
mkdir -p /sys/fs/cgroup
mount -t tmpfs -o remount,rw /sys/fs/cgroup

# Run RaspAP
/usr/sbin/raspap.sh

I tried to incorporate the instructions for the RaspAP dockerfile from here: GitHub - RaspAP/raspap-docker: A community-led docker container for RaspAP

It builds the addon, when I install it. But if I run it I get:

exec /run.sh: no such file or directory

In the log.

Any help is appreciated. I’m totally new to this and don’t really know what I am doing…

So I have made some… progress in trying to get the RaspAP dockerfile running within home assistant (HA) as an addon. Still, there is no need for it to talk to HA in anyway.

Now my dockerfile

ARG BUILD_FROM
FROM ghcr.io/raspap/raspap-docker:latest

# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh

CMD ["/run.sh"]

my config.yaml

name: "RaspAP"
description: "RaspAP running in a Docker container"
version: "1.0.0"
slug: "raspap"
init: false
arch:
  - armhf
  - armv7
  - aarch64
host_network: true
privileged: true
devices:
  - /dev/ttyUSB0
  - /dev/ttyUSB1
  - /sys/fs/cgroup:/sys/fs/cgroup:rw
map:
  - config:rw
ports:
  80/tcp: 80

my run.sh

#!/bin/sh

# Run RaspAP
tail -f /dev/null

the last line is to keep the container running.

However, raspAP does not run in the container. It should start on startup, but
when I ssh into HA and enter the container and start raspAp manually I get this exchange:

➜  ~ docker exec -it addon_local_raspap /bin/bash

root@local-raspap:/# ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   2316  1152 ?        Ss   11:27   0:00 /bin/sh /run.sh
root           7  0.0  0.0   2252  1024 ?        S    11:27   0:00 tail -f /dev/null
root           8  0.0  0.0   4052  3200 pts/2    Ss   11:31   0:00 /bin/bash
root          14  0.0  0.0   8160  3712 pts/2    R+   11:32   0:00 ps aux
root@local-raspap:/# /bin/bash /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 3
Stopping network services...
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Changing RaspAP Daemon --interface to uap0
Starting network services...
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
RaspAP service start DONE
root@local-raspap:/# ps aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   2316  1152 ?        Ss   11:27   0:00 /bin/sh /run.sh
root           7  0.0  0.0   2252  1024 ?        S    11:27   0:00 tail -f /dev/null
root           8  0.0  0.0   4052  3200 pts/2    Ss   11:31   0:00 /bin/bash
root          29  0.0  0.0   8160  3712 pts/2    R+   11:41   0:00 ps aux
root@local-raspap:/# ```

It seems, so far. To be a problem with "systemd" not working or being available for raspap in the container... I don't get it.
The container should work. It is a tested one from RaspAP. And also I have set 

privileged: true

in config.yaml

Any ideas?

Without digging into your setup, that message tells that servicestart.sh is expecting that systemd is present and running, while it is not.
You probably just need to start the main application some other “manual” way.

Thank you. I tried this by replicate whatever is being done to start raspap. But it’s pretty complicated.
Why does systemd not work? Is there anyway to make systemd work inside a container inside HA?

If you hate complications, you’ll definitely hate trying to run systemd inside a container :wink:
Systemd is meant as a generic system (i.e. bare metal or VM) hypervisor of sorts.
A docker image is supposed to be the opposite of generic, super specific.

You can google docker systemd to have an idea, but it definitely is far easier to mimic what servicestart.sh does in your Dockerfile’s ENTRYPOINT and/or CMD.

P.S. I’m talking docker in general, here. There are some specifics to HA addons as well, IIRC. Not sure using ghcr.io/raspap/raspap-docker as the base image will ever work.
You might want to start from ghcr.io/hassio-addons/base then add raspap on top.

Thank you. I gave up on this.
It led me down rabbitholes too much and I’m not knowing enough to solve this in a reasonable amount of time.

The weird thing is that this is actually a docker image from RaspAP so I don’t get why they do it with Systemd dependencies in the docker image.

I also tried a generic raspberryPiOS docker image and installing RaspAP inside of it manually. But that didn’t work either. For other reasons.

I use a second raspberry PI now, but it is a pitty. For mobile use of HA, having it double as a travel hotspot would have been really nice.

Well, I’m pretty sure they don’t use that specific script in their own docker image.

Yes, I guess you are right. I came to think they did by my own, clumsy, research. Found a file called raspap.service which in turn uses the servicestart.sh file which relies on systemd. So I tried use it too…
I asked in the github of the docker image. Somehow I just can’t completely let go of this yet…

It seems it systemd is indeed needed.

But, at the end of the day, RaspAP is just launching a daemon / long-running process, right?
You cannot identify what it is?