update repository references and improve script handling
This commit is contained in:
@@ -4,25 +4,25 @@
|
||||
|
||||
[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
|
||||
[![Donate][paypal-badge]](https://www.paypal.com/donate/?hosted_button_id=DZFULJZTP3UQA)
|
||||

|
||||

|
||||
|
||||
[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee%20(no%20paypal)-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white
|
||||
[paypal-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee%20with%20Paypal-0070BA?logo=paypal&style=flat&logoColor=white
|
||||
|
||||
[](https://www.codacy.com/gh/Mesteriis/hassio-addons-avm/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Mesteriis/hassio-addons-avm&utm_campaign=Badge_Grade)
|
||||
[](https://github.com/Mesteriis/hassio-addons-avm/actions/workflows/weekly-supelinter.yaml)
|
||||
[](https://github.com/Mesteriis/hassio-addons-avm/actions/workflows/onpush_builder.yaml)
|
||||
[](https://github.com/Mesteriis/hassio-addons-avm/actions/workflows/weekly_stats.yaml)
|
||||
[](https://www.codacy.com/gh/alexbelgium/hassio-addons/dashboard?utm_source=github.com&utm_medium=referral&utm_content=alexbelgium/hassio-addons&utm_campaign=Badge_Grade)
|
||||
[](https://github.com/alexbelgium/hassio-addons/actions/workflows/weekly-supelinter.yaml)
|
||||
[](https://github.com/alexbelgium/hassio-addons/actions/workflows/onpush_builder.yaml)
|
||||
[](https://github.com/alexbelgium/hassio-addons/actions/workflows/weekly_stats.yaml)
|
||||
|
||||
[support-badge]: https://camo.githubusercontent.com/f4dbb995049f512fdc97fcc9e022ac243fa38c408510df9d46c7467d0970d959/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f537570706f72742d7468726561642d677265656e2e737667
|
||||
|
||||
_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_
|
||||
|
||||
[](https://github.com/Mesteriis/hassio-addons-avm/stargazers)
|
||||
[](https://github.com/alexbelgium/hassio-addons/stargazers)
|
||||
|
||||
_Thanks to all contributors !_
|
||||
|
||||
[](https://github.com/Mesteriis/hassio-addons-avm/graphs/contributors)
|
||||
[](https://github.com/alexbelgium/hassio-addons/graphs/contributors)
|
||||
|
||||
## About
|
||||
|
||||
@@ -38,7 +38,7 @@ home to the next level.
|
||||
|
||||
[![Add repository on my Home Assistant][repository-badge]][repository-url]
|
||||
|
||||
If you want to do add the repository manually, please follow the procedure highlighted in the [Home Assistant website](https://home-assistant.io/hassio/installing_third_party_addons). Use the following URL to add this repository: https://github.com/Mesteriis/hassio-addons-avm
|
||||
If you want to do add the repository manually, please follow the procedure highlighted in the [Home Assistant website](https://home-assistant.io/hassio/installing_third_party_addons). Use the following URL to add this repository: https://github.com/alexbelgium/hassio-addons
|
||||
|
||||
## Statistics
|
||||
|
||||
@@ -61,17 +61,15 @@ If you want to do add the repository manually, please follow the procedure highl
|
||||
|
||||
### Total downloads evolution
|
||||
|
||||
<img src="https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.github/stats.png" width=500px>
|
||||
<img src="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.github/stats.png" width=500px>
|
||||
|
||||
### Specific downloads evolution
|
||||
|
||||
<img src="https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.github/stats_addons.png" width=500px>
|
||||
<img src="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.github/stats_addons.png" width=500px>
|
||||
|
||||
### Stars evolution
|
||||
|
||||
<a href="https://star-history.com">
|
||||
<img src="https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.github/starsevol.svg" width=500px>
|
||||
</a>
|
||||
[](https://star-history.com/#alexbelgium/hassio-addons&Date)
|
||||
|
||||
## Add-ons provided by this repository
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ if [ -e "/MODULESFILE" ]; then
|
||||
if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi &&
|
||||
apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true &&
|
||||
mkdir -p /etc/cont-init.d &&
|
||||
for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done &&
|
||||
for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done &&
|
||||
chmod -R 755 /etc/cont-init.d
|
||||
fi
|
||||
|
||||
@@ -28,7 +28,7 @@ if [ -e "/ENVFILE" ]; then
|
||||
|
||||
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi &&
|
||||
if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi &&
|
||||
curl -f -L -s -S "https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.templates/ha_automatic_packages.sh" --output /ha_automatic_packages.sh &&
|
||||
curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automatic_packages.sh" --output /ha_automatic_packages.sh &&
|
||||
chmod 777 /ha_automatic_packages.sh &&
|
||||
eval /./ha_automatic_packages.sh "${PACKAGES:-}" &&
|
||||
rm /ha_automatic_packages.sh
|
||||
|
||||
@@ -1,61 +1,91 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# shellcheck shell=bash disable=SC2016
|
||||
set -e
|
||||
# ==============================================================================
|
||||
# Displays a simple add-on banner on startup
|
||||
# ==============================================================================
|
||||
if bashio::supervisor.ping; then
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue " Add-on: $(bashio::addon.name)"
|
||||
bashio::log.blue " $(bashio::addon.description)"
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
|
||||
bashio::log.blue " Add-on version: $(bashio::addon.version)"
|
||||
if bashio::var.true "$(bashio::addon.update_available)"; then
|
||||
bashio::log.magenta ' There is an update available for this add-on!'
|
||||
bashio::log.magenta \
|
||||
" Latest add-on version: $(bashio::addon.version_latest)"
|
||||
bashio::log.magenta ' Please consider upgrading as soon as possible.'
|
||||
else
|
||||
bashio::log.green ' You are running the latest version of this add-on.'
|
||||
fi
|
||||
|
||||
bashio::log.blue " System: $(bashio::info.operating_system)" \
|
||||
" ($(bashio::info.arch) / $(bashio::info.machine))"
|
||||
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
|
||||
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
|
||||
|
||||
if ! bashio::supervisor.ping 2>/dev/null; then
|
||||
# Degraded mode if no homeassistant
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue \
|
||||
' Please, share the above information when looking for help'
|
||||
bashio::log.blue \
|
||||
' or support in, e.g., GitHub, forums'
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.green \
|
||||
' Provided by: https://github.com/Mesteriis/hassio-addons-avm '
|
||||
bashio::log.blue "Starting addon without HA support"
|
||||
bashio::log.blue "Version : ${BUILD_VERSION:-1.0}"
|
||||
bashio::log.blue "Please use Docker Compose for env variables"
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
# Use environment variables instead of addon options
|
||||
echo "... convert scripts to use environment variables instead of addon options"
|
||||
while IFS= read -r scripts
|
||||
do
|
||||
sed -i -e 's/bashio::config.has_value[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']/[ ! -z "${\1:-}" ]/g' \
|
||||
-e 's/bashio::config.true[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']/[ ! -z "${\1:-}" ] \&\& [ "${\1:-}" = "true" ]/g' \
|
||||
-e 's/\$(bashio::config[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"'])/${\1:-}/g' \
|
||||
-e 's/\$(bashio::addon.port[[:space:]]*["'"'"']\([0-9]*\)["'"'"'])/${\1:-}/g' \
|
||||
-e 's/bashio::config.require.ssl/true/g' \
|
||||
-e 's/\$(bashio::addon.ingress_port)/""/g' \
|
||||
-e 's/\$(bashio::addon.ingress_entry)/""/g' \
|
||||
-e 's/\$(bashio::addon.ip_address)/""/g' "$scripts"
|
||||
done < <(grep -srl "bashio" /etc/cont-init.d /custom-services.d)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue " Add-on: $(bashio::addon.name)"
|
||||
bashio::log.blue " $(bashio::addon.description)"
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
|
||||
bashio::log.blue " Add-on version: $(bashio::addon.version)"
|
||||
if bashio::var.true "$(bashio::addon.update_available)"; then
|
||||
bashio::log.magenta ' There is an update available for this add-on!'
|
||||
bashio::log.magenta \
|
||||
" Latest add-on version: $(bashio::addon.version_latest)"
|
||||
bashio::log.magenta ' Please consider upgrading as soon as possible.'
|
||||
else
|
||||
bashio::log.green ' You are running the latest version of this add-on.'
|
||||
fi
|
||||
|
||||
bashio::log.blue " System: $(bashio::info.operating_system)"
|
||||
bashio::log.blue " Architecture: $(bashio::info.arch) / $(bashio::info.machine)"
|
||||
bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)"
|
||||
bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)"
|
||||
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.blue \
|
||||
' Please, share the above information when looking for help'
|
||||
bashio::log.blue \
|
||||
' or support in, e.g., GitHub, forums'
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
bashio::log.green \
|
||||
' Provided by: https://github.com/alexbelgium/hassio-addons '
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
|
||||
# ==============================================================================
|
||||
# Global actions for all addons
|
||||
# ==============================================================================
|
||||
if bashio::config.has_value "PUID" && bashio::config.has_value "PGID"; then
|
||||
bashio::log.green \
|
||||
' Defining permissions for main user : '
|
||||
bashio::log.green ' Defining permissions for main user : '
|
||||
PUID="$(bashio::config "PUID")"
|
||||
PGID="$(bashio::config "PGID")"
|
||||
bashio::log.blue "User UID: $PUID"
|
||||
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
|
||||
bashio::log.blue "User GID: $PGID"
|
||||
|
||||
# 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 \
|
||||
'-----------------------------------------------------------'
|
||||
fi
|
||||
|
||||
# Clean bashrc file
|
||||
if [ -f ~/.bashrc ]; then rm ~/.bashrc; fi
|
||||
# Clean bashrc file safely
|
||||
if [ -f ~/.bashrc ]; then : > ~/.bashrc; fi
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
if ! bashio::supervisor.ping 2>/dev/null; then
|
||||
echo "..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
###################################
|
||||
# Export all addon options as env #
|
||||
###################################
|
||||
@@ -27,7 +32,7 @@ for KEYS in "${arr[@]}"; do
|
||||
VALUE=$(jq ."$KEYS" "${JSONSOURCE}")
|
||||
# Check if the value is an array
|
||||
if [[ "$VALUE" == \[* ]]; then
|
||||
bashio::log.warning "$VALUE is an array, skipping"
|
||||
bashio::log.warning "One of your option is an array, skipping"
|
||||
else
|
||||
# Continue for single values
|
||||
VALUE="${VALUE//[\"\']/}"
|
||||
@@ -54,7 +59,7 @@ for KEYS in "${arr[@]}"; do
|
||||
VALUE="$secret"
|
||||
fi
|
||||
# text
|
||||
if bashio::config.false "verbose" || [[ "${KEYS}" == *"PASS"* ]]; then
|
||||
if bashio::config.false "verbose" || [[ "${KEYS,,}" == *"pass"* ]]; then
|
||||
bashio::log.blue "${KEYS}=******"
|
||||
else
|
||||
bashio::log.blue "$line"
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
if ! bashio::supervisor.ping 2>/dev/null; then
|
||||
echo "..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
######################
|
||||
# MOUNT LOCAL SHARES #
|
||||
######################
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
# shellcheck disable=
|
||||
set -e
|
||||
|
||||
if ! bashio::supervisor.ping 2>/dev/null; then
|
||||
bashio::log.blue "Disabled : please use another method"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
####################
|
||||
# DEFINE FUNCTIONS #
|
||||
####################
|
||||
@@ -19,6 +24,7 @@ test_mount () {
|
||||
fi
|
||||
|
||||
# Exit if can't write
|
||||
[[ -e "/mnt/$diskname/testaze" ]] && rm -r "/mnt/$diskname/testaze"
|
||||
# shellcheck disable=SC2015
|
||||
mkdir "/mnt/$diskname/testaze" && touch "/mnt/$diskname/testaze/testaze" && rm -r "/mnt/$diskname/testaze" || ERROR_MOUNT=true
|
||||
if [[ "$ERROR_MOUNT" == "true" ]]; then
|
||||
@@ -65,7 +71,7 @@ if bashio::config.has_value 'networkdisks'; then
|
||||
# Alert message that it is a new code
|
||||
if [[ "$(date +"%Y%m%d")" -lt "20240201" ]]; then
|
||||
bashio::log.warning "------------------------"
|
||||
bashio::log.warning "This is a new code, please report any issues on https://github.com/Mesteriis/hassio-addons-avm"
|
||||
bashio::log.warning "This is a new code, please report any issues on https://github.com/alexbelgium/hassio-addons"
|
||||
bashio::log.warning "------------------------"
|
||||
fi
|
||||
|
||||
|
||||
@@ -7,22 +7,23 @@ set -e
|
||||
# INITIALIZATION #
|
||||
##################
|
||||
|
||||
# Exit if /config is not mounted
|
||||
if [ ! -d /config ]; then
|
||||
# Disable if config not present
|
||||
if [ ! -d /config ] || ! bashio::supervisor.ping 2>/dev/null; then
|
||||
echo "..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Define slug
|
||||
slug="${HOSTNAME}"
|
||||
slug="${HOSTNAME/-/_}"
|
||||
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/$slug/config.yaml"
|
||||
CONFIGFILEBROWSER="/addon_configs/${HOSTNAME/-/_}/config.yaml"
|
||||
else
|
||||
# Legacy config location
|
||||
slug="${HOSTNAME#*-}"
|
||||
CONFIGLOCATION="/config/addons_config/${slug}"
|
||||
CONFIGFILEBROWSER="/homeassistant/addons_config/$slug/config.yaml"
|
||||
fi
|
||||
@@ -35,6 +36,9 @@ CONFIGSOURCE="$CONFIGLOCATION"/config.yaml
|
||||
if bashio::config.has_value 'CONFIG_LOCATION'; then
|
||||
|
||||
CONFIGSOURCE=$(bashio::config "CONFIG_LOCATION")
|
||||
if [[ "$CONFIGSOURCE" == *.* ]]; then
|
||||
CONFIGSOURCE=$(dirname "$CONFIGSOURCE")
|
||||
fi
|
||||
# If does not end by config.yaml, remove trailing slash and add config.yaml
|
||||
if [[ "$CONFIGSOURCE" != *".yaml" ]]; then
|
||||
CONFIGSOURCE="${CONFIGSOURCE%/}"/config.yaml
|
||||
@@ -89,7 +93,7 @@ else
|
||||
bashio::log.green "If accessing the file with filebrowser it should be mapped to $CONFIGSOURCE"
|
||||
fi
|
||||
bashio::log.green "---------------------------------------------------------"
|
||||
bashio::log.green "Wiki here on how to use : github.com/Mesteriis/hassio-addons-avm/wiki/Add‐ons-feature-:-add-env-variables"
|
||||
bashio::log.green "Wiki here on how to use : github.com/alexbelgium/hassio-addons/wiki/Add‐ons-feature-:-add-env-variables"
|
||||
echo ""
|
||||
|
||||
# Check if config file is there, or create one from template
|
||||
@@ -103,7 +107,7 @@ if [ ! -f "$CONFIGSOURCE" ]; then
|
||||
cp /templates/config.yaml "$(dirname "${CONFIGSOURCE}")"
|
||||
else
|
||||
# Download template
|
||||
TEMPLATESOURCE="https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.templates/config.template"
|
||||
TEMPLATESOURCE="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/config.template"
|
||||
curl -f -L -s -S "$TEMPLATESOURCE" --output "$CONFIGSOURCE"
|
||||
fi
|
||||
fi
|
||||
@@ -111,7 +115,7 @@ fi
|
||||
# Check if there are lines to read
|
||||
cp "$CONFIGSOURCE" /tempenv
|
||||
sed -i '/^#/d' /tempenv
|
||||
sed -i '/^ /d' /tempenv
|
||||
sed -i '/^[[:space:]]*$/d' /tempenv
|
||||
sed -i '/^$/d' /tempenv
|
||||
# Exit if empty
|
||||
if [ ! -s /tempenv ]; then
|
||||
@@ -154,6 +158,10 @@ parse_yaml "$CONFIGSOURCE" "" >/tmpfile
|
||||
# Escape dollars
|
||||
sed -i 's|$.|\$|g' /tmpfile
|
||||
|
||||
# Look where secrets.yaml is located
|
||||
SECRETSFILE="/config/secrets.yaml"
|
||||
if [ -f "$SECRETSFILE" ]; then SECRETSFILE="/homeassistant/secrets.yaml"; fi
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Clean output
|
||||
line="${line//[\"\']/}"
|
||||
@@ -162,10 +170,10 @@ while IFS= read -r line; do
|
||||
echo "secret detected"
|
||||
secret=${line#*secret }
|
||||
# Check if single match
|
||||
secretnum=$(sed -n "/$secret:/=" /config/secrets.yaml)
|
||||
secretnum=$(sed -n "/$secret:/=" "$SECRETSFILE")
|
||||
[[ $(echo $secretnum) == *' '* ]] && bashio::exit.nok "There are multiple matches for your password name. Please check your secrets.yaml file"
|
||||
# Get text
|
||||
secret=$(sed -n "/$secret:/p" /config/secrets.yaml)
|
||||
secret=$(sed -n "/$secret:/p" "$SECRETSFILE")
|
||||
secret=${secret#*: }
|
||||
line="${line%%=*}='$secret'"
|
||||
fi
|
||||
|
||||
@@ -6,36 +6,37 @@ set -e
|
||||
# INITIALIZATION #
|
||||
##################
|
||||
|
||||
# Exit if /config is not mounted
|
||||
if [ ! -d /config ]; then
|
||||
# Exit if /config is not mounted or HA not used
|
||||
if [ ! -d /config ] || ! bashio::supervisor.ping 2>/dev/null; then
|
||||
echo "..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Define slug
|
||||
slug="${HOSTNAME}"
|
||||
slug="${HOSTNAME/-/_}"
|
||||
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/$slug/${HOSTNAME#*-}.sh"
|
||||
CONFIGFILEBROWSER="/addon_configs/${HOSTNAME/-/_}/$slug.sh"
|
||||
else
|
||||
# Legacy config location
|
||||
slug="${HOSTNAME#*-}"
|
||||
CONFIGLOCATION="/config/addons_autoscripts"
|
||||
CONFIGFILEBROWSER="/homeassistant/addons_config/${slug}/${slug}.sh"
|
||||
CONFIGFILEBROWSER="/homeassistant/addons_autoscripts/$slug.sh"
|
||||
fi
|
||||
|
||||
# Default location
|
||||
mkdir -p "$CONFIGLOCATION" || true
|
||||
CONFIGSOURCE="$CONFIGLOCATION/${HOSTNAME#*-}.sh"
|
||||
CONFIGSOURCE="$CONFIGLOCATION/$slug.sh"
|
||||
|
||||
bashio::log.green "Execute $CONFIGFILEBROWSER if existing"
|
||||
bashio::log.green "Wiki here : github.com/Mesteriis/hassio-addons-avm/wiki/Add-ons-feature-:-customisation"
|
||||
bashio::log.green "Wiki here : github.com/alexbelgium/hassio-addons/wiki/Add-ons-feature-:-customisation"
|
||||
|
||||
# Download template if no script found and exit
|
||||
if [ ! -f "$CONFIGSOURCE" ]; then
|
||||
TEMPLATESOURCE="https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.templates/script.template"
|
||||
TEMPLATESOURCE="https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/script.template"
|
||||
curl -f -L -s -S "$TEMPLATESOURCE" --output "$CONFIGSOURCE" || true
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#============================#
|
||||
# ALEXBELGIUM'S ENV INJECTOR #
|
||||
#============================#
|
||||
#
|
||||
# All env variables set in this file will be enabled in the app
|
||||
# This allows enabling more options that normally available in the addon options
|
||||
# This file must be filled according to the yaml format.
|
||||
|
||||
@@ -20,7 +20,7 @@ if ! command -v curl >/dev/null 2>/dev/null; then
|
||||
fi
|
||||
|
||||
# Call apps installer script if needed
|
||||
curl -f -L -s -S "https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.templates/ha_automatic_packages.sh" --output /ha_automatic_packages.sh
|
||||
curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automatic_packages.sh" --output /ha_automatic_packages.sh
|
||||
chmod 777 /ha_automatic_packages.sh
|
||||
eval /./ha_automatic_packages.sh "${PACKAGES:-}"
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ for files in "/etc/cont-init.d" "/etc/services.d"; do
|
||||
COMMAND="mount"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND"; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES exfatprogs ntfs-3g squashfs-tools fuse lsblk"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES exfatprogs ntfs-3g ntfs-3g-progs squashfs-tools fuse lsblk"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES exfat* ntfs* squashfs-tools util-linux"
|
||||
#[ "$PACKMANAGER" = "pacman" ] && PACKAGES="$PACKAGES ntfs-3g"
|
||||
fi
|
||||
@@ -216,10 +216,10 @@ fi
|
||||
#######################
|
||||
|
||||
# Install micro texteditor
|
||||
curl https://getmic.ro | bash
|
||||
mv micro /usr/bin
|
||||
micro -plugin install bounce
|
||||
micro -plugin install filemanager
|
||||
curl https://getmic.ro | bash || true
|
||||
mv micro /usr/bin || true
|
||||
micro -plugin install bounce || true
|
||||
micro -plugin install filemanager || true
|
||||
|
||||
for files in "/etc/services.d" "/etc/cont-init.d"; do
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ mkdir -p /etc/cont-init.d
|
||||
|
||||
# Download scripts
|
||||
for scripts in $MODULES; do
|
||||
echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/Mesteriis/hassio-addons-avm/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" &&
|
||||
echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" &&
|
||||
[ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] ||
|
||||
(echo "script failed to install $scripts" && exit 1)
|
||||
done
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
echo "Starting..."
|
||||
|
||||
####################
|
||||
@@ -11,11 +12,11 @@ for SCRIPTS in /etc/cont-init.d/*; do
|
||||
echo "$SCRIPTS: executing"
|
||||
|
||||
# Check if run as root
|
||||
if test "$(id -u)" == 0 && test "$(id -u)" == 0; then
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||
chmod a+x "$SCRIPTS"
|
||||
else
|
||||
bashio::log.warning "Script executed with user $(id -u):$(id -g), things can break and chown won't work"
|
||||
echo -e "\e[38;5;214m$(date) WARNING: Script executed with user $(id -u):$(id -g), things can break and chown won't work\e[0m"
|
||||
# Disable chown and chmod in scripts
|
||||
sed -i "s/^chown /true # chown /g" "$SCRIPTS"
|
||||
sed -i "s/ chown / true # chown /g" "$SCRIPTS"
|
||||
@@ -26,34 +27,70 @@ for SCRIPTS in /etc/cont-init.d/*; do
|
||||
# Get current shebang, if not available use another
|
||||
currentshebang="$(sed -n '1{s/^#![[:blank:]]*//p;q}' "$SCRIPTS")"
|
||||
if [ ! -f "${currentshebang%% *}" ]; then
|
||||
for shebang in "/command/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/bin/bash" "/bin/sh"; do if [ -f "${shebang%% *}" ]; then break; fi; done
|
||||
for shebang in "/command/with-contenv bashio" "/usr/bin/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/usr/bin/bash" "/usr/bin/sh" "/bin/bash" "/bin/sh"; do
|
||||
command_path="${shebang%% *}"
|
||||
if [ -x "$command_path" ] && "$command_path" echo "yes" >/dev/null 2>&1; then
|
||||
echo "Valid shebang: $shebang"
|
||||
break
|
||||
fi
|
||||
done
|
||||
sed -i "s|$currentshebang|$shebang|g" "$SCRIPTS"
|
||||
fi
|
||||
|
||||
# Use source to share env variables when requested
|
||||
if [ "${ha_entry_source:-null}" = true ] && command -v "source" &>/dev/null; then
|
||||
# Exit cannot be used with source
|
||||
sed -i "s/(.*\s|^)exit ([0-9]+)/\1 return \2 || exit \2/g" "$SCRIPTS"
|
||||
sed -i "s/bashio::exit.nok/return 1/g" "$SCRIPTS"
|
||||
sed -i "s/bashio::exit.ok/return 0/g" "$SCRIPTS"
|
||||
# shellcheck source=/dev/null
|
||||
# shellcheck disable=SC1090
|
||||
source "$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?"
|
||||
else
|
||||
# Support for posix only shell
|
||||
/."$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?"
|
||||
"$SCRIPTS" || echo -e "\033[0;31mError\033[0m : $SCRIPTS exiting $?"
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
rm "$SCRIPTS"
|
||||
|
||||
done
|
||||
|
||||
######################
|
||||
# Starting container #
|
||||
######################
|
||||
|
||||
echo " "
|
||||
echo -e "\033[0;32mStarting the upstream container\033[0m"
|
||||
echo " "
|
||||
|
||||
# Launch lsio mods
|
||||
if [ -f /docker-mods ]; then exec /docker-mods; fi
|
||||
# If PID 1, keep alive and manage sigterm
|
||||
if [ "$$" -eq 1 ]; then
|
||||
echo " "
|
||||
echo -e "\033[0;32mEverything started!\033[0m"
|
||||
terminate() {
|
||||
echo "Termination signal received, forwarding to subprocesses..."
|
||||
# Terminate all subprocesses
|
||||
if command -v pgrep &>/dev/null; then
|
||||
for pid in $(pgrep -P $$); do
|
||||
echo "Terminating child PID $pid"
|
||||
kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid"
|
||||
done
|
||||
else
|
||||
# Fallback to iterating through /proc if pgrep is not available
|
||||
for pid in /proc/[0-9]*/; do
|
||||
pid=${pid#/proc/}
|
||||
pid=${pid%/}
|
||||
if [[ "$pid" -ne 1 ]] && grep -q "^PPid:\s*$$" "/proc/$pid/status" 2>/dev/null; then
|
||||
echo "Terminating child PID $pid"
|
||||
kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
wait
|
||||
echo "All subprocesses terminated. Exiting."
|
||||
exit 0
|
||||
}
|
||||
trap terminate SIGTERM SIGINT
|
||||
while :; do sleep infinity & wait $!; done
|
||||
else
|
||||
echo " "
|
||||
echo -e "\033[0;32mStarting the upstream container\033[0m"
|
||||
echo " "
|
||||
# Launch lsio mods
|
||||
if [ -f /docker-mods ]; then exec /docker-mods; fi
|
||||
fi
|
||||
|
||||
@@ -39,7 +39,9 @@ mkdir -p /run/s6/container_environment
|
||||
|
||||
# Check if shebang exists
|
||||
for shebang in "/command/with-contenv bashio" "/usr/bin/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/usr/bin/bash" "/usr/bin/sh" "/bin/bash" "/bin/sh"; do
|
||||
if [ -f "${shebang%% *}" ]; then
|
||||
command_path="${shebang%% *}"
|
||||
if [ -x "$command_path" ] && "$command_path" echo "yes" >/dev/null 2>&1; then
|
||||
echo "Valid shebang: $shebang"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -51,6 +51,11 @@ if [ -f /etc/s6-overlay/s6-rc.d/svc-cron/run ]; then
|
||||
sed -i "/exec \/usr\/sbin\/cron/c exec /usr/sbin/cron -f &>/proc/1/fd/1" /etc/s6-overlay/s6-rc.d/svc-cron/run
|
||||
fi
|
||||
|
||||
# variables not found
|
||||
for file in $(grep -srl "/usr/bin" /etc/cont-init.d /etc/s6-overlay/s6-rc.d); do
|
||||
sed -i "1a set +u" "$file"
|
||||
done
|
||||
|
||||
# Replace lsiown if not found
|
||||
if [ ! -f /usr/bin/lsiown ]; then
|
||||
for file in $(grep -sril "lsiown" /etc); do
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
#################
|
||||
|
||||
# Any commands written in this bash script will be executed at addon start
|
||||
# See guide here : https://github.com/Mesteriis/hassio-addons-avm/wiki/Add%E2%80%90ons-feature-:-customisation
|
||||
# See guide here : https://github.com/alexbelgium/hassio-addons/wiki/Add%E2%80%90ons-feature-:-customisation
|
||||
|
||||
Reference in New Issue
Block a user