Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: feat(ux): keep sudo permissions alive during compile #1341

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions nodebuilder
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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:?}"/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)" "$*" \
Expand Down
Loading