diff --git a/nodebuilder b/nodebuilder index fc6545135..659e25c31 100755 --- a/nodebuilder +++ b/nodebuilder @@ -88,6 +88,10 @@ compile_bitcoin_from_source() ./configure --without-bdb --enable-suppress-external-warnings > /dev/null ;; esac + + keep_sudo_alive & + readonly KEEP_SUDO_ALIVE_PID="$!" + log_info 'Compiling source code. Please wait.' case "${TARGET_KERNEL}" in FreeBSD | OpenBSD) @@ -97,7 +101,6 @@ compile_bitcoin_from_source() make --jobs "${SYS_CORES_PLUS_ONE}" > /dev/null 2>&1 ;; esac - log_info 'Running compile checks. Please wait.' case "${TARGET_KERNEL}" in FreeBSD | OpenBSD) @@ -109,7 +112,6 @@ compile_bitcoin_from_source() esac # exclude the two lines before and after 'Ran 3 tests in ' in make check's stdout sed -n '1N;2N;/Ran 3 tests in /{N;N;d;};P;N;D' "${STDERR_COMPILE_LOG_FILE}" >&2 - log_info "Installing Bitcoin Core ${target_bitcoin_version}." case "${TARGET_KERNEL}" in FreeBSD | OpenBSD) @@ -120,6 +122,9 @@ compile_bitcoin_from_source() ;; esac + [ -n "${KEEP-SUDO-ALIVE_PID:-}" ] && ps -p "${KEEP_SUDO_ALIVE_PID}" && + kill "${KEEP_SUDO_ALIVE_PID}" + cd - > /dev/null rm "${STDERR_COMPILE_LOG_FILE}" rm -rf "${COMPILE_DIRECTORY:?}"/ @@ -646,7 +651,11 @@ get_operating_system() # shellcheck disable=SC2317 handle_exit() { - [ -n "${TEMP_DIRECTORY:-}" ] && rm -rf -- "${TEMP_DIRECTORY:?}"/ + [ -n "${TEMP_DIRECTORY:-}" ] && + rm -rf -- "${TEMP_DIRECTORY:?}"/ + [ -n "${KEEP_SUDO_ALIVE_PID:-}" ] && + ps -p "${KEEP_SUDO_ALIVE_PID}" && + kill "${KEEP_SUDO_ALIVE_PID}" } # shellcheck disable=SC2317 @@ -1238,6 +1247,14 @@ is_valid_bitcoin_version() return 1 } +keep_sudo_alive() +{ + while true; do + sudo -n true + sleep 60 + done +} + log_error() { printf "[%s] ERROR: ${CONSOLE_COLOR_RED:-}%s" "$(get_log_timestamp)" "$*" \