Userdata starage fix

This commit is contained in:
Andrei Smaliak 2026-06-10 08:22:10 +04:00
parent 3f613e9851
commit e915a950cf
2 changed files with 258 additions and 211 deletions

View File

@ -126,6 +126,7 @@ apt_repair_state() {
dpkg --audit >>"$LOG" 2>&1 || true dpkg --audit >>"$LOG" 2>&1 || true
if ! run_long "DPKG configure pending packages" 1800 \ if ! run_long "DPKG configure pending packages" 1800 \
/usr/bin/env DEBIAN_FRONTEND=noninteractive \
/usr/bin/dpkg --configure -a; then /usr/bin/dpkg --configure -a; then
rc=1 rc=1
fi fi
@ -153,6 +154,7 @@ apt_install_missing() {
local missing=() local missing=()
local failed=() local failed=()
local pkg local pkg
local installed_any=0
for pkg in "${pkgs[@]}"; do for pkg in "${pkgs[@]}"; do
if ! package_installed "$pkg"; then if ! package_installed "$pkg"; then
@ -168,29 +170,16 @@ apt_install_missing() {
log "Missing packages: ${missing[*]}" log "Missing packages: ${missing[*]}"
if ! apt_repair_state; then if ! apt_repair_state; then
log "APT/DPKG repair preflight reported issues; continuing with install" log "APT/DPKG repair preflight failed; refusing to install packages on an unsafe dpkg state"
echo "[!] APT/DPKG repair preflight reported issues; continuing (see $LOG)" echo "[!] APT/DPKG repair preflight failed; refusing to continue package install (see $LOG)"
return 1
fi fi
apt_update_if_needed apt_update_if_needed
if run_long "Install packages" 1800 \
/usr/bin/env DEBIAN_FRONTEND=noninteractive \
/usr/bin/apt-get -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
install "${missing[@]}"; then
return 0
fi
log "Bulk package install failed; repairing APT/DPKG state and retrying packages one by one"
echo "[!] Bulk package install failed; retrying packages one by one (see $LOG)"
apt_repair_state || true
for pkg in "${missing[@]}"; do for pkg in "${missing[@]}"; do
if package_installed "$pkg"; then if package_installed "$pkg"; then
log "Package installed during bulk attempt: $pkg" log "Package already installed before one-by-one attempt: $pkg"
continue continue
fi fi
@ -200,20 +189,35 @@ apt_install_missing() {
-o Dpkg::Options::="--force-confdef" \ -o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \ -o Dpkg::Options::="--force-confold" \
install "$pkg"; then install "$pkg"; then
installed_any=1
sync || true
if ! apt_repair_state; then
log "APT/DPKG repair failed after installing package: $pkg"
echo "[!] APT/DPKG repair failed after installing package: $pkg (see $LOG)"
return 1
fi
continue continue
fi fi
failed+=("$pkg") failed+=("$pkg")
apt_repair_state || true if ! apt_repair_state; then
log "APT/DPKG repair failed after package failure: $pkg"
echo "[!] APT/DPKG repair failed after package failure: $pkg (see $LOG)"
return 1
fi
done done
if [ "${#failed[@]}" -eq 0 ]; then if [ "${#failed[@]}" -eq 0 ]; then
log "Packages installed after one-by-one retry: ${missing[*]}" if [ "$installed_any" -eq 1 ]; then
log "Packages installed one by one: ${missing[*]}"
else
log "Packages already installed after preflight: ${missing[*]}"
fi
return 0 return 0
fi fi
log "Failed packages after one-by-one retry: ${failed[*]}" log "Failed packages after one-by-one install: ${failed[*]}"
echo "[!] Failed packages after one-by-one retry: ${failed[*]} (see $LOG)" echo "[!] Failed packages after one-by-one install: ${failed[*]} (see $LOG)"
return 1 return 1
} }
@ -256,48 +260,201 @@ apt_install_optional() {
done done
} }
migrate_pcp_logs_to_userdata() { keep_pcp_logs_on_root() {
local target="/userdata/pcp"
local current_target="" local current_target=""
local backup_path=""
local ts=""
if ! mountpoint -q /userdata; then systemctl_disable_now_safe iomatex-pcp-maintenance.timer iomatex-pcp-maintenance.service
log "SKIP: /userdata is not mounted; keeping PCP logs at /var/log/pcp" systemctl_disable_now_safe pmie pmlogger pmproxy
return 0
fi
mkdir -p "$target"
if [ -L /var/log/pcp ]; then if [ -L /var/log/pcp ]; then
current_target="$(readlink /var/log/pcp || true)" current_target="$(readlink /var/log/pcp || true)"
if [ "$current_target" != "$target" ]; then if [ "$current_target" = "/userdata/pcp" ]; then
log "WARN: /var/log/pcp is already a symlink to ${current_target}; expected ${target}" rm -f /var/log/pcp
return 0 mkdir -p /var/log/pcp
log "Restored /var/log/pcp as a local directory; PCP logs are not kept on /userdata"
fi fi
chown -R pcp:pcp "$target" 2>/dev/null || true fi
mkdir -p /var/log/pcp
chown -R pcp:pcp /var/log/pcp 2>/dev/null || true
}
disable_userdata_swap() {
if swapon --show=NAME 2>/dev/null | awk '{print $1}' | grep -qx /userdata/swapfile; then
swapoff /userdata/swapfile >/dev/null 2>&1 || true
log "Disabled active /userdata/swapfile"
fi
if [ -f /userdata/swapfile ]; then
rm -f /userdata/swapfile 2>/dev/null || true
log "Removed /userdata/swapfile"
fi
}
ensure_userdata_fstab_nonblocking() {
local tmp
[ -f /etc/fstab ] || return 0
if ! awk '$1 !~ /^#/ && $2 == "/userdata" { found=1 } END { exit found ? 0 : 1 }' /etc/fstab; then
return 0 return 0
fi fi
systemctl_disable_now_safe pmcd pmie pmlogger pmproxy backup_if_exists /etc/fstab
tmp="$(mktemp)"
set +e
awk '
BEGIN { changed=0 }
$1 ~ /^#/ || $2 != "/userdata" { print; next }
{
split($4, opts, ",")
has_nofail=0
has_timeout=0
for (i in opts) {
if (opts[i] == "nofail") has_nofail=1
if (opts[i] ~ /^x-systemd.device-timeout=/) has_timeout=1
}
if (!has_nofail) {
$4 = ($4 == "defaults" ? "defaults,nofail" : $4 ",nofail")
changed=1
}
if (!has_timeout) {
$4 = $4 ",x-systemd.device-timeout=5s"
changed=1
}
if ($6 != "0") {
$6 = "0"
changed=1
}
print
}
END { if (changed) exit 2 }
' /etc/fstab >"$tmp"
local awk_rc=$?
set -e
case "$awk_rc" in
0)
rm -f "$tmp"
;;
2)
install -m 0644 -o root -g root "$tmp" /etc/fstab
rm -f "$tmp"
log "Updated /etc/fstab: /userdata is non-blocking for cold boot"
;;
*)
rm -f "$tmp"
log "WARN: unable to normalize /etc/fstab /userdata entry"
return 0
;;
esac
}
if [ -d /var/log/pcp ]; then append_kernel_args_to_file() {
rsync -aHAX --numeric-ids /var/log/pcp/ "$target"/ local path="$1"
ts="$(date -u +%Y%m%d%H%M%S)" local tmp
backup_path="/var/log/pcp.bak.${ts}" local changed=0
mv /var/log/pcp "$backup_path"
log "Migrated /var/log/pcp to ${target}; backup: ${backup_path}" [ -f "$path" ] || return 0
backup_if_exists "$path"
tmp="$(mktemp)"
set +e
case "$path" in
*/extlinux.conf)
awk '
/^[[:space:]]*APPEND[[:space:]]/ {
if ($0 !~ /(^|[[:space:]])fsck\.repair=/) {
$0 = $0 " fsck.repair=yes"
changed=1
}
if ($0 !~ /(^|[[:space:]])fsck\.mode=/) {
$0 = $0 " fsck.mode=auto"
changed=1
}
}
{ print }
END { if (changed) exit 2 }
' "$path" >"$tmp"
;;
*/armbianEnv.txt|*/orangepiEnv.txt)
awk '
BEGIN { seen=0; changed=0 }
/^extraargs=/ {
seen=1
if ($0 !~ /(^|[[:space:]])fsck\.repair=/) {
$0 = $0 " fsck.repair=yes"
changed=1
}
if ($0 !~ /(^|[[:space:]])fsck\.mode=/) {
$0 = $0 " fsck.mode=auto"
changed=1
}
}
{ print }
END {
if (!seen) {
print "extraargs=fsck.repair=yes fsck.mode=auto"
changed=1
}
if (changed) exit 2
}
' "$path" >"$tmp"
;;
*)
set -e
rm -f "$tmp"
return 0
;;
esac
local awk_rc=$?
set -e
case "$awk_rc" in
0)
rm -f "$tmp"
;;
2)
install -m 0644 -o root -g root "$tmp" "$path"
rm -f "$tmp"
log "Updated boot fsck args in ${path}"
changed=1
;;
*)
rm -f "$tmp"
log "WARN: unable to update boot fsck args in ${path}"
;;
esac
return 0
}
configure_cold_boot_fsck_repair() {
local rc_file="/etc/default/rcS"
if [ -f "$rc_file" ]; then
backup_if_exists "$rc_file"
if grep -qE '^[[:space:]]*FSCKFIX=' "$rc_file"; then
sed -i -E 's/^[[:space:]]*FSCKFIX=.*/FSCKFIX=yes/' "$rc_file"
else else
rm -f /var/log/pcp 2>/dev/null || true printf '\nFSCKFIX=yes\n' >>"$rc_file"
fi
else
printf 'FSCKFIX=yes\n' >"$rc_file"
chmod 0644 "$rc_file"
fi fi
ln -s "$target" /var/log/pcp mkdir -p /etc/default/grub.d
chown -R pcp:pcp "$target" 2>/dev/null || true write_if_changed /etc/default/grub.d/99-iomatex-fsck.cfg 0644 <<'EOF'
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} fsck.repair=yes fsck.mode=auto"
EOF
if have update-grub; then
soft_run "Update GRUB fsck policy" 120 /usr/sbin/update-grub
fi
systemctl_enable_now_safe pmcd append_kernel_args_to_file /boot/extlinux/extlinux.conf
systemctl_enable_now_safe pmie append_kernel_args_to_file /boot/armbianEnv.txt
systemctl_enable_now_safe pmlogger append_kernel_args_to_file /boot/orangepiEnv.txt
systemctl_enable_now_safe pmproxy
log "Cold-boot fsck auto-repair policy ensured"
} }
apt_remove_if_installed() { apt_remove_if_installed() {
@ -502,63 +659,13 @@ run_long() {
local msg="$1" local msg="$1"
local timeout_s="$2" local timeout_s="$2"
local rc local rc
local pid
local spin='|/-\'
local i=0
local start_ts=0
local elapsed=0
local last_heartbeat=0
local spinner_tty=0
local spinner_tty_path=""
local timed_out=0
shift 2 shift 2
log "RUN: $msg :: $*" log "RUN: $msg :: $*"
( "$@" >>"$LOG" 2>&1 ) & ( timeout --kill-after=10s "$timeout_s" "$@" >>"$LOG" 2>&1 ) &
pid=$! local pid=$!
start_ts="$(date +%s)" spinner "$pid" "$msg"
spinner_tty_path="$(tty 2>/dev/null || true)"
if [[ -n "$spinner_tty_path" && "$spinner_tty_path" != "not a tty" && -w "$spinner_tty_path" ]]; then
spinner_tty=1
fi
if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then
tput civis >"$spinner_tty_path" 2>/dev/null || true
fi
while kill -0 "$pid" 2>/dev/null; do
i=$(((i + 1) % 4))
elapsed=$(( $(date +%s) - start_ts ))
if [[ "$spinner_tty" -eq 1 ]]; then
printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >"$spinner_tty_path"
fi
if (( elapsed >= last_heartbeat + 15 )); then
log "HEARTBEAT: ${msg} still running (${elapsed}s)"
last_heartbeat="$elapsed"
fi
if (( timeout_s > 0 && elapsed >= timeout_s )); then
timed_out=1
log "TIMEOUT(${timeout_s}s): ${msg}; terminating pid=${pid}"
kill "$pid" >/dev/null 2>&1 || true
sleep 2
kill -9 "$pid" >/dev/null 2>&1 || true
break
fi
sleep 0.2
done
if [[ "$spinner_tty" -eq 1 ]]; then
printf "\r%-80s\r" "" >"$spinner_tty_path"
fi
if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then
tput cnorm >"$spinner_tty_path" 2>/dev/null || true
fi
if wait "$pid"; then if wait "$pid"; then
rc=0 rc=0
@ -566,10 +673,6 @@ run_long() {
rc=$? rc=$?
fi fi
if [ "$timed_out" -eq 1 ]; then
rc=124
fi
if [ "$rc" -eq 0 ]; then if [ "$rc" -eq 0 ]; then
log "OK: $msg" log "OK: $msg"
echo "[OK] $msg" echo "[OK] $msg"
@ -593,6 +696,11 @@ soft_run() {
fi fi
} }
flush_filesystems() {
log "Sync filesystems before script exit"
sync || true
}
# --- root --- # --- root ---
if [ "${EUID:-$(id -u)}" -ne 0 ]; then if [ "${EUID:-$(id -u)}" -ne 0 ]; then
if [ -x /usr/bin/sudo ]; then if [ -x /usr/bin/sudo ]; then
@ -610,6 +718,14 @@ if grep -q $'\r' "$0"; then
exit 1 exit 1
fi fi
if ! have timeout; then
log "ERROR: Required command not found: timeout"
echo "[!] ERROR: Required command not found: timeout"
exit 1
fi
trap flush_filesystems EXIT
log "=== IOMATEX EDGE :: STAGE_ENV START (Debian 11) ===" log "=== IOMATEX EDGE :: STAGE_ENV START (Debian 11) ==="
log "LOG: $LOG" log "LOG: $LOG"
@ -651,8 +767,9 @@ log "APT policy: vendor list and deb822 sources removed"
# ------------------------- # -------------------------
step "APT/DPKG repair preflight" step "APT/DPKG repair preflight"
if ! apt_repair_state; then if ! apt_repair_state; then
log "APT/DPKG repair preflight reported issues before update; continuing" log "ERROR: APT/DPKG repair preflight failed before update; stop to avoid unsafe package state"
echo "[!] APT/DPKG repair preflight reported issues before update (see $LOG)" echo "[!] ERROR: APT/DPKG repair preflight failed before update. Stop and inspect $LOG"
exit 1
fi fi
step "APT update" step "APT update"
@ -661,20 +778,16 @@ apt_update_if_needed
# ------------------------- # -------------------------
# Step 4: Base tools (nano mandatory early) # Step 4: Base tools (nano mandatory early)
# ------------------------- # -------------------------
step "Install base tools (nano mandatory early) + checkinstall" step "Install base system tools (one by one)"
apt_install_missing \ apt_install_missing \
ca-certificates curl wget sudo \ ca-certificates curl wget sudo \
openssh-server \ openssh-server \
iproute2 net-tools \ iproute2 net-tools \
tzdata \ tzdata \
htop mc \
nano \ nano \
rsync \ rsync \
checkinstall \ xz-utils unzip \
xz-utils unzip git \
jq \
procps \ procps \
dos2unix \
logrotate \ logrotate \
rsyslog \ rsyslog \
network-manager \ network-manager \
@ -683,6 +796,8 @@ apt_install_missing \
pulseaudio-utils \ pulseaudio-utils \
alsa-utils alsa-utils
apt_install_optional htop mc checkinstall git jq dos2unix
step "Install mbpoll" step "Install mbpoll"
install_mbpoll install_mbpoll
@ -871,8 +986,8 @@ ensure_edge_name
# ------------------------- # -------------------------
step "Install + enable Cockpit baseline + security reminder" step "Install + enable Cockpit baseline + security reminder"
apt_install_missing cockpit network-manager apt_install_missing cockpit network-manager
apt_install_optional cockpit-networkmanager cockpit-storaged cockpit-pcp apt_install_optional cockpit-networkmanager cockpit-storaged
migrate_pcp_logs_to_userdata keep_pcp_logs_on_root
systemctl_enable_now_safe NetworkManager systemctl_enable_now_safe NetworkManager
IP_MAIN="$(main_ipv4)" IP_MAIN="$(main_ipv4)"
@ -928,11 +1043,16 @@ EOF
# Step 11: /userdata usage (SAFE cold-boot) # Step 11: /userdata usage (SAFE cold-boot)
# - NO bind-mount /var/log # - NO bind-mount /var/log
# - NO fstab entries that can block boot # - NO fstab entries that can block boot
# - swap + generic app logs are enabled via systemd oneshot after /userdata is mounted # - /userdata is treated as optional for boot
# - NO swap on /userdata; hard power cuts can make that partition block boot on fsck
# - generic app log directory is created only when /userdata is already mounted
# ------------------------- # -------------------------
step "Userdata SAFE: systemd bootstrap (swap on /userdata + generic logs) + log overflow protection" step "Userdata SAFE: non-blocking mount + generic logs + log overflow protection"
mkdir -p /etc/systemd/system /usr/local/sbin mkdir -p /etc/systemd/system /usr/local/sbin
configure_cold_boot_fsck_repair
ensure_userdata_fstab_nonblocking
disable_userdata_swap
write_if_changed /usr/local/sbin/iomatex-userdata-bootstrap 0755 <<'EOF' write_if_changed /usr/local/sbin/iomatex-userdata-bootstrap 0755 <<'EOF'
#!/usr/bin/env bash #!/usr/bin/env bash
@ -946,38 +1066,17 @@ if ! mountpoint -q /userdata; then
exit 0 exit 0
fi fi
# 1) Swap on /userdata (no /etc/fstab usage) # Generic app log root on /userdata (apps may opt in later)
SWAPFILE="/userdata/swapfile"
if command -v swapon >/dev/null 2>&1; then
if ! swapon --show=NAME | awk '{print $1}' | grep -qx "$SWAPFILE"; then
if [ ! -f "$SWAPFILE" ]; then
log "Create swapfile: $SWAPFILE (1024M)"
( command -v fallocate >/dev/null 2>&1 && fallocate -l 1024M "$SWAPFILE" ) || dd if=/dev/zero of="$SWAPFILE" bs=1M count=1024 status=none
chmod 600 "$SWAPFILE"
mkswap "$SWAPFILE" >/dev/null
else
chmod 600 "$SWAPFILE" || true
file "$SWAPFILE" | grep -qi "swap file" || mkswap "$SWAPFILE" >/dev/null
fi
swapon "$SWAPFILE" || true
fi
fi
# swappiness (harmless if already set)
echo "vm.swappiness=10" >/etc/sysctl.d/99-iomatex-swap.conf
sysctl -p /etc/sysctl.d/99-iomatex-swap.conf >/dev/null 2>&1 || true
# 2) Generic app log root on /userdata (apps may opt in later)
mkdir -p /userdata/logs/iomatex mkdir -p /userdata/logs/iomatex
log "OK: swap + generic userdata log root configured (cold-boot safe)" log "OK: generic userdata log root configured"
exit 0 exit 0
EOF EOF
USERDATA_UNIT_CHANGED=0 USERDATA_UNIT_CHANGED=0
write_if_changed /etc/systemd/system/iomatex-userdata-bootstrap.service 0644 <<'EOF' write_if_changed /etc/systemd/system/iomatex-userdata-bootstrap.service 0644 <<'EOF'
[Unit] [Unit]
Description=IOMATEX userdata bootstrap (swap + persistent logs) - cold-boot safe Description=IOMATEX userdata bootstrap (persistent log directory) - cold-boot safe
After=local-fs.target After=local-fs.target
Wants=local-fs.target Wants=local-fs.target
ConditionPathIsDirectory=/userdata ConditionPathIsDirectory=/userdata
@ -1253,9 +1352,6 @@ fi
soft_run "Enable iomatex-log-watchdog.timer" 20 /bin/systemctl enable --now iomatex-log-watchdog.timer soft_run "Enable iomatex-log-watchdog.timer" 20 /bin/systemctl enable --now iomatex-log-watchdog.timer
soft_run "Run iomatex-log-watchdog once (best-effort)" 30 /bin/systemctl start iomatex-log-watchdog.service soft_run "Run iomatex-log-watchdog once (best-effort)" 30 /bin/systemctl start iomatex-log-watchdog.service
soft_run "Enable iomatex-pcp-maintenance.timer" 20 /bin/systemctl enable --now iomatex-pcp-maintenance.timer
soft_run "Run PCP archive maintenance once (best-effort)" 300 /bin/systemctl start iomatex-pcp-maintenance.service
if [ "$MOSQ_LOG_CFG_CHANGED" -eq 1 ]; then if [ "$MOSQ_LOG_CFG_CHANGED" -eq 1 ]; then
soft_run "Restart mosquitto (production logging baseline)" 30 /bin/systemctl restart mosquitto soft_run "Restart mosquitto (production logging baseline)" 30 /bin/systemctl restart mosquitto
fi fi
@ -1298,8 +1394,9 @@ echo
echo " Password policy : minlen=8 (NO dictionary), pam_unix obscure OFF" echo " Password policy : minlen=8 (NO dictionary), pam_unix obscure OFF"
echo echo
echo " Userdata usage (cold-boot safe):" echo " Userdata usage (cold-boot safe):"
echo " - swap on /userdata via systemd oneshot (no fstab)" echo " - /userdata fstab entry is non-blocking when present"
echo " - generic userdata log root at /userdata/logs/iomatex" echo " - no swap on /userdata"
echo " - generic userdata log root at /userdata/logs/iomatex when mounted"
echo echo
echo " Network IPs:" echo " Network IPs:"
ip -4 addr show | awk '/inet /{print " - " $2 " (" $NF ")"}' || true ip -4 addr show | awk '/inet /{print " - " $2 " (" $NF ")"}' || true

View File

@ -226,79 +226,22 @@ run_long() {
local msg="$1" local msg="$1"
local timeout_s="$2" local timeout_s="$2"
local rc local rc
local pid
local spin='|/-\\'
local i=0
local start_ts=0
local elapsed=0
local last_heartbeat=0
local spinner_tty=0
local spinner_tty_path=""
local timed_out=0
shift 2 shift 2
log "RUN: $msg :: $*" log "RUN: $msg :: $*"
( timeout --kill-after=10s "$timeout_s" "$@" >>"$LOG" 2>&1 ) &
( "$@" >>"$LOG" 2>&1 ) & local pid=$!
pid=$! spinner "$pid" "$msg"
start_ts="$(date +%s)"
spinner_tty_path="$(tty 2>/dev/null || true)"
if [[ -n "$spinner_tty_path" && "$spinner_tty_path" != "not a tty" && -w "$spinner_tty_path" ]]; then
spinner_tty=1
fi
if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then
tput civis >"$spinner_tty_path" 2>/dev/null || true
fi
while kill -0 "$pid" 2>/dev/null; do
i=$(((i + 1) % 4))
elapsed=$(( $(date +%s) - start_ts ))
if [[ "$spinner_tty" -eq 1 ]]; then
printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >"$spinner_tty_path"
fi
if (( elapsed >= last_heartbeat + 15 )); then
log "HEARTBEAT: ${msg} still running (${elapsed}s)"
last_heartbeat="$elapsed"
fi
if (( timeout_s > 0 && elapsed >= timeout_s )); then
timed_out=1
log "TIMEOUT(${timeout_s}s): ${msg}; terminating pid=${pid}"
kill "$pid" >/dev/null 2>&1 || true
sleep 2
kill -9 "$pid" >/dev/null 2>&1 || true
break
fi
sleep 0.2
done
if [[ "$spinner_tty" -eq 1 ]]; then
printf "\r%-80s\r" "" >"$spinner_tty_path"
fi
if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then
tput cnorm >"$spinner_tty_path" 2>/dev/null || true
fi
wait "$pid" wait "$pid"
rc=$? rc=$?
if [[ "$timed_out" -eq 1 ]]; then
rc=124
fi
if [[ "$rc" -eq 0 ]]; then if [[ "$rc" -eq 0 ]]; then
if [[ "$spinner_tty" -eq 1 ]]; then if [[ -t 1 ]]; then
printf "\r[OK] %s. \n" "$msg" >"$spinner_tty_path" printf "\r[OK] %s. \n" "$msg"
else else
echo "[OK] $msg" echo "[OK] $msg"
fi fi
else else
if [[ "$spinner_tty" -eq 1 ]]; then if [[ -t 1 ]]; then
printf "\r[FAIL:%s] %s. \n" "$rc" "$msg" >"$spinner_tty_path" printf "\r[FAIL:%s] %s. \n" "$rc" "$msg"
else else
echo "[FAIL:$rc] $msg" echo "[FAIL:$rc] $msg"
fi fi
@ -374,6 +317,7 @@ install_base_packages() {
require_cmd apt-get require_cmd apt-get
require_cmd install require_cmd install
require_cmd timeout
require_cmd flock require_cmd flock
require_cmd systemctl require_cmd systemctl
require_cmd visudo require_cmd visudo
@ -1500,6 +1444,11 @@ post_install_self_test() {
fi fi
} }
flush_filesystems() {
log "Sync filesystems before installer exit"
sync
}
print_summary() { print_summary() {
echo echo
echo "Stage_3 ready (dedicated X11 appliance mode)." echo "Stage_3 ready (dedicated X11 appliance mode)."
@ -1579,6 +1528,7 @@ main() {
install_systemd_unit install_systemd_unit
enable_managed_services enable_managed_services
post_install_self_test post_install_self_test
flush_filesystems
print_summary print_summary
} }