Skip to content

Commit 289a8cd

Browse files
authored
Merge pull request #732 from dappnode/marc/fix-console-setup-firstboot
fix: prevent console-setup from blocking first boot
2 parents 2ffa927 + fa7c249 commit 289a8cd

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

scripts/dappnode_install.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,9 @@ main() {
11981198
# Run test in interactive terminal (first boot only)
11991199
if [ -f "${DAPPNODE_DIR}/.firstboot" ]; then
12001200
apt-get update
1201-
apt-get install -y kbd
1201+
# A package upgrade may leave console-setup pending configuration.
1202+
# Never let debconf open a hidden prompt while rc.local owns tty1.
1203+
DEBIAN_FRONTEND=noninteractive apt-get install -y kbd
12021204
openvt -s -w -- sudo -u root "${DAPPNODE_DIR}/scripts/dappnode_test_install.sh"
12031205
exit 0
12041206
fi

scripts/dappnode_install_pre.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
# Execute script with flag UPDATE to update the host: ./dappnode_install_pre.sh UPDATE
44

5+
# This script also runs from unattended ISO late-commands, where debconf has no
6+
# terminal on which it can safely ask package-configuration questions.
7+
export DEBIAN_FRONTEND=noninteractive
8+
59
DAPPNODE_DIR="/usr/src/dappnode"
610
LOGS_DIR="$DAPPNODE_DIR/logs"
711
lsb_dist="$(. /etc/os-release && echo "$ID")"
@@ -105,8 +109,10 @@ install_iptables() {
105109

106110
# HOST UPDATE
107111
host_update() {
108-
apt-get update 2>&1 | tee -a $LOG_FILE
109-
apt-get -y upgrade 2>&1 | tee -a $LOG_FILE
112+
# Process substitution keeps apt-get's exit status while still logging its
113+
# output. A regular pipeline would return tee's status and hide dpkg errors.
114+
apt-get update > >(tee -a "$LOG_FILE") 2>&1 || return $?
115+
apt-get -y upgrade > >(tee -a "$LOG_FILE") 2>&1
110116
}
111117

112118
check_ubuntu_connectivity() {
@@ -152,7 +158,10 @@ touch $LOG_FILE
152158
# Only update && upgrade host if needed
153159
if [ "$1" == "UPDATE" ]; then
154160
echo -e "\e[32m \n\n Updating && upgrading host \n\n \e[0m" 2>&1 | tee -a $LOG_FILE
155-
host_update 2>&1 | tee -a $LOG_FILE
161+
if ! host_update; then
162+
echo -e "\e[31m \n\n ERROR: host update failed \n\n \e[0m" 2>&1 | tee -a "$LOG_FILE"
163+
exit 1
164+
fi
156165
fi
157166

158167
if find /etc/apt/ -name "*.list" -print0 | xargs --null cat | grep -q "https://download.docker.com/linux/$lsb_dist"; then

0 commit comments

Comments
 (0)