mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-03 14:24:06 +02:00
Compare commits
10 Commits
3013387c7e
...
7a5463f9bc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a5463f9bc | ||
|
|
accc11db99 | ||
|
|
b87beb9a08 | ||
|
|
8ea0ad30ea | ||
|
|
e641b7fc80 | ||
|
|
9f0d8f3341 | ||
|
|
43007282a4 | ||
|
|
50a7f44ff3 | ||
|
|
7cfe9a8770 | ||
|
|
1b16b4b697 |
@@ -58,26 +58,30 @@ if ! command -v bashio::addon.version >/dev/null 2>&1; then
|
||||
/usr/local/lib/bashio/bashio.sh
|
||||
do
|
||||
if [ -f "$f" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$f"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Try regular bashio, fallback to standalone if unavailable or fails
|
||||
set +e
|
||||
_bv="$(bashio::addon.version 2>/dev/null)"
|
||||
_rc=$?
|
||||
set -e
|
||||
|
||||
if [ "$_rc" -ne 0 ] || [ -z "$_bv" ] || [ "$_bv" = "null" ]; then
|
||||
if [ -f /usr/local/lib/bashio-standalone.sh ]; then
|
||||
. /usr/local/lib/bashio-standalone.sh
|
||||
_bv="$(bashio::addon.version)"
|
||||
fi
|
||||
for _sf in /usr/local/lib/bashio-standalone.sh /.bashio-standalone.sh; do
|
||||
if [ -f "$_sf" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$_sf"
|
||||
_bv="$(bashio::addon.version 2>/dev/null || true)"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$_bv"
|
||||
echo "${_bv:-PROBE_OK}"
|
||||
'
|
||||
|
||||
validate_shebang() {
|
||||
@@ -143,8 +147,6 @@ if [ -z "$shebang" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sed -i "1s|^.*|#!$shebang|" "$0"
|
||||
|
||||
if ! command -v bashio::addon.version >/dev/null 2>&1; then
|
||||
for f in /usr/lib/bashio/bashio.sh /usr/lib/bashio/lib.sh /usr/src/bashio/bashio.sh /usr/local/lib/bashio/bashio.sh /usr/local/lib/bashio-standalone.sh; do
|
||||
if [ -f "$f" ]; then
|
||||
@@ -160,9 +162,9 @@ fi
|
||||
##################
|
||||
|
||||
# Exit if /config is not mounted or HA not used
|
||||
if [ ! -d /config ] || ! bashio::supervisor.ping 2> /dev/null; then
|
||||
echo "..."
|
||||
exit 0
|
||||
if [ ! -d /config ] || ! bashio::supervisor.ping 2>/dev/null; then
|
||||
echo "..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Define slug
|
||||
@@ -171,13 +173,11 @@ slug="${slug#*_}"
|
||||
|
||||
# Check type of config folder
|
||||
if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then
|
||||
# New config location
|
||||
CONFIGLOCATION="/config"
|
||||
CONFIGFILEBROWSER="/addon_configs/${HOSTNAME/-/_}/$slug.sh"
|
||||
CONFIGLOCATION="/config"
|
||||
CONFIGFILEBROWSER="/addon_configs/${HOSTNAME/-/_}/$slug.sh"
|
||||
else
|
||||
# Legacy config location
|
||||
CONFIGLOCATION="/config/addons_autoscripts"
|
||||
CONFIGFILEBROWSER="/homeassistant/addons_autoscripts/$slug.sh"
|
||||
CONFIGLOCATION="/config/addons_autoscripts"
|
||||
CONFIGFILEBROWSER="/homeassistant/addons_autoscripts/$slug.sh"
|
||||
fi
|
||||
|
||||
# Default location
|
||||
@@ -189,26 +189,28 @@ bashio::log.green "Execute $CONFIGFILEBROWSER if existing"
|
||||
|
||||
# Download template if no script found and exit
|
||||
if [ ! -f "$CONFIGSOURCE" ]; then
|
||||
TEMPLATESOURCE="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/script.template"
|
||||
curl -f -L -s -S "$TEMPLATESOURCE" --output "$CONFIGSOURCE" || true
|
||||
exit 0
|
||||
TEMPLATESOURCE="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/script.template"
|
||||
curl -f -L -s -S "$TEMPLATESOURCE" --output "$CONFIGSOURCE" || true
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Convert scripts to linux
|
||||
dos2unix "$CONFIGSOURCE" &> /dev/null || true
|
||||
dos2unix "$CONFIGSOURCE" >/dev/null 2>&1 || true
|
||||
chmod +x "$CONFIGSOURCE"
|
||||
|
||||
sed -i "1s|^.*|#!$shebang|" "$CONFIGSOURCE"
|
||||
if grep -q 'bashio' "$CONFIGSOURCE"; then
|
||||
sed -i "1s|^.*|#!$shebang|" "$CONFIGSOURCE"
|
||||
else
|
||||
sed -i '1s|^.*|#!/bin/bash|' "$CONFIGSOURCE"
|
||||
fi
|
||||
|
||||
# Check if there is actual commands
|
||||
while IFS= read -r line; do
|
||||
# Remove leading and trailing whitespaces
|
||||
line="$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
line="$(echo "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
|
||||
# Check if line is not empty and does not start with #
|
||||
if [[ -n "$line" ]] && [[ ! "$line" =~ ^# ]]; then
|
||||
bashio::log.green "... script found, executing"
|
||||
/."$CONFIGSOURCE"
|
||||
break
|
||||
fi
|
||||
if [[ -n "$line" ]] && [[ ! "$line" =~ ^# ]]; then
|
||||
bashio::log.green "... script found, executing"
|
||||
"$CONFIGSOURCE"
|
||||
break
|
||||
fi
|
||||
done < "$CONFIGSOURCE"
|
||||
|
||||
@@ -90,14 +90,17 @@ _rc=$?
|
||||
set -e
|
||||
|
||||
if [ "$_rc" -ne 0 ] || [ -z "$_bv" ] || [ "$_bv" = "null" ]; then
|
||||
if [ -f /usr/local/lib/bashio-standalone.sh ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /usr/local/lib/bashio-standalone.sh
|
||||
_bv="$(bashio::addon.version)"
|
||||
fi
|
||||
for _sf in /usr/local/lib/bashio-standalone.sh /.bashio-standalone.sh; do
|
||||
if [ -f "$_sf" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
. "$_sf"
|
||||
_bv="$(bashio::addon.version 2>/dev/null || true)"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$_bv"
|
||||
echo "${_bv:-PROBE_OK}"
|
||||
'
|
||||
|
||||
validate_shebang() {
|
||||
@@ -165,6 +168,26 @@ if [ -z "$shebang" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
####################################
|
||||
# Bashio library for source fallback
|
||||
####################################
|
||||
|
||||
BASHIO_LIB=""
|
||||
for f in /usr/lib/bashio/bashio.sh /usr/lib/bashio/lib.sh /usr/src/bashio/bashio.sh /usr/local/lib/bashio/bashio.sh; do
|
||||
if [ -f "$f" ]; then
|
||||
BASHIO_LIB="$f"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$BASHIO_LIB" ]; then
|
||||
for f in /usr/local/lib/bashio-standalone.sh /.bashio-standalone.sh; do
|
||||
if [ -f "$f" ]; then
|
||||
BASHIO_LIB="$f"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
####################
|
||||
# Starting scripts #
|
||||
####################
|
||||
@@ -193,7 +216,23 @@ run_one_script() {
|
||||
# shellcheck disable=SC1090
|
||||
source "$script" || echo -e "\033[0;31mError\033[0m : $script exiting $?"
|
||||
else
|
||||
"$script" || echo -e "\033[0;31mError\033[0m : $script exiting $?"
|
||||
_run_rc=0
|
||||
"$script" || _run_rc=$?
|
||||
if [ "$_run_rc" -eq 126 ] && [ -n "${BASHIO_LIB:-}" ]; then
|
||||
echo "Direct exec failed (rc=126, likely E2BIG), retrying via source in subshell..."
|
||||
_run_rc=0
|
||||
(
|
||||
# shellcheck disable=SC1090
|
||||
. "$BASHIO_LIB" 2>/dev/null || true
|
||||
# shellcheck disable=SC1090
|
||||
. "$script"
|
||||
) || _run_rc=$?
|
||||
if [ "$_run_rc" -ne 0 ]; then
|
||||
echo -e "\033[0;31mError\033[0m : $script exiting $_run_rc"
|
||||
fi
|
||||
elif [ "$_run_rc" -ne 0 ]; then
|
||||
echo -e "\033[0;31mError\033[0m : $script exiting $_run_rc"
|
||||
fi
|
||||
fi
|
||||
|
||||
sed -i '1a exit 0' "$script"
|
||||
@@ -217,8 +256,19 @@ if $PID1; then
|
||||
restart_count=0
|
||||
max_restarts=5
|
||||
while true; do
|
||||
"$runfile"
|
||||
rc=$?
|
||||
_svc_rc=0
|
||||
"$runfile" || _svc_rc=$?
|
||||
if [ "$_svc_rc" -eq 126 ] && [ -n "${BASHIO_LIB:-}" ]; then
|
||||
echo "Direct exec of $runfile failed (rc=126, likely E2BIG), retrying via source..."
|
||||
_svc_rc=0
|
||||
(
|
||||
# shellcheck disable=SC1090
|
||||
. "$BASHIO_LIB" 2>/dev/null || true
|
||||
# shellcheck disable=SC1090
|
||||
. "$runfile"
|
||||
) || _svc_rc=$?
|
||||
fi
|
||||
rc=$_svc_rc
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "$runfile exited cleanly (exit 0), not restarting."
|
||||
break
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
## 26.3.7-3 (07-03-2026)
|
||||
- Minor bugs fixed
|
||||
## 26.3.7-2 (07-03-2026)
|
||||
- Minor bugs fixed
|
||||
|
||||
## 26.3.7 (2026-03-07)
|
||||
- Update to latest version from jokob-sk/NetAlertX (changelog : https://github.com/jokob-sk/NetAlertX/releases)
|
||||
|
||||
@@ -50,4 +50,4 @@ slug: netalertx
|
||||
tmpfs: true
|
||||
udev: true
|
||||
url: https://github.com/alexbelgium/hassio-addons
|
||||
version: "26.3.7"
|
||||
version: "26.3.7-3"
|
||||
|
||||
Reference in New Issue
Block a user