mirror of
https://github.com/buanet/ioBroker.docker.git
synced 2025-12-25 17:54:11 +02:00
add check for package validity
This commit is contained in:
20
debian/scripts/setup_packages.sh
vendored
20
debian/scripts/setup_packages.sh
vendored
@@ -6,11 +6,13 @@ set -euo pipefail
|
||||
# Reading ENV
|
||||
set +u
|
||||
packages=$PACKAGES
|
||||
debug=$DEBUG
|
||||
set -u
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
check_package_preq() {
|
||||
# check for influx packages
|
||||
if [[ "$i" == "influxdb" || "$i" == "influxdb2-cli" ]]; then
|
||||
# add influxdata repo
|
||||
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
|
||||
@@ -18,10 +20,26 @@ check_package_preq() {
|
||||
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
|
||||
fi
|
||||
}
|
||||
check_package_validity() {
|
||||
# remove packages when "influxdb" AND "influxdb2-cli"
|
||||
if [[ echo "$packages" | grep -qw "influxdb" && echo "$packages" | grep -qw "influxdb2-cli" ]]; then
|
||||
echo "PACKAGES includes \"influxdb\" AND \"influxdb2-cli\"."
|
||||
echo "As installing both packages together is not possible, they will be skipped."
|
||||
packages=$(echo "$packages" | sed 's/influxdb//g' | sed 's/influxdb2-cli//g')
|
||||
if [[ "$debug" == "true" ]]; then echo "[DEBUG] New list of packages: = ""$packages"; fi
|
||||
echo ' '
|
||||
fi
|
||||
# check string for double spaces
|
||||
while echo "$packages" | grep -q ' '; do
|
||||
# remove double spaces
|
||||
packages=$(echo "$packages" | sed 's/ / /g')
|
||||
done
|
||||
}
|
||||
|
||||
if [[ "$1" == "-install" ]]; then
|
||||
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
|
||||
echo ' '
|
||||
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
|
||||
check_package_validity
|
||||
for i in $packages; do
|
||||
if [[ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]]; then
|
||||
echo -n "$i is not installed. Installing... "
|
||||
|
||||
Reference in New Issue
Block a user