|
2 | 2 |
|
3 | 3 | # Execute script with flag UPDATE to update the host: ./dappnode_install_pre.sh UPDATE |
4 | 4 |
|
| 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 | + |
5 | 9 | DAPPNODE_DIR="/usr/src/dappnode" |
6 | 10 | LOGS_DIR="$DAPPNODE_DIR/logs" |
7 | 11 | lsb_dist="$(. /etc/os-release && echo "$ID")" |
@@ -105,8 +109,10 @@ install_iptables() { |
105 | 109 |
|
106 | 110 | # HOST UPDATE |
107 | 111 | 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 |
110 | 116 | } |
111 | 117 |
|
112 | 118 | check_ubuntu_connectivity() { |
@@ -152,7 +158,10 @@ touch $LOG_FILE |
152 | 158 | # Only update && upgrade host if needed |
153 | 159 | if [ "$1" == "UPDATE" ]; then |
154 | 160 | 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 |
156 | 165 | fi |
157 | 166 |
|
158 | 167 | if find /etc/apt/ -name "*.list" -print0 | xargs --null cat | grep -q "https://download.docker.com/linux/$lsb_dist"; then |
|
0 commit comments