mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-10 01:25:58 +02:00
New logic
This commit is contained in:
@@ -2,17 +2,17 @@
|
||||
# If dockerfile failed install manually
|
||||
if [ -e "/ENVFILE" ]; then
|
||||
echo "Executing script"
|
||||
PACKAGES=$(< /ENVFILE)
|
||||
PACKAGES=$(</ENVFILE)
|
||||
(
|
||||
#######################
|
||||
# Automatic installer #
|
||||
#######################
|
||||
$(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \
|
||||
$(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \
|
||||
curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \
|
||||
chmod 777 /automatic_packages.sh && \
|
||||
eval /./automatic_packages.sh "$PACKAGES" && \
|
||||
rm /automatic_packages.sh
|
||||
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); 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); fi &&
|
||||
curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh &&
|
||||
chmod 777 /automatic_packages.sh &&
|
||||
eval /./automatic_packages.sh "$PACKAGES" &&
|
||||
rm /automatic_packages.sh
|
||||
|
||||
) >/dev/null
|
||||
|
||||
|
||||
@@ -5,35 +5,35 @@
|
||||
|
||||
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)"
|
||||
" 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::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'
|
||||
' Please, share the above information when looking for help'
|
||||
bashio::log.blue \
|
||||
' or support in, e.g., GitHub, forums'
|
||||
' or support in, e.g., GitHub, forums'
|
||||
bashio::log.green \
|
||||
' https://github.com/alexbelgium/hassio-addons'
|
||||
' https://github.com/alexbelgium/hassio-addons'
|
||||
bashio::log.blue \
|
||||
'-----------------------------------------------------------'
|
||||
'-----------------------------------------------------------'
|
||||
fi
|
||||
|
||||
@@ -83,8 +83,8 @@ while IFS= read -r line; do
|
||||
if [[ $line =~ ^.+[=].+$ ]]; then
|
||||
export $line
|
||||
# Export the variable
|
||||
sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run*
|
||||
|
||||
sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || true
|
||||
sed -i "1a export $line" /scripts/*run* 2>/dev/null || true
|
||||
# Show in log
|
||||
bashio::log.blue "$line"
|
||||
else
|
||||
|
||||
@@ -4,27 +4,27 @@
|
||||
# INIT #
|
||||
########
|
||||
|
||||
VERBOSE=false
|
||||
set +u 2>/dev/null
|
||||
PACKAGES="${1:-}"
|
||||
VERBOSE="${2:-}"
|
||||
PACKAGES="${*:-}"
|
||||
[ "$VERBOSE" = true ] && echo "ENV : $PACKAGES"
|
||||
|
||||
############################
|
||||
# CHECK WHICH BASE IS USED #
|
||||
############################
|
||||
|
||||
if [[ "$(apk -h 2>/dev/null)" ]]; then
|
||||
# If apk based
|
||||
[ "$VERBOSE" = true ] && echo "apk based"
|
||||
PACKMANAGER="apk"
|
||||
PACKAGES="apk add --no-cache $PACKAGES"
|
||||
COMMAND="apk"
|
||||
if command -v $COMMAND &>/dev/null; then
|
||||
# If apk based
|
||||
[ "$VERBOSE" = true ] && echo "apk based"
|
||||
PACKMANAGER="apk"
|
||||
PACKAGES="apk add --no-cache $PACKAGES"
|
||||
else
|
||||
# If apt-get based
|
||||
[ "$VERBOSE" = true ] && echo "apt based"
|
||||
PACKMANAGER="apt"
|
||||
PACKAGES="apt-get clean \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends $PACKAGES"
|
||||
# If apt-get based
|
||||
[ "$VERBOSE" = true ] && echo "apt based"
|
||||
PACKMANAGER="apt"
|
||||
PACKAGES="apt-get update \
|
||||
&& apt-get install -yqq --no-install-recommends $PACKAGES"
|
||||
fi
|
||||
|
||||
###################
|
||||
@@ -42,85 +42,85 @@ PACKAGES="$PACKAGES jq curl"
|
||||
# Scripts
|
||||
for files in "/etc/cont-init.d" "/etc/services.d" "/scripts"; do
|
||||
# Next directory if does not exists
|
||||
if ! ls $files 1> /dev/null 2>&1; then continue; fi
|
||||
if ! ls $files 1>/dev/null 2>&1; then continue; fi
|
||||
|
||||
# Test each possible command
|
||||
COMMAND="nginx"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES nginx"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES nginx"
|
||||
if ls /etc/nginx 1> /dev/null 2>&1; then mv /etc/nginx /etc/nginx2; fi
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES nginx"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES nginx"
|
||||
if ls /etc/nginx 1>/dev/null 2>&1; then mv /etc/nginx /etc/nginx2; fi
|
||||
fi
|
||||
|
||||
COMMAND="cifs"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils"
|
||||
fi
|
||||
|
||||
COMMAND="smbclient"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES samba samba-client"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES samba smbclient"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES samba samba-client"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES samba smbclient"
|
||||
fi
|
||||
|
||||
COMMAND="openvpn"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||
fi
|
||||
|
||||
COMMAND="jq"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES jq"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES jq"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES jq"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES jq"
|
||||
fi
|
||||
|
||||
COMMAND="yamllint"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES yamllint"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES yamllint"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES yamllint"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES yamllint"
|
||||
fi
|
||||
|
||||
COMMAND="git"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES git"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES git"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES git"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES git"
|
||||
fi
|
||||
|
||||
COMMAND="sponge"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES moreutils"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES moreutils"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES moreutils"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES moreutils"
|
||||
fi
|
||||
|
||||
COMMAND="sqlite"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES sqlite"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES sqlite3"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES sqlite"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES sqlite3"
|
||||
fi
|
||||
|
||||
COMMAND="pip"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES py3-pip"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES python-pip"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES py3-pip"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES python-pip"
|
||||
fi
|
||||
|
||||
COMMAND="wget"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES wget"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES wget"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES wget"
|
||||
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES wget"
|
||||
fi
|
||||
|
||||
done
|
||||
@@ -130,15 +130,19 @@ done
|
||||
####################
|
||||
|
||||
# Install apps
|
||||
[ "$VERBOSE" = true ] && echo "installing packages $PACKAGES"
|
||||
eval "$PACKAGES"
|
||||
[ "$VERBOSE" = true ] && echo "installing packages $PACKAGES"
|
||||
eval "$PACKAGES"
|
||||
|
||||
# Clean after install
|
||||
[ "$VERBOSE" = true ] && echo "Cleaning apt cache"
|
||||
[ "$PACKMANAGER" = "apt" ] && apt-get clean || true
|
||||
|
||||
# Replace nginx if installed
|
||||
if ls /etc/nginx2 1> /dev/null 2>&1; then
|
||||
if ls /etc/nginx2 1>/dev/null 2>&1; then
|
||||
[ "$VERBOSE" = true ] && echo "replace nginx2"
|
||||
rm -r /etc/nginx
|
||||
mv /etc/nginx2 /etc/nginx
|
||||
mkdir -p /var/log/nginx
|
||||
mkdir -p /var/log/nginx
|
||||
touch /var/log/nginx/error.log
|
||||
fi
|
||||
|
||||
@@ -148,33 +152,48 @@ fi
|
||||
|
||||
for files in "/scripts" "/etc/services.d" "/etc/cont-init.d"; do
|
||||
|
||||
# Next directory if does not exists
|
||||
if ! ls $files 1> /dev/null 2>&1; then continue; fi
|
||||
# Next directory if does not exists
|
||||
if ! ls $files 1>/dev/null 2>&1; then continue; fi
|
||||
|
||||
# Bashio
|
||||
# Bashio
|
||||
if grep -q -rnw "$files/" -e 'bashio' && [ ! -f "/usr/bin/bashio" ]; then
|
||||
[ "$VERBOSE" = true ] && echo "install bashio"
|
||||
BASHIO_VERSION="0.14.3"
|
||||
mkdir -p /tmp/bashio
|
||||
curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio
|
||||
mv /tmp/bashio/lib /usr/lib/bashio
|
||||
ln -s /usr/lib/bashio/bashio /usr/bin/bashio
|
||||
rm -rf /tmp/bashio
|
||||
[ "$VERBOSE" = true ] && echo "install bashio"
|
||||
BASHIO_VERSION="0.14.3"
|
||||
mkdir -p /tmp/bashio
|
||||
curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio
|
||||
mv /tmp/bashio/lib /usr/lib/bashio
|
||||
ln -s /usr/lib/bashio/bashio /usr/bin/bashio
|
||||
rm -rf /tmp/bashio
|
||||
fi
|
||||
|
||||
# Lastversion
|
||||
# Lastversion
|
||||
if grep -q -rnw "$files/" -e 'lastversion'; then
|
||||
[ "$VERBOSE" = true ] && echo "install lastversion"
|
||||
pip install lastversion
|
||||
[ "$VERBOSE" = true ] && echo "install lastversion"
|
||||
pip install lastversion
|
||||
fi
|
||||
|
||||
# Tempio
|
||||
# Tempio
|
||||
if grep -q -rnw "$files/" -e 'tempio' && [ ! -f "/usr/bin/tempio" ]; then
|
||||
[ "$VERBOSE" = true ] && echo "install tempio"
|
||||
TEMPIO_VERSION="2021.09.0"
|
||||
BUILD_ARCH="$(bashio::info.arch)"
|
||||
curl -L -f -s -o /usr/bin/tempio "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"
|
||||
chmod a+x /usr/bin/tempio
|
||||
[ "$VERBOSE" = true ] && echo "install tempio"
|
||||
TEMPIO_VERSION="2021.09.0"
|
||||
BUILD_ARCH="$(bashio::info.arch)"
|
||||
curl -L -f -s -o /usr/bin/tempio "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"
|
||||
chmod a+x /usr/bin/tempio
|
||||
fi
|
||||
|
||||
|
||||
# Mustache
|
||||
COMMAND="mustache"
|
||||
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then
|
||||
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||
[ "$PACKMANAGER" = "apk" ] && apk add --no-cache go npm &&
|
||||
apk upgrade --no-cache &&
|
||||
apk add --no-cache --virtual .build-deps build-base git go &&
|
||||
go get -u github.com/quantumew/mustache-cli &&
|
||||
cp "$GOPATH"/bin/* /usr/bin/ &&
|
||||
rm -rf "$GOPATH" /var/cache/apk/* /tmp/src &&
|
||||
apk del .build-deps xz build-base
|
||||
[ "$PACKMANAGER" = "apt" ] && apt-get update &&
|
||||
apt-get install -yqq go npm node-mustache
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user