diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index cda3820..393f6ab 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -208,12 +208,16 @@ function install_crowsnest_dependencies() { echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' read -r -a packages <<< "${packages}" - ### Update system package info + ### Update system package info if lists > 3 days old status_msg "Updating package lists..." - if ! sudo apt-get update --allow-releaseinfo-change; then - log_error "failure while updating package lists" - error_msg "Updating package lists failed!" - exit 1 + if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -3)" ]]; then + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + else + status_msg "Package lists updated recently, skipping..." fi ### Install required packages diff --git a/scripts/klipper.sh b/scripts/klipper.sh index 66126b4..ca489fb 100644 --- a/scripts/klipper.sh +++ b/scripts/klipper.sh @@ -321,12 +321,16 @@ function install_klipper_packages() { echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' read -r -a packages <<< "${packages}" - ### Update system package info + ### Update system package info if lists > 3 days old status_msg "Updating package lists..." - if ! sudo apt-get update --allow-releaseinfo-change; then - log_error "failure while updating package lists" - error_msg "Updating package lists failed!" - exit 1 + if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -3)" ]]; then + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + else + status_msg "Package lists updated recently, skipping..." fi ### Install required packages diff --git a/scripts/moonraker-telegram-bot.sh b/scripts/moonraker-telegram-bot.sh index 7aab1e9..ee0520f 100644 --- a/scripts/moonraker-telegram-bot.sh +++ b/scripts/moonraker-telegram-bot.sh @@ -121,12 +121,16 @@ function install_telegram_bot_dependencies() { echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' read -r -a packages <<< "${packages}" - ### Update system package info + ### Update system package info if lists > 3 days old status_msg "Updating package lists..." - if ! sudo apt-get update --allow-releaseinfo-change; then - log_error "failure while updating package lists" - error_msg "Updating package lists failed!" - exit 1 + if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -3)" ]]; then + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + else + status_msg "Package lists updated recently, skipping..." fi ### Install required packages diff --git a/scripts/moonraker.sh b/scripts/moonraker.sh index 655e2d6..a2020bf 100644 --- a/scripts/moonraker.sh +++ b/scripts/moonraker.sh @@ -152,12 +152,16 @@ function install_moonraker_dependencies() { echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' read -r -a packages <<< "${packages}" - ### Update system package info + ### Update system package info if lists > 3 days old status_msg "Updating package lists..." - if ! sudo apt-get update --allow-releaseinfo-change; then - log_error "failure while updating package lists" - error_msg "Updating package lists failed!" - exit 1 + if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -3)" ]]; then + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + else + status_msg "Package lists updated recently, skipping..." fi ### Install required packages diff --git a/scripts/octoeverywhere.sh b/scripts/octoeverywhere.sh index ff953ce..18e063f 100644 --- a/scripts/octoeverywhere.sh +++ b/scripts/octoeverywhere.sh @@ -318,12 +318,16 @@ function install_octoeverywhere_dependencies() { echo "${cyan}${packages}${white}" | tr '[:space:]' '\n' read -r -a packages <<< "${packages}" - ### Update system package info + ### Update system package info if lists > 3 days old status_msg "Updating package lists..." - if ! sudo apt-get update --allow-releaseinfo-change; then - log_error "failure while updating package lists" - error_msg "Updating package lists failed!" - exit 1 + if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -3)" ]]; then + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + else + status_msg "Package lists updated recently, skipping..." fi ### Install required packages diff --git a/scripts/utilities.sh b/scripts/utilities.sh index b3293ff..269bbdf 100644 --- a/scripts/utilities.sh +++ b/scripts/utilities.sh @@ -303,9 +303,22 @@ function dependency_check() { done echo - if sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${packages[@]}" -y; then + ### Update system package info if lists > 3 days old + status_msg "Updating package lists..." + if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -3)" ]]; then + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + else + status_msg "Package lists updated recently, skipping..." + fi + + if sudo apt-get install "${packages[@]}" -y; then ok_msg "Dependencies installed!" else + log_error "failure while installing dependencies" error_msg "Installing dependencies failed!" return 1 # exit kiauh fi @@ -375,10 +388,20 @@ function check_system_updates() { function update_system() { status_msg "Updating System ..." - if sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y; then + if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -3)" ]]; then + status_msg "Updating package lists..." + if ! sudo apt-get update --allow-releaseinfo-change; then + log_error "failure while updating package lists" + error_msg "Updating package lists failed!" + exit 1 + fi + else + status_msg "Package lists updated recently, skipping..." + fi + if sudo apt-get upgrade -y; then print_confirm "Update complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been kept back!${green}" else - print_error "System update failed! Please watch for any errors printed above!" + print_error "System update failed! Please look for any errors printed above!" fi }