#!/bin/bash set -uo pipefail NAPLO=/var/log/raveos-telepito-frissites.log CSOMAGOK=(calamares raveos-calamares-module raveos-calamares-theme) MENTES=/tmp/calamares-elozo.tar LISTA=/tmp/calamares-elozo.lista REPOCONF=/tmp/raveos-csak-repo.conf ZOLD=$'\e[38;2;106;168;79m' HALVANY=$'\e[38;2;140;150;158m' SARGA=$'\e[38;2;214;158;46m' ALAP=$'\e[0m' exec 3>&1 exec >>"$NAPLO" 2>&1 echo "== RaveOS installer update: $(date)" kiir() { printf '%s\n' "$2" printf ' %s%s%s\n' "$1" "$2" "$ALAP" >&3 } printf '\e[?25l\n %sRaveOS Installer%s\n %sChecking for the latest installer version%s\n\n' "$ZOLD" "$ALAP" "$HALVANY" "$ALAP" >&3 van_net() { curl -fsI --max-time 6 https://page.rp1.hu/x86_64/ >/dev/null || curl -fsI --max-time 6 https://rp1.hu/ >/dev/null } kiir "$HALVANY" "Checking internet connection..." for _ in $(seq 1 10); do van_net && break sleep 2 done if ! van_net; then kiir "$SARGA" "No internet connection. Choose a Wi-Fi network from the list (Esc: skip)." sleep 2 printf '\e[?25h' >&3 nmtui-connect /dev/tty 2>&1 printf '\e[?25l\e[2J\e[H\n' >&3 for _ in $(seq 1 10); do van_net && break sleep 2 done fi if ! van_net; then kiir "$SARGA" "No internet connection, starting the installer as is." sleep 2 exit 0 fi for _ in $(seq 1 60); do systemctl is-active --quiet pacman-init.service && break sleep 1 done sed -n '1,/^\[core\]/p' /etc/pacman.conf | sed '$d' > "$REPOCONF" kiir "$HALVANY" "Checking for updates..." if ! timeout 60 pacman --config "$REPOCONF" --noprogressbar -Sy; then kiir "$SARGA" "The RaveOS repository is not reachable, starting the installer as is." sleep 2 exit 0 fi FRISS=$(pacman --config "$REPOCONF" -Qu "${CSOMAGOK[@]}" 2>/dev/null) if [ -z "$FRISS" ]; then kiir "$ZOLD" "The installer is up to date." sleep 1 exit 0 fi echo "Available updates:" echo "$FRISS" kiir "$HALVANY" "Installing update:" while IFS= read -r sor; do kiir "$HALVANY" " $sor" done <<< "$FRISS" { pacman -Qlq "${CSOMAGOK[@]}" | grep -v '/$' for cs in "${CSOMAGOK[@]}"; do ls -d /var/lib/pacman/local/"$cs"-[0-9]* 2>/dev/null done } | sed 's#^/##' | sort > "$LISTA" tar -cf "$MENTES" -C / -T "$LISTA" 2>/dev/null visszaallit() { kiir "$SARGA" "$1" rm -f /var/lib/pacman/db.lck pacman -Qlq "${CSOMAGOK[@]}" 2>/dev/null | grep -v '/$' | sed 's#^/##' | sort > "$LISTA.uj" comm -13 "$LISTA" "$LISTA.uj" | while IFS= read -r f; do rm -f "/$f"; done for cs in "${CSOMAGOK[@]}"; do rm -rf /var/lib/pacman/local/"$cs"-[0-9]* done tar -xf "$MENTES" -C / sleep 3 exit 0 } if ! timeout 180 pacman --config "$REPOCONF" --noprogressbar -S --needed --noconfirm "${CSOMAGOK[@]}"; then visszaallit "The update failed, starting the installer as is." fi if ldd /usr/bin/calamares /usr/lib/libcalamares*.so* /usr/lib/calamares/modules/*/*.so 2>&1 | grep -q "not found"; then visszaallit "The new installer is missing a library, starting the previous version." fi kiir "$ZOLD" "The installer has been updated." sleep 1