testing influx repo integration

This commit is contained in:
buanet
2023-04-15 22:30:19 +02:00
parent 9afa6646c2
commit bbac132f28
2 changed files with 32 additions and 10 deletions

View File

@@ -1,16 +1,37 @@
#!/bin/bash
# bash strict mode
set -euo pipefail
# Reading ENV
set +u
packages=$PACKAGES
set -u
export DEBIAN_FRONTEND=noninteractive
if [ "$1" == "-install" ]
then
check_package_preq() {
if [[ "$i" == "influxdb" || "$i" == "influxdb2-cli" ]]; then
# add influxdata repo
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
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
}
if [[ "$1" == "-install" ]]; then
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
packages=$(cat /opt/scripts/.docker_config/.packages)
echo ' '
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... "
if [[ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]]; then
echo -n "$i is not installed. Installing... "
check_package_preq >> /opt/scripts/setup_packages.log 2>&1
return=$?
if [[ "$return" -ne 0 ]]; then
echo "Failed."
echo "For more details see \"/opt/scripts/setup_packages.log\"."
echo ' '
else
DEBIAN_FRONTEND=noninteractive apt-get -q -y install "$i" >> /opt/scripts/setup_packages.log 2>&1
return=$?
if [[ "$return" -ne 0 ]]; then
@@ -20,11 +41,12 @@ then
else
echo "Done."
fi
else
echo "$i is already installed."
fi
else
echo "$i is already installed."
fi
done
elif [ "$1" == "-update" ]; then
elif [[ "$1" == "-update" ]]; then
echo -n "Updating Linux packages on first run... "
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
return=$?