mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-08 08:35:57 +02:00
new logic
This commit is contained in:
@@ -4,16 +4,10 @@
|
|||||||
# INIT #
|
# INIT #
|
||||||
########
|
########
|
||||||
|
|
||||||
# Messages ?
|
|
||||||
VERBOSE=false
|
VERBOSE=false
|
||||||
# Non interactive
|
|
||||||
export DEBIAN_FRONTEND="noninteractive"
|
|
||||||
export LANG="C.UTF-8"
|
|
||||||
# Allow undefined variables
|
|
||||||
set +u 2>/dev/null
|
set +u 2>/dev/null
|
||||||
# Get env variables
|
PACKAGES="${*:-}"
|
||||||
PACKAGES="${@:-}"
|
[ "$VERBOSE" = true ] && echo "ENV : $PACKAGES"
|
||||||
[ $VERBOSE = true ] && echo "ENV : $PACKAGES"
|
|
||||||
|
|
||||||
############################
|
############################
|
||||||
# CHECK WHICH BASE IS USED #
|
# CHECK WHICH BASE IS USED #
|
||||||
@@ -21,12 +15,12 @@ PACKAGES="${@:-}"
|
|||||||
|
|
||||||
if [[ "$(apk -h 2>/dev/null)" ]]; then
|
if [[ "$(apk -h 2>/dev/null)" ]]; then
|
||||||
# If apk based
|
# If apk based
|
||||||
[ $VERBOSE = true ] && echo "apk based"
|
[ "$VERBOSE" = true ] && echo "apk based"
|
||||||
PACKMANAGER="apk"
|
PACKMANAGER="apk"
|
||||||
PACKAGES="apk add --no-cache $PACKAGES"
|
PACKAGES="apk add --no-cache $PACKAGES"
|
||||||
else
|
else
|
||||||
# If apt-get based
|
# If apt-get based
|
||||||
[ $VERBOSE = true ] && echo "apt based"
|
[ "$VERBOSE" = true ] && echo "apt based"
|
||||||
PACKMANAGER="apt"
|
PACKMANAGER="apt"
|
||||||
PACKAGES="apt-get clean \
|
PACKAGES="apt-get clean \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
@@ -45,71 +39,88 @@ PACKAGES="$PACKAGES jq curl"
|
|||||||
# FOR EACH SCRIPT, SELECT PACKAGES
|
# FOR EACH SCRIPT, SELECT PACKAGES
|
||||||
##################################
|
##################################
|
||||||
|
|
||||||
# Nginx
|
|
||||||
if ls /etc/nginx 1> /dev/null 2>&1; then
|
|
||||||
[ $VERBOSE = true ] && echo "nginx found"
|
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES nginx"
|
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES nginx"
|
|
||||||
mv /etc/nginx /etc/nginx2
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Scripts
|
# Scripts
|
||||||
for files in "/etc/cont-init.d" "/etc/services.d" "/scripts"; do
|
for files in "/etc/cont-init.d" "/etc/services.d" "/scripts"; do
|
||||||
# Next directory if does not exists
|
# 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
|
||||||
|
|
||||||
if ls $files/*smb* 1> /dev/null 2>&1; then
|
COMMAND="nginx"
|
||||||
[ $VERBOSE = true ] && echo "smb found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba samba-client"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba smbclient"
|
[ "$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
|
fi
|
||||||
|
|
||||||
if ls $files/*vpn* 1> /dev/null 2>&1; then
|
COMMAND="cifs"
|
||||||
[ $VERBOSE = true ] && echo "vpn found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba"
|
||||||
|
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ls $files/*global_var* 1> /dev/null 2>&1; then
|
COMMAND="smbclient"
|
||||||
[ $VERBOSE = true ] && echo "global_var found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES jq"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES jq"
|
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES samba samba-client"
|
||||||
|
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES samba smbclient"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ls $files/*yaml* 1> /dev/null 2>&1; then
|
|
||||||
echo "yaml found"
|
COMMAND="openvpn"
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES yamllint"
|
if grep -q -rn "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES yamllint"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
|
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||||
|
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(grep -rnw "$files/" -e 'git') ]]; then
|
COMMAND="jq"
|
||||||
[ $VERBOSE = true ] && echo "git found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES git"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES git"
|
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES jq"
|
||||||
|
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES jq"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(grep -rnw "$files/" -e 'sponge') ]]; then
|
COMMAND="yamllint"
|
||||||
[ $VERBOSE = true ] && echo "sponge found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES moreutils"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES moreutils"
|
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES yamllint"
|
||||||
|
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES yamllint"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(grep -rnw "$files/" -e 'sqlite') ]]; then
|
COMMAND="git"
|
||||||
[ $VERBOSE = true ] && echo "sqlite found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES sqlite"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES sqlite3"
|
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES git"
|
||||||
|
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES git"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(grep -rnw "$files/" -e 'pip') ]]; then
|
COMMAND="sponge"
|
||||||
[ $VERBOSE = true ] && echo "pip found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES py3-pip"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES python-pip"
|
[ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES moreutils"
|
||||||
|
[ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES moreutils"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(grep -rnw "$files/" -e 'wget') ]]; then
|
COMMAND="sqlite"
|
||||||
[ $VERBOSE = true ] && echo "wget found"
|
if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then
|
||||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES wget"
|
[ "$VERBOSE" = true ] && echo "$COMMAND required"
|
||||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES wget"
|
[ "$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"
|
||||||
|
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"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
@@ -118,16 +129,13 @@ done
|
|||||||
# INSTALL ELEMENTS #
|
# INSTALL ELEMENTS #
|
||||||
####################
|
####################
|
||||||
|
|
||||||
[ $VERBOSE = true ] && echo "installing packages $PACKAGES"
|
# Install apps
|
||||||
|
[ "$VERBOSE" = true ] && echo "installing packages $PACKAGES"
|
||||||
eval "$PACKAGES"
|
eval "$PACKAGES"
|
||||||
|
|
||||||
##########################
|
|
||||||
# CORRECT INSTALLED APPS #
|
|
||||||
##########################
|
|
||||||
|
|
||||||
# Replace nginx if installed
|
# 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"
|
[ "$VERBOSE" = true ] && echo "replace nginx2"
|
||||||
rm -r /etc/nginx
|
rm -r /etc/nginx
|
||||||
mv /etc/nginx2 /etc/nginx
|
mv /etc/nginx2 /etc/nginx
|
||||||
mkdir -p /var/log/nginx
|
mkdir -p /var/log/nginx
|
||||||
@@ -138,14 +146,14 @@ fi
|
|||||||
# INSTALL MANUAL APPS #
|
# INSTALL MANUAL APPS #
|
||||||
#######################
|
#######################
|
||||||
|
|
||||||
for files in "/etc/cont-init.d" "/etc/services.d" "/scripts"; do
|
for files in "/scripts" "/etc/services.d" "/etc/cont-init.d"; do
|
||||||
|
|
||||||
# Next directory if does not exists
|
# 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
|
||||||
|
|
||||||
# Bashio
|
# Bashio
|
||||||
if [[ $(grep -rnw "$files/" -e 'bashio') ]] && [ ! -f "/usr/bin/bashio" ]; then
|
if grep -q -rnw "$files/" -e 'bashio' && [ ! -f "/usr/bin/bashio" ]; then
|
||||||
[ $VERBOSE = true ] && echo "install bashio"
|
[ "$VERBOSE" = true ] && echo "install bashio"
|
||||||
BASHIO_VERSION="0.14.3"
|
BASHIO_VERSION="0.14.3"
|
||||||
mkdir -p /tmp/bashio
|
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
|
curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio
|
||||||
@@ -155,14 +163,14 @@ if ! ls $files 1> /dev/null 2>&1; then continue; fi
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Lastversion
|
# Lastversion
|
||||||
if [[ $(grep -rnw "$files/" -e 'lastversion') ]]; then
|
if grep -q -rnw "$files/" -e 'lastversion'; then
|
||||||
[ $VERBOSE = true ] && echo "install lastversion"
|
[ "$VERBOSE" = true ] && echo "install lastversion"
|
||||||
pip install lastversion
|
pip install lastversion
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Tempio
|
# Tempio
|
||||||
if [[ $(grep -rnw "$files/" -e 'tempio') ]] && [ ! -f "/usr/bin/tempio" ]; then
|
if grep -q -rnw "$files/" -e 'tempio' && [ ! -f "/usr/bin/tempio" ]; then
|
||||||
[ $VERBOSE = true ] && echo "install tempio"
|
[ "$VERBOSE" = true ] && echo "install tempio"
|
||||||
TEMPIO_VERSION="2021.09.0"
|
TEMPIO_VERSION="2021.09.0"
|
||||||
BUILD_ARCH="$(bashio::info.arch)"
|
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}"
|
curl -L -f -s -o /usr/bin/tempio "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}"
|
||||||
|
|||||||
Reference in New Issue
Block a user