mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 18:31:02 +01:00
Update automatic_packages.sh
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
set +e 2>/dev/null
|
||||
set +u 2>/dev/null
|
||||
|
||||
VERBOSE=true
|
||||
|
||||
##################
|
||||
# INIT VARIABLES #
|
||||
@@ -13,12 +15,12 @@ PACKMANAGER="apk"
|
||||
|
||||
if [[ "$(apk -h 2>/dev/null)" ]]; then
|
||||
# If apk based
|
||||
echo "apk based"
|
||||
[ $VERBOSE = true ] && echo "apk based"
|
||||
PACKMANAGER="apk"
|
||||
PACKAGES="apk add --no-cache $PACKAGES"
|
||||
else
|
||||
# If apt-get based
|
||||
echo "apt based"
|
||||
[ $VERBOSE = true ] && echo "apt based"
|
||||
PACKMANAGER="apt"
|
||||
PACKAGES="apt-get clean \
|
||||
&& apt-get update \
|
||||
@@ -39,7 +41,7 @@ PACKAGES="$PACKAGES jq curl"
|
||||
|
||||
# In etc
|
||||
if ls /etc/nginx 1> /dev/null 2>&1; then
|
||||
echo "nginx found"
|
||||
[ $VERBOSE = true ] && echo "nginx found"
|
||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES nginx"
|
||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES nginx"
|
||||
mv /etc/nginx /etc/nginx2
|
||||
@@ -49,19 +51,19 @@ fi
|
||||
for files in "/scripts" "/etc/cont-init.d"; do
|
||||
|
||||
if ls $files/*smb* 1> /dev/null 2>&1; then
|
||||
echo "smb found"
|
||||
[ $VERBOSE = true ] && echo "smb found"
|
||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba samba-client"
|
||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba smbclient"
|
||||
fi
|
||||
|
||||
if ls $files/*vpn* 1> /dev/null 2>&1; then
|
||||
echo "vpn found"
|
||||
[ $VERBOSE = true ] && echo "vpn found"
|
||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn"
|
||||
fi
|
||||
|
||||
if ls $files/*global_var* 1> /dev/null 2>&1; then
|
||||
echo "global_var found"
|
||||
[ $VERBOSE = true ] && echo "global_var found"
|
||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES jq"
|
||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES jq"
|
||||
fi
|
||||
@@ -73,25 +75,25 @@ for files in "/scripts" "/etc/cont-init.d"; do
|
||||
fi
|
||||
|
||||
if [[ $(grep -rnw "$files/" -e 'git') ]]; then
|
||||
echo "git found"
|
||||
[ $VERBOSE = true ] && echo "git found"
|
||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES git"
|
||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES git"
|
||||
fi
|
||||
|
||||
if [[ $(grep -rnw "$files/" -e 'sponge') ]]; then
|
||||
echo "sponge found"
|
||||
[ $VERBOSE = true ] && echo "sponge found"
|
||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES moreutils"
|
||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES moreutils"
|
||||
fi
|
||||
|
||||
if [[ $(grep -rnw "$files/" -e 'sqlite') ]]; then
|
||||
echo "sqlite found"
|
||||
[ $VERBOSE = true ] && echo "sqlite found"
|
||||
[ $PACKMANAGER = "apk" ] && PACKAGES="$PACKAGES sqlite"
|
||||
[ $PACKMANAGER = "apt" ] && PACKAGES="$PACKAGES sqlite3"
|
||||
fi
|
||||
|
||||
if [[ $(grep -rnw "$files/" -e 'pip') ]]; then
|
||||
echo "pip found"
|
||||
[ $VERBOSE = true ] && echo "pip found"
|
||||
[ $PACKMANAGER = "apk" ] && [[ $(pip -V) ]] || PACKAGES="$PACKAGES py3-pip"
|
||||
[ $PACKMANAGER = "apt" ] && [[ $(pip -V) ]] || PACKAGES="$PACKAGES python-pip"
|
||||
fi
|
||||
@@ -102,13 +104,14 @@ done
|
||||
# INSTALL ELEMENTS #
|
||||
####################
|
||||
|
||||
echo "installing packages $PACKAGES"
|
||||
[ $VERBOSE = true ] && echo "installing packages $PACKAGES"
|
||||
eval "$PACKAGES"
|
||||
|
||||
# Replace nginx if installed
|
||||
if ls /etc/nginx2 1> /dev/null 2>&1; then
|
||||
echo "replace nginx"
|
||||
cp -rlf /etc/nginx2/ /etc/nginx/ && rm -r /etc/nginx2
|
||||
[ $VERBOSE = true ] && echo "replace nginx2"
|
||||
cp -rlf /etc/nginx2/ /etc/nginx/
|
||||
rm -r /etc/nginx2
|
||||
mkdir -p /var/log/nginx
|
||||
touch /var/log/nginx/error.log
|
||||
fi
|
||||
@@ -121,6 +124,7 @@ for files in "/scripts" "/etc/cont-init.d"; do
|
||||
|
||||
# Bashio
|
||||
if [[ $(grep -rnw "$files/" -e 'bashio') ]]; then
|
||||
[ $VERBOSE = true ] && echo "install 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
|
||||
mv /tmp/bashio/lib /usr/lib/bashio
|
||||
@@ -130,11 +134,13 @@ for files in "/scripts" "/etc/cont-init.d"; do
|
||||
|
||||
# Lastversion
|
||||
if [[ $(grep -rnw "$files/" -e 'lastversion') ]]; then
|
||||
[ $VERBOSE = true ] && echo "install lastversion"
|
||||
pip install lastversion
|
||||
fi
|
||||
|
||||
# Tempio
|
||||
if [[ $(grep -rnw "$files/" -e '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}"
|
||||
|
||||
Reference in New Issue
Block a user