fix error handling

This commit is contained in:
buanet
2023-02-20 18:01:33 +01:00
parent 73225edba2
commit 288932d607
2 changed files with 16 additions and 18 deletions

View File

@@ -135,19 +135,7 @@ if [[ -f /opt/.first_run ]]; then
if [[ "$offlinemode" = "true" ]]; then
echo "OFFLINE_MODE is \"true\". Skipping Linux package updates on first run."
else
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
bash /opt/scripts/setup_packages.sh -update
fi
echo ' '
# Installing packages from ENV

View File

@@ -10,7 +10,7 @@ then
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..."
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
@@ -24,10 +24,20 @@ then
echo "$i is already installed."
fi
done
elif [ "$1" == "-update" ]
then
apt-get -q update
apt-get -q -y upgrade
elif [ "$1" == "-update" ]; then
echo -n "Updating Linux packages on first run... "
apt-get -q update >> /opt/scripts/setup_packages.log 2>&1
return=$?
apt-get -q -y upgrade >> /opt/scripts/setup_packages.log 2>&1
return1=$?
if [[ "$return" -ne 0 || "$return1" -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
else
echo "No paramerter found!"
exit 1