mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-05 07:14:08 +02:00
Allow starting without HA
This commit is contained in:
@@ -4,7 +4,14 @@ set -e
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Displays a simple add-on banner on startup
|
# Displays a simple add-on banner on startup
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
if bashio::supervisor.ping 2>/dev/null; then
|
if ! bashio::supervisor.ping 2>/dev/null; then
|
||||||
|
bashio::log.blue \
|
||||||
|
'-----------------------------------------------------------'
|
||||||
|
bashio::log.blue " Starting addon without HA support"
|
||||||
|
bashio::log.blue \
|
||||||
|
'-----------------------------------------------------------'
|
||||||
|
fi
|
||||||
|
|
||||||
bashio::log.blue \
|
bashio::log.blue \
|
||||||
'-----------------------------------------------------------'
|
'-----------------------------------------------------------'
|
||||||
bashio::log.blue " Add-on: $(bashio::addon.name)"
|
bashio::log.blue " Add-on: $(bashio::addon.name)"
|
||||||
@@ -22,8 +29,8 @@ if bashio::supervisor.ping 2>/dev/null; then
|
|||||||
bashio::log.green ' You are running the latest version of this add-on.'
|
bashio::log.green ' You are running the latest version of this add-on.'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bashio::log.blue " System: $(bashio::info.operating_system)" \
|
bashio::log.blue " System: $(bashio::info.operating_system)"
|
||||||
" ($(bashio::info.arch) / $(bashio::info.machine))"
|
bashio::log.blue " Architecture: $(bashio::info.arch) / $(bashio::info.machine)"
|
||||||
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
|
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
|
||||||
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
|
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
|
||||||
|
|
||||||
@@ -44,25 +51,23 @@ if bashio::supervisor.ping 2>/dev/null; then
|
|||||||
# Global actions for all addons
|
# Global actions for all addons
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
if bashio::config.has_value "PUID" && bashio::config.has_value "PGID"; then
|
if bashio::config.has_value "PUID" && bashio::config.has_value "PGID"; then
|
||||||
bashio::log.green \
|
bashio::log.green ' Defining permissions for main user : '
|
||||||
' Defining permissions for main user : '
|
|
||||||
PUID="$(bashio::config "PUID")"
|
PUID="$(bashio::config "PUID")"
|
||||||
PGID="$(bashio::config "PGID")"
|
PGID="$(bashio::config "PGID")"
|
||||||
bashio::log.blue "User UID: $PUID"
|
bashio::log.blue "User UID: $PUID"
|
||||||
bashio::log.blue "User GID: $PGID"
|
bashio::log.blue "User GID: $PGID"
|
||||||
id -u abc &>/dev/null || usermod -o -u "$PUID" abc &>/dev/null || true
|
|
||||||
id -g abc &>/dev/null || groupmod -o -g "$PGID" abc &>/dev/null || true
|
# Only modify user/group if they exist
|
||||||
|
if id abc &>/dev/null; then
|
||||||
|
usermod -o -u "$PUID" abc &>/dev/null
|
||||||
|
fi
|
||||||
|
if getent group abc &>/dev/null; then
|
||||||
|
groupmod -o -g "$PGID" abc &>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
bashio::log.blue \
|
bashio::log.blue \
|
||||||
'-----------------------------------------------------------'
|
'-----------------------------------------------------------'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clean bashrc file
|
# Clean bashrc file safely
|
||||||
if [ -f ~/.bashrc ]; then rm ~/.bashrc; fi
|
if [ -f ~/.bashrc ]; then > ~/.bashrc; fi
|
||||||
|
|
||||||
else
|
|
||||||
bashio::log.blue \
|
|
||||||
'-----------------------------------------------------------'
|
|
||||||
bashio::log.blue " Starting addon without HA support"
|
|
||||||
bashio::log.blue \
|
|
||||||
'-----------------------------------------------------------'
|
|
||||||
fi
|
|
||||||
|
|||||||
Reference in New Issue
Block a user