enhance initial packages install/ update

This commit is contained in:
buanet
2023-02-20 16:18:22 +01:00
parent 6f83191969
commit 73225edba2
3 changed files with 33 additions and 18 deletions

View File

@@ -3,7 +3,8 @@
* upgrade node version to recommended node18
* rewrite of multihost setup handling
* rewrite of custom objects and states db setup handling
* extend logging and error handling
* enhance initial packages install/ update
* enhance logging and error handling
* add volume instruction to dockerfile
* add support for password protected custom objects and states db ([#306](https://github.com/buanet/ioBroker.docker/issues/306))
* add restore command to maintenance script

View File

@@ -134,24 +134,29 @@ if [[ -f /opt/.first_run ]]; then
# Updating Linux packages
if [[ "$offlinemode" = "true" ]]; then
echo "OFFLINE_MODE is \"true\". Skipping Linux package updates on first run."
echo ' '
else
echo "Updating Linux packages on first run... "
bash /opt/scripts/setup_packages.sh -update
echo 'Done.'
echo ' '
echo -n "Updating Linux packages on first run... "
set +e
bash /opt/scripts/setup_packages.sh -update > /opt/scripts/setup_packages.log 2>&1
return=$?
set -e
if [[ "$return" -ne 0 ]]; then
echo "Failed."
echo "For more details see \"/opt/scripts/setup_packages.log\"."
echo "Make sure the container has internet access to get the latest package updates."
echo "This has no impact to the setup process. The script will continue."
else
echo 'Done.'
fi
fi
echo ' '
# Installing packages from ENV
if [[ "$packages" != "" && "$offlinemode" = "true" ]]; then
echo "PACKAGES is set, but OFFLINE_MODE is \"true\". Skipping Linux package installation."
echo ' '
elif [[ "$packages" != "" ]]; then
echo "PACKAGES is set. Installing additional Linux packages."
echo "Checking the following packages:" "$packages""... "
echo "PACKAGES is set. Installing the following additional Linux packages: ""$packages"
echo "$packages" > /opt/scripts/.docker_config/.packages
bash /opt/scripts/setup_packages.sh -install
echo 'Done.'
echo ' '
fi
# Register maintenance script
echo -n 'Registering maintenance script as command... '
@@ -159,11 +164,10 @@ if [[ -f /opt/.first_run ]]; then
echo "alias maint=\'/opt/scripts/maintenance.sh\'" >> /root/.bashrc
echo "alias m=\'/opt/scripts/maintenance.sh\'" >> /root/.bashrc
echo 'Done.'
echo ' '
else
echo "This is not the first run of this container. Skipping first run preparation."
echo ' '
fi
echo ' '
# Setting UID and/ or GID
if [[ "$setgid" != "$(cat /etc/group | grep 'iobroker:' | cut -d':' -f3)" || "$setuid" != "$(cat /etc/passwd | grep 'iobroker:' | cut -d':' -f3)" ]]; then

View File

@@ -1,23 +1,33 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
if [ "$1" == "-install" ]
then
apt-get -qq update
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 "$i is not installed. Installing..."
sudo apt-get -qq -y install "$i"
echo -n "$i is not installed. Installing..."
DEBIAN_FRONTEND=noninteractive apt-get -q -y install "$i" >> /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
echo "Done."
fi
else
echo "$i is already installed."
fi
done
elif [ "$1" == "-update" ]
then
apt-get -qq update
apt-get -qq -y upgrade
apt-get -q update
apt-get -q -y upgrade
else
echo "No paramerter found!"
exit 1