Skip to content

Commit 9981313

Browse files
Rework error handeling (#2377)
1 parent 21a29d7 commit 9981313

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

.github/workflows/scripts/app-test/pr-build.func

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ http://dl-cdn.alpinelinux.org/alpine/latest-stable/community
250250
EOF'
251251
pct exec "$CTID" -- ash -c "apk add bash >/dev/null"
252252
fi
253-
lxc-attach -n "$CTID" -- bash -c "$(< /root/actions-runner/_work/ProxmoxVE/ProxmoxVE/install/$var_install.sh)"
253+
lxc-attach -n "$CTID" -- bash -c "$(cat /root/actions-runner/_work/ProxmoxVE/ProxmoxVE/install/$var_install.sh)" $var_install.sh
254254

255255
}
256256

.github/workflows/scripts/app-test/pr-install.func

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
#!/usr/bin/env bash
22
# Copyright (c) 2021-2025 community-scripts ORG
3-
# Author: Michel Roegl-Brunner (michelroegl-brunner)
3+
# Author: michelroegl-brunner
44
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
55

66
color() {
77
return
88
}
9+
10+
SCRIPT_NAME="${BASH_SOURCE[0]:-unknown_script}"
911
catch_errors() {
10-
set -Eeuo pipefail
12+
set -Euoe pipefail
1113
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
1214
}
1315

14-
1516
error_handler() {
1617
local line_number="$1"
1718
local command="$2"
18-
SCRIPT_NAME=$(basename "$0")
19-
local error_message="$SCRIPT_NAME: Failure in line $line_number while executing command $command"
19+
local error_message="$SCRIPT_NAME: Failure in line $line_number while executing command '$command'"
2020
echo -e "\n$error_message"
21-
exit 200
21+
exit 300
2222
}
23+
2324
verb_ip6() {
24-
STD=""
25-
return
25+
STD="silent"
26+
silent() {
27+
"$@" >/dev/null 2>&1 || error_handler "${BASH_LINENO[0]}" "$*"
28+
}
2629
}
2730

2831
msg_info() {
@@ -40,11 +43,9 @@ msg_error() {
4043
local msg="$1"
4144
echo -e "${msg}\n"
4245
}
43-
44-
RETRY_NUM=10
45-
RETRY_EVERY=3
46+
RETRY_NUM=10
47+
RETRY_EVERY=3
4648
setting_up_container() {
47-
4849
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
4950
locale_line=$(grep -v '^#' /etc/locale.gen | grep -E '^[a-zA-Z]' | awk '{print $1}' | head -n 1)
5051
echo "LANG=${locale_line}" >/etc/default/locale
@@ -57,6 +58,7 @@ setting_up_container() {
5758
if [ "$(hostname -I)" != "" ]; then
5859
break
5960
fi
61+
echo 1>&2 -en "No Network! "
6062
sleep $RETRY_EVERY
6163
done
6264
if [ "$(hostname -I)" = "" ]; then
@@ -66,6 +68,8 @@ setting_up_container() {
6668
fi
6769
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
6870
systemctl disable -q --now systemd-networkd-wait-online.service
71+
msg_ok "Set up Container OS"
72+
msg_ok "Network Connected: $(hostname -I)"
6973
}
7074

7175
network_check() {
@@ -75,10 +79,11 @@ network_check() {
7579
}
7680

7781
update_os() {
78-
export DEBIAN_FRONTEND=noninteractive
79-
apt-get update >/dev/null 2>&1
80-
apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade >/dev/null 2>&1
81-
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
82+
msg_info "Updating Container OS"
83+
apt-get update
84+
apt-get -o Dpkg::Options::="--force-confold" -y dist-upgrade
85+
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
86+
msg_ok "Updated Container OS"
8287
}
8388

8489
motd_ssh() {
@@ -87,6 +92,4 @@ motd_ssh() {
8792

8893
customize() {
8994
return
90-
}
91-
92-
95+
}

0 commit comments

Comments
 (0)