mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 05:04:21 +01:00
Add support for new audo layer (#1153)
* Add support for new audo layer * Add layer * restucture * better struct * Improve devcontainer * Fix container * Fix LN * disable lint * ignore
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM ubuntu:18.04
|
FROM debian
|
||||||
|
|
||||||
WORKDIR /workspaces
|
WORKDIR /workspaces
|
||||||
|
|
||||||
@@ -15,19 +15,30 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
apt-transport-https \
|
apt-transport-https \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
dbus \
|
|
||||||
software-properties-common \
|
software-properties-common \
|
||||||
gpg-agent \
|
gnupg \
|
||||||
git \
|
&& curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
|
||||||
jq \
|
&& add-apt-repository "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
|
||||||
sudo \
|
|
||||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \
|
|
||||||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
|
||||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||||
docker-ce \
|
docker-ce \
|
||||||
docker-ce-cli \
|
docker-ce-cli \
|
||||||
containerd.io
|
containerd.io \
|
||||||
# This is a development container. Don't bother to clean up apt cache, this way we have it handy later
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install tools
|
||||||
|
ARG SHELLCHECK_VERSION=0.7.0
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
jq \
|
||||||
|
dbus \
|
||||||
|
network-manager \
|
||||||
|
libpulse0 \
|
||||||
|
git \
|
||||||
|
tar \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
\
|
||||||
|
&& curl -SL "https://storage.googleapis.com/shellcheck/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar xzf - \
|
||||||
|
&& cp "shellcheck-v${SHELLCHECK_VERSION}/shellcheck" /usr/bin/ \
|
||||||
|
&& rm -rf shellcheck-v${SHELLCHECK_VERSION}
|
||||||
|
|
||||||
# Generate a machine-id for this container
|
# Generate a machine-id for this container
|
||||||
RUN rm /etc/machine-id && dbus-uuidgen --ensure=/etc/machine-id
|
RUN rm /etc/machine-id && dbus-uuidgen --ensure=/etc/machine-id
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Based on https://github.com/issacg/hassio-addon-devcontainer
|
// Based on https://github.com/issacg/hassio-addon-devcontainer
|
||||||
{
|
{
|
||||||
"name": "Hass.io Community Add-Ons",
|
"name": "Home Assistant Add-Ons",
|
||||||
"context": "..",
|
"context": "..",
|
||||||
"dockerFile": "Dockerfile",
|
"dockerFile": "Dockerfile",
|
||||||
"appPort": "7123:8123",
|
"appPort": "7123:8123",
|
||||||
@@ -9,6 +9,10 @@
|
|||||||
"GIT_EDITOR=code --wait",
|
"GIT_EDITOR=code --wait",
|
||||||
"--privileged"
|
"--privileged"
|
||||||
],
|
],
|
||||||
|
"extensions": [
|
||||||
|
"timonwong.shellcheck",
|
||||||
|
"esbenp.prettier-vscode"
|
||||||
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
"terminal.integrated.shell.linux": "/bin/bash"
|
"terminal.integrated.shell.linux": "/bin/bash"
|
||||||
},
|
},
|
||||||
|
|||||||
1
.shellcheckrc
Normal file
1
.shellcheckrc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
disable=SC1008
|
||||||
6
.vscode/tasks.json
vendored
6
.vscode/tasks.json
vendored
@@ -4,7 +4,7 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "Start Hass.io",
|
"label": "Start Home Assistant",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_hassio.sh",
|
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_hassio.sh",
|
||||||
"group": {
|
"group": {
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},{
|
},{
|
||||||
"label": "Cleanup stale Hass.io environment",
|
"label": "Cleanup stale Home Assistant environment",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_hassio.sh --cleanup",
|
"command": "/workspaces/test_hassio/addons/local/.devcontainer/start_hassio.sh --cleanup",
|
||||||
"group": "test",
|
"group": "test",
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
},
|
},
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},{
|
},{
|
||||||
"label": "Run Hass.io CLI",
|
"label": "Run Home Assistant CLI",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "docker run --rm -ti -v /etc/machine-id:/etc/machine-id --network=hassio --add-host hassio:172.30.32.2 homeassistant/amd64-hassio-cli:dev",
|
"command": "docker run --rm -ti -v /etc/machine-id:/etc/machine-id --network=hassio --add-host hassio:172.30.32.2 homeassistant/amd64-hassio-cli:dev",
|
||||||
"group": "test",
|
"group": "test",
|
||||||
|
|||||||
@@ -1,45 +1,51 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 1.0
|
## 1.1.0
|
||||||
|
|
||||||
|
- Renaming Home Assistant
|
||||||
|
- Convert to s6-overlay
|
||||||
|
- Support new audio backend
|
||||||
|
|
||||||
|
## 1.0.0
|
||||||
|
|
||||||
- Support aarch64 in armv7 combat mode
|
- Support aarch64 in armv7 combat mode
|
||||||
|
|
||||||
## 0.9
|
## 0.9.0
|
||||||
|
|
||||||
- Corrected link to documentation inside the add-on
|
- Corrected link to documentation inside the add-on
|
||||||
- Adjust source links in Dockerfile
|
- Adjust source links in Dockerfile
|
||||||
- Update add-on documentation to match current state
|
- Update add-on documentation to match current state
|
||||||
|
|
||||||
## 0.8
|
## 0.8.0
|
||||||
|
|
||||||
- Fix API url for access to Home Assistant
|
- Fix API url for access to Home Assistant
|
||||||
|
|
||||||
## 0.7
|
## 0.7.0
|
||||||
|
|
||||||
- Add missing options
|
- Add missing options
|
||||||
|
|
||||||
## 0.6
|
## 0.6.0
|
||||||
|
|
||||||
- Update Ada to 0.7
|
- Update Ada to 0.7
|
||||||
- Add options to change TTS / STT Home Assistant provider
|
- Add options to change TTS / STT Home Assistant provider
|
||||||
|
|
||||||
## 0.5
|
## 0.5.0
|
||||||
|
|
||||||
- Update Ada to 0.6
|
- Update Ada to 0.6
|
||||||
|
|
||||||
## 0.4
|
## 0.4.0
|
||||||
|
|
||||||
- Update Ada to 0.5
|
- Update Ada to 0.5
|
||||||
|
|
||||||
## 0.3
|
## 0.3.0
|
||||||
|
|
||||||
- Update Ada to 0.4
|
- Update Ada to 0.4
|
||||||
|
|
||||||
## 0.2
|
## 0.2.0
|
||||||
|
|
||||||
- Update Ada to 0.3
|
- Update Ada to 0.3
|
||||||
- Add armhf support
|
- Add armhf support
|
||||||
|
|
||||||
## 0.1
|
## 0.1.0
|
||||||
|
|
||||||
- Initial support
|
- Initial support
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ ARG ADA_VERSION
|
|||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
portaudio19-dev \
|
portaudio19-dev \
|
||||||
|
libasound2-plugins \
|
||||||
libsndfile1 \
|
libsndfile1 \
|
||||||
mplayer \
|
mplayer \
|
||||||
libffi-dev \
|
libffi-dev \
|
||||||
@@ -32,6 +33,4 @@ RUN apt-get update \
|
|||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY data/run.sh /
|
COPY rootfs /
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "Hey Ada!",
|
"name": "Hey Ada!",
|
||||||
"version": "1.0",
|
"version": "1.1.0",
|
||||||
"slug": "ada",
|
"slug": "ada",
|
||||||
"description": "Voice assistant powered by Home Assistant",
|
"description": "Voice assistant powered by Home Assistant",
|
||||||
"url": "https://github.com/home-assistant/hassio-addons/blob/master/ada",
|
"url": "https://github.com/home-assistant/hassio-addons/blob/master/ada",
|
||||||
"arch": ["armhf", "armv7", "amd64"],
|
"arch": ["armhf", "armv7", "amd64"],
|
||||||
|
"init": false,
|
||||||
"startup": "application",
|
"startup": "application",
|
||||||
"boot": "auto",
|
"boot": "auto",
|
||||||
"audio": true,
|
"audio": true,
|
||||||
"homeassistant": "0.102.0.dev",
|
"homeassistant": "0.102.0",
|
||||||
"homeassistant_api": true,
|
"homeassistant_api": true,
|
||||||
"options": {
|
"options": {
|
||||||
"stt": "cloud",
|
"stt": "cloud",
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env bashio
|
|
||||||
|
|
||||||
STT=$(bashio::config 'stt')
|
|
||||||
TTS=$(bashio::config 'tts')
|
|
||||||
|
|
||||||
exec python3 -m ada --url "http://hassio/homeassistant/api" --key "$HASSIO_TOKEN" --stt "$STT" --tts "$TTS"
|
|
||||||
8
ada/rootfs/etc/services.d/ada/finish
Normal file
8
ada/rootfs/etc/services.d/ada/finish
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/execlineb -S0
|
||||||
|
# ==============================================================================
|
||||||
|
# Take down the S6 supervision tree when Ada fails
|
||||||
|
# ==============================================================================
|
||||||
|
if { s6-test ${1} -ne 0 }
|
||||||
|
if { s6-test ${1} -ne 256 }
|
||||||
|
|
||||||
|
s6-svscanctl -t /var/run/s6/services
|
||||||
8
ada/rootfs/etc/services.d/ada/run
Normal file
8
ada/rootfs/etc/services.d/ada/run
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# Start Ada service
|
||||||
|
# ==============================================================================
|
||||||
|
STT=$(bashio::config 'stt')
|
||||||
|
TTS=$(bashio::config 'tts')
|
||||||
|
|
||||||
|
exec python3 -m ada --url "http://supervisor/core/api" --key "$SUPERVISOR_TOKEN" --stt "$STT" --tts "$TTS"
|
||||||
@@ -39,7 +39,8 @@ jobs:
|
|||||||
- script: |
|
- script: |
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
sudo docker run --rm -i \
|
sudo docker run --rm -i \
|
||||||
-v $(pwd):/mnt:ro koalaman/shellcheck:$(versionShellCheck) **/*.sh
|
-v $(pwd):/mnt:ro -e SHELLCHECK_OPTS="-e SC1008" \
|
||||||
|
koalaman/shellcheck:$(versionShellCheck) **/*.sh
|
||||||
displayName: "Run ShellCheck"
|
displayName: "Run ShellCheck"
|
||||||
|
|
||||||
- job: "JQ"
|
- job: "JQ"
|
||||||
|
|||||||
@@ -1,31 +1,36 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 8.4
|
## 8.5.0
|
||||||
|
|
||||||
|
- Add support for PulseAudio with new Audio backend
|
||||||
|
- Migrate to s6-overlay
|
||||||
|
|
||||||
|
## 8.4.0
|
||||||
|
|
||||||
- Support to use only web terminal without SSH server
|
- Support to use only web terminal without SSH server
|
||||||
|
|
||||||
**ATTENTION:** If you want access with SSH, you need maybe add the Port setting option back.
|
**ATTENTION:** If you want access with SSH, you need maybe add the Port setting option back.
|
||||||
|
|
||||||
## 8.3
|
## 8.3.0
|
||||||
|
|
||||||
- Update Home Assistant CLI to 4.0.1
|
- Update Home Assistant CLI to 4.0.1
|
||||||
- Add backward compatibility with the hassio command
|
- Add backward compatibility with the hassio command
|
||||||
- Update Web terminal to ttyd 1.6.0 with Libwebsockets 3.2.2
|
- Update Web terminal to ttyd 1.6.0 with Libwebsockets 3.2.2
|
||||||
- Rename HASSIO_TOKEN to SUPERVISOR_TOKEN in shell profile
|
- Rename HASSIO_TOKEN to SUPERVISOR_TOKEN in shell profile
|
||||||
|
|
||||||
## 8.2
|
## 8.2.0
|
||||||
|
|
||||||
- Fix creation of new tmux terminal windows
|
- Fix creation of new tmux terminal windows
|
||||||
- Add add-on icon
|
- Add add-on icon
|
||||||
- Update welcome logo
|
- Update welcome logo
|
||||||
- Fix SSH folder issue with authorized keys
|
- Fix SSH folder issue with authorized keys
|
||||||
|
|
||||||
## 8.1
|
## 8.1.0
|
||||||
|
|
||||||
- Fix for non existing .bash_profile startup error
|
- Fix for non existing .bash_profile startup error
|
||||||
- Add current, short, path to command line prompt
|
- Add current, short, path to command line prompt
|
||||||
|
|
||||||
## 8.0
|
## 8.0.0
|
||||||
|
|
||||||
- Add support for a web-based terminal via Ingress
|
- Add support for a web-based terminal via Ingress
|
||||||
- Upgrade Alpine Linux to 3.11
|
- Upgrade Alpine Linux to 3.11
|
||||||
@@ -33,100 +38,100 @@
|
|||||||
- Persist .ssh folder across restarts
|
- Persist .ssh folder across restarts
|
||||||
- Add helper symlink folders to user home folder
|
- Add helper symlink folders to user home folder
|
||||||
|
|
||||||
## 7.1
|
## 7.1.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 3.1.1
|
- Update Hass.io CLI to 3.1.1
|
||||||
|
|
||||||
## 7.0
|
## 7.0.0
|
||||||
|
|
||||||
- Added bash_profile as a persistent file
|
- Added bash_profile as a persistent file
|
||||||
|
|
||||||
## 6.4
|
## 6.4.0
|
||||||
|
|
||||||
- Changed logging from DEBUG -> INFO
|
- Changed logging from DEBUG -> INFO
|
||||||
|
|
||||||
## 6.3
|
## 6.3.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 3.1.0
|
- Update Hass.io CLI to 3.1.0
|
||||||
|
|
||||||
## 6.2
|
## 6.2.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 3.0.0
|
- Update Hass.io CLI to 3.0.0
|
||||||
|
|
||||||
## 6.1
|
## 6.1.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 2.3.0
|
- Update Hass.io CLI to 2.3.0
|
||||||
|
|
||||||
## 6.0
|
## 6.0.0
|
||||||
|
|
||||||
- Update and pin base image to Alpine 3.10
|
- Update and pin base image to Alpine 3.10
|
||||||
|
|
||||||
## 5.6
|
## 5.6.0
|
||||||
|
|
||||||
- Fixes crash when using authorized keys
|
- Fixes crash when using authorized keys
|
||||||
|
|
||||||
## 5.5
|
## 5.5.0
|
||||||
|
|
||||||
- Rewrite add-on onto Bashio
|
- Rewrite add-on onto Bashio
|
||||||
- Added documentation to add-on repository
|
- Added documentation to add-on repository
|
||||||
- Code styling improvements
|
- Code styling improvements
|
||||||
|
|
||||||
## 5.4
|
## 5.4.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 2.2.0
|
- Update Hass.io CLI to 2.2.0
|
||||||
|
|
||||||
## 5.3
|
## 5.3.0
|
||||||
|
|
||||||
- Fix: User root not allowed because account is locked
|
- Fix: User root not allowed because account is locked
|
||||||
|
|
||||||
## 5.2
|
## 5.2.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 2.1.0
|
- Update Hass.io CLI to 2.1.0
|
||||||
|
|
||||||
## 5.1
|
## 5.1.0
|
||||||
|
|
||||||
- Map all serial devices into container for manual adjustments
|
- Map all serial devices into container for manual adjustments
|
||||||
|
|
||||||
## 5.0
|
## 5.0.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 2.0.1, include bash completion
|
- Update Hass.io CLI to 2.0.1, include bash completion
|
||||||
|
|
||||||
## 4.0
|
## 4.0.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 1.4.0
|
- Update Hass.io CLI to 1.4.0
|
||||||
- Add new API role profile
|
- Add new API role profile
|
||||||
- Update OpenSSH to 7.7
|
- Update OpenSSH to 7.7
|
||||||
|
|
||||||
## 3.7
|
## 3.7.0
|
||||||
|
|
||||||
- Add YAML highlighting for nano
|
- Add YAML highlighting for nano
|
||||||
|
|
||||||
## 3.6
|
## 3.6.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 1.3.1
|
- Update Hass.io CLI to 1.3.1
|
||||||
|
|
||||||
## 3.5
|
## 3.5.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 1.3.0
|
- Update Hass.io CLI to 1.3.0
|
||||||
|
|
||||||
## 3.4
|
## 3.4.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 1.2.1
|
- Update Hass.io CLI to 1.2.1
|
||||||
|
|
||||||
## 3.3
|
## 3.3.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 1.1.2
|
- Update Hass.io CLI to 1.1.2
|
||||||
|
|
||||||
## 3.2
|
## 3.2.0
|
||||||
|
|
||||||
- Downgrade Hass.io CLI to 1.0.1
|
- Downgrade Hass.io CLI to 1.0.1
|
||||||
|
|
||||||
## 3.1
|
## 3.1.0
|
||||||
|
|
||||||
- Update Hass.io CLI to 1.1.1
|
- Update Hass.io CLI to 1.1.1
|
||||||
- Change internal token handling for Hass.io API
|
- Change internal token handling for Hass.io API
|
||||||
|
|
||||||
## 3.0
|
## 3.0.0
|
||||||
|
|
||||||
- Use new base images
|
- Use new base images
|
||||||
- Add hassio-cli version 1.0
|
- Add hassio-cli version 1.0
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ RUN \
|
|||||||
\
|
\
|
||||||
&& apk add --no-cache \
|
&& apk add --no-cache \
|
||||||
bash-completion \
|
bash-completion \
|
||||||
|
pulseaudio-utils \
|
||||||
|
alsa-plugins-pulse \
|
||||||
git \
|
git \
|
||||||
libuv \
|
libuv \
|
||||||
mosquitto-clients \
|
mosquitto-clients \
|
||||||
@@ -77,11 +79,4 @@ RUN curl -Lso /usr/bin/ha \
|
|||||||
&& /usr/bin/ha completion > /usr/share/bash-completion/completions/ha
|
&& /usr/bin/ha completion > /usr/share/bash-completion/completions/ha
|
||||||
|
|
||||||
# Copy data
|
# Copy data
|
||||||
COPY data/.tmux.conf /root/
|
COPY rootfs /
|
||||||
COPY data/hassio /usr/bin/
|
|
||||||
COPY data/homeassistant.sh /etc/profile.d/
|
|
||||||
COPY data/motd /etc/
|
|
||||||
COPY data/run.sh /
|
|
||||||
COPY data/sshd_config /etc/ssh/
|
|
||||||
|
|
||||||
CMD [ "/run.sh" ]
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "Terminal & SSH",
|
"name": "Terminal & SSH",
|
||||||
"version": "8.4",
|
"version": "8.5.0",
|
||||||
"slug": "ssh",
|
"slug": "ssh",
|
||||||
"description": "Allow logging in remotely to Home Assistant using SSH",
|
"description": "Allow logging in remotely to Home Assistant using SSH",
|
||||||
"url": "https://github.com/home-assistant/hassio-addons/tree/master/ssh",
|
"url": "https://github.com/home-assistant/hassio-addons/tree/master/ssh",
|
||||||
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
||||||
|
"init": false,
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
"startup": "services",
|
"startup": "services",
|
||||||
"ingress": true,
|
"ingress": true,
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
"boot": "auto",
|
"boot": "auto",
|
||||||
"hassio_api": true,
|
"hassio_api": true,
|
||||||
"hassio_role": "manager",
|
"hassio_role": "manager",
|
||||||
|
"audio": true,
|
||||||
"auto_uart": true,
|
"auto_uart": true,
|
||||||
"ports": {
|
"ports": {
|
||||||
"22/tcp": null
|
"22/tcp": null
|
||||||
|
|||||||
114
ssh/data/run.sh
114
ssh/data/run.sh
@@ -1,114 +0,0 @@
|
|||||||
#!/usr/bin/env bashio
|
|
||||||
set -e
|
|
||||||
|
|
||||||
KEYS_PATH=/data/host_keys
|
|
||||||
|
|
||||||
WAIT_PIDS=()
|
|
||||||
|
|
||||||
bashio::log.info "Initializing add-on for use..."
|
|
||||||
USE_SSHD=true
|
|
||||||
if bashio::config.has_value 'authorized_keys'; then
|
|
||||||
bashio::log.info "Setup authorized_keys"
|
|
||||||
|
|
||||||
mkdir -p /data/.ssh
|
|
||||||
chmod 700 /data/.ssh
|
|
||||||
rm -f /data/.ssh/authorized_keys
|
|
||||||
while read -r line; do
|
|
||||||
echo "$line" >> /data/.ssh/authorized_keys
|
|
||||||
done <<< "$(bashio::config 'authorized_keys')"
|
|
||||||
|
|
||||||
chmod 600 /data/.ssh/authorized_keys
|
|
||||||
sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ no/ /etc/ssh/sshd_config
|
|
||||||
|
|
||||||
# Unlock account
|
|
||||||
PASSWORD="$(pwgen -s 64 1)"
|
|
||||||
echo "root:${PASSWORD}" | chpasswd 2&> /dev/null
|
|
||||||
elif bashio::config.has_value 'password'; then
|
|
||||||
bashio::log.info "Setup password login"
|
|
||||||
|
|
||||||
PASSWORD=$(bashio::config 'password')
|
|
||||||
echo "root:${PASSWORD}" | chpasswd 2&> /dev/null
|
|
||||||
|
|
||||||
sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ yes/ /etc/ssh/sshd_config
|
|
||||||
sed -i s/#PermitEmptyPasswords.*/PermitEmptyPasswords\ no/ /etc/ssh/sshd_config
|
|
||||||
elif bashio::var.has_value "$(bashio::addon.port 22)"; then
|
|
||||||
bashio::exit.nok "You need to setup a login!"
|
|
||||||
else
|
|
||||||
USE_SSHD=false
|
|
||||||
bashio::log.info "Disable SSH remote access because of missing login credential!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate host keys
|
|
||||||
if ! bashio::fs.directory_exists "${KEYS_PATH}"; then
|
|
||||||
bashio::log.info "Generating host keys..."
|
|
||||||
|
|
||||||
mkdir -p "${KEYS_PATH}"
|
|
||||||
ssh-keygen -A || bashio::exit.nok "Failed to create host keys!"
|
|
||||||
cp -fp /etc/ssh/ssh_host* "${KEYS_PATH}/"
|
|
||||||
else
|
|
||||||
bashio::log.info "Restoring host keys..."
|
|
||||||
cp -fp "${KEYS_PATH}"/* /etc/ssh/
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Persist shell history by redirecting .bash_history to /data
|
|
||||||
touch /data/.bash_history
|
|
||||||
chmod 600 /data/.bash_history
|
|
||||||
ln -s -f /data/.bash_history /root/.bash_history
|
|
||||||
|
|
||||||
# Make Home Assistant TOKEN available on the CLI
|
|
||||||
echo "export SUPERVISOR_TOKEN=${SUPERVISOR_TOKEN}" >> /etc/profile.d/homeassistant.sh
|
|
||||||
|
|
||||||
# Remove old HASSIO_TOKEN from bash profile (if exists)
|
|
||||||
if bashio::fs.file_exists /data/.bash_profile; then
|
|
||||||
sed -i "/export HASSIO_TOKEN=.*/d" /data/.bash_profile
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Persist .bash_profile by redirecting .bash_profile to /data
|
|
||||||
touch /data/.bash_profile
|
|
||||||
chmod 600 /data/.bash_profile
|
|
||||||
ln -s -f /data/.bash_profile /root/.bash_profile
|
|
||||||
|
|
||||||
# Links some common directories to the user's home folder for convenience
|
|
||||||
DIRECTORIES=(addons backup config share ssl)
|
|
||||||
for dir in "${DIRECTORIES[@]}"; do
|
|
||||||
ln -s "/${dir}" "${HOME}/${dir}" \
|
|
||||||
|| bashio::log.warning "Failed linking common directory: ${dir}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Sets up the users .ssh folder to be persistent
|
|
||||||
if ! bashio::fs.directory_exists /data/.ssh; then
|
|
||||||
mkdir -p /data/.ssh \
|
|
||||||
|| bashio::exit.nok 'Failed to create a persistent .ssh folder'
|
|
||||||
|
|
||||||
chmod 700 /data/.ssh \
|
|
||||||
|| bashio::exit.nok \
|
|
||||||
'Failed setting permissions on persistent .ssh folder'
|
|
||||||
fi
|
|
||||||
ln -s /data/.ssh /root/.ssh
|
|
||||||
|
|
||||||
# Register stop
|
|
||||||
function stop_addon() {
|
|
||||||
bashio::log.debug "Kill Processes..."
|
|
||||||
kill -15 "${WAIT_PIDS[@]}"
|
|
||||||
|
|
||||||
wait "${WAIT_PIDS[@]}"
|
|
||||||
bashio::log.debug "Done."
|
|
||||||
}
|
|
||||||
trap "stop_addon" SIGTERM SIGHUP
|
|
||||||
|
|
||||||
# Start SSH server
|
|
||||||
if bashio::var.true "${USE_SSHD}"; then
|
|
||||||
bashio::log.info "Starting SSH daemon..."
|
|
||||||
/usr/sbin/sshd -D -e < /dev/null &
|
|
||||||
WAIT_PIDS+=($!)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start ttyd server
|
|
||||||
bashio::log.info "Starting Web Terminal..."
|
|
||||||
cd /root
|
|
||||||
ttyd -p 8099 tmux -u new -A -s homeassistant bash -l &
|
|
||||||
WAIT_PIDS+=($!)
|
|
||||||
|
|
||||||
# Wait until all is done
|
|
||||||
bashio::log.info "SSH add-on is set up and running!"
|
|
||||||
wait "${WAIT_PIDS[@]}"
|
|
||||||
16
ssh/rootfs/etc/cont-init.d/keygen.sh
Normal file
16
ssh/rootfs/etc/cont-init.d/keygen.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# SSH Host keys
|
||||||
|
# ==============================================================================
|
||||||
|
KEYS_PATH=/data/host_keys
|
||||||
|
|
||||||
|
if ! bashio::fs.directory_exists "${KEYS_PATH}"; then
|
||||||
|
bashio::log.info "Generating host keys..."
|
||||||
|
|
||||||
|
mkdir -p "${KEYS_PATH}"
|
||||||
|
ssh-keygen -A || bashio::exit.nok "Failed to create host keys!"
|
||||||
|
cp -fp /etc/ssh/ssh_host* "${KEYS_PATH}/"
|
||||||
|
else
|
||||||
|
bashio::log.info "Restoring host keys..."
|
||||||
|
cp -fp "${KEYS_PATH}"/* /etc/ssh/
|
||||||
|
fi
|
||||||
40
ssh/rootfs/etc/cont-init.d/profile.sh
Normal file
40
ssh/rootfs/etc/cont-init.d/profile.sh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# Setup persistent user settings
|
||||||
|
# ==============================================================================
|
||||||
|
DIRECTORIES=(addons backup config share ssl)
|
||||||
|
|
||||||
|
# Persist shell history by redirecting .bash_history to /data
|
||||||
|
touch /data/.bash_history
|
||||||
|
chmod 600 /data/.bash_history
|
||||||
|
ln -s -f /data/.bash_history /root/.bash_history
|
||||||
|
|
||||||
|
# Make Home Assistant TOKEN available on the CLI
|
||||||
|
echo "export SUPERVISOR_TOKEN=${SUPERVISOR_TOKEN}" >> /etc/profile.d/homeassistant.sh
|
||||||
|
|
||||||
|
# Remove old HASSIO_TOKEN from bash profile (if exists)
|
||||||
|
if bashio::fs.file_exists /data/.bash_profile; then
|
||||||
|
sed -i "/export HASSIO_TOKEN=.*/d" /data/.bash_profile
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Persist .bash_profile by redirecting .bash_profile to /data
|
||||||
|
touch /data/.bash_profile
|
||||||
|
chmod 600 /data/.bash_profile
|
||||||
|
ln -s -f /data/.bash_profile /root/.bash_profile
|
||||||
|
|
||||||
|
# Links some common directories to the user's home folder for convenience
|
||||||
|
for dir in "${DIRECTORIES[@]}"; do
|
||||||
|
ln -s "/${dir}" "${HOME}/${dir}" \
|
||||||
|
|| bashio::log.warning "Failed linking common directory: ${dir}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Sets up the users .ssh folder to be persistent
|
||||||
|
if ! bashio::fs.directory_exists /data/.ssh; then
|
||||||
|
mkdir -p /data/.ssh \
|
||||||
|
|| bashio::exit.nok 'Failed to create a persistent .ssh folder'
|
||||||
|
|
||||||
|
chmod 700 /data/.ssh \
|
||||||
|
|| bashio::exit.nok \
|
||||||
|
'Failed setting permissions on persistent .ssh folder'
|
||||||
|
fi
|
||||||
|
ln -s /data/.ssh /root/.ssh
|
||||||
31
ssh/rootfs/etc/cont-init.d/ssh.sh
Normal file
31
ssh/rootfs/etc/cont-init.d/ssh.sh
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# SSH setup & user
|
||||||
|
# ==============================================================================
|
||||||
|
if bashio::config.has_value 'authorized_keys'; then
|
||||||
|
bashio::log.info "Setup authorized_keys"
|
||||||
|
|
||||||
|
mkdir -p /data/.ssh
|
||||||
|
chmod 700 /data/.ssh
|
||||||
|
rm -f /data/.ssh/authorized_keys
|
||||||
|
while read -r line; do
|
||||||
|
echo "$line" >> /data/.ssh/authorized_keys
|
||||||
|
done <<< "$(bashio::config 'authorized_keys')"
|
||||||
|
|
||||||
|
chmod 600 /data/.ssh/authorized_keys
|
||||||
|
sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ no/ /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
# Unlock account
|
||||||
|
PASSWORD="$(pwgen -s 64 1)"
|
||||||
|
echo "root:${PASSWORD}" | chpasswd 2&> /dev/null
|
||||||
|
elif bashio::config.has_value 'password'; then
|
||||||
|
bashio::log.info "Setup password login"
|
||||||
|
|
||||||
|
PASSWORD=$(bashio::config 'password')
|
||||||
|
echo "root:${PASSWORD}" | chpasswd 2&> /dev/null
|
||||||
|
|
||||||
|
sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ yes/ /etc/ssh/sshd_config
|
||||||
|
sed -i s/#PermitEmptyPasswords.*/PermitEmptyPasswords\ no/ /etc/ssh/sshd_config
|
||||||
|
elif bashio::var.has_value "$(bashio::addon.port 22)"; then
|
||||||
|
bashio::exit.nok "You need to setup a login!"
|
||||||
|
fi
|
||||||
2
ssh/rootfs/etc/fix-attrs.d/cli
Normal file
2
ssh/rootfs/etc/fix-attrs.d/cli
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/usr/bin/hassio false root 0755 0755
|
||||||
|
/usr/bin/ha false root 0755 0755
|
||||||
2
ssh/rootfs/etc/fix-attrs.d/profile
Normal file
2
ssh/rootfs/etc/fix-attrs.d/profile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/data/.bash_history false root 0600 0755
|
||||||
|
/data/.bash_profile false root 0600 0755
|
||||||
3
ssh/rootfs/etc/fix-attrs.d/ssh
Normal file
3
ssh/rootfs/etc/fix-attrs.d/ssh
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/data/.ssh false root 0644 0700
|
||||||
|
/data/.ssh/authorized_keys false root 0600 0755
|
||||||
|
/etc/ssh false root 0644 0755
|
||||||
8
ssh/rootfs/etc/services.d/sshd/finish
Normal file
8
ssh/rootfs/etc/services.d/sshd/finish
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/execlineb -S0
|
||||||
|
# ==============================================================================
|
||||||
|
# Take down the S6 supervision tree when sshd fails
|
||||||
|
# ==============================================================================
|
||||||
|
if { s6-test ${1} -ne 0 }
|
||||||
|
if { s6-test ${1} -ne 256 }
|
||||||
|
|
||||||
|
s6-svscanctl -t /var/run/s6/services
|
||||||
12
ssh/rootfs/etc/services.d/sshd/run
Normal file
12
ssh/rootfs/etc/services.d/sshd/run
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# Start sshd service if enabled
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# If SSH is disabled, use a fake sleep process
|
||||||
|
if ! bashio::var.has_value "$(bashio::addon.port 22)"; then
|
||||||
|
exec sleep 864000
|
||||||
|
fi
|
||||||
|
|
||||||
|
bashio::log.info "Starting the SSH daemon..."
|
||||||
|
exec /usr/sbin/sshd -D -e
|
||||||
8
ssh/rootfs/etc/services.d/ttyd/finish
Normal file
8
ssh/rootfs/etc/services.d/ttyd/finish
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/execlineb -S0
|
||||||
|
# ==============================================================================
|
||||||
|
# Take down the S6 supervision tree when ttyd fails
|
||||||
|
# ==============================================================================
|
||||||
|
if { s6-test ${1} -ne 0 }
|
||||||
|
if { s6-test ${1} -ne 256 }
|
||||||
|
|
||||||
|
s6-svscanctl -t /var/run/s6/services
|
||||||
8
ssh/rootfs/etc/services.d/ttyd/run
Normal file
8
ssh/rootfs/etc/services.d/ttyd/run
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# Start ttyd service for ingress
|
||||||
|
# ==============================================================================
|
||||||
|
bashio::log.info "Starting Web Terminal..."
|
||||||
|
cd /root
|
||||||
|
|
||||||
|
exec ttyd -p 8099 tmux -u new -A -s homeassistant bash -l
|
||||||
0
ssh/data/hassio → ssh/rootfs/usr/bin/hassio
Executable file → Normal file
0
ssh/data/hassio → ssh/rootfs/usr/bin/hassio
Executable file → Normal file
Reference in New Issue
Block a user