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(security): install software updates on macOS #481

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2fcdb40
feat: install software updates on macOS
bitcoin-tools Apr 1, 2024
c3da707
fix: formatting and UI
bitcoin-tools Apr 1, 2024
f8d9472
Update nodebuilder
bitcoin-tools Apr 1, 2024
f7a2a7b
feat(ci): install macOS updates and cache directory
bitcoin-tools Apr 1, 2024
d00ac97
Update validation.yaml
bitcoin-tools Apr 1, 2024
7e20fd2
Update validation.yaml
bitcoin-tools Apr 1, 2024
ac265dd
Update validation.yaml
bitcoin-tools Apr 1, 2024
80d3d14
Update nodebuilder
bitcoin-tools Apr 1, 2024
291ad8b
Update nodebuilder
bitcoin-tools Apr 1, 2024
2c489df
Update nodebuilder
bitcoin-tools Apr 1, 2024
5e84635
Update nodebuilder
bitcoin-tools Apr 1, 2024
2e57ab0
Update nodebuilder
bitcoin-tools Apr 1, 2024
5f5848f
Update nodebuilder
bitcoin-tools Apr 1, 2024
8a2270f
Update nodebuilder
bitcoin-tools Apr 25, 2024
25cd856
fix(ci): remove duplicate needs field in bare metal jobs
bitcoin-tools Apr 26, 2024
38abf02
Update nodebuilder
bitcoin-tools Apr 26, 2024
d7669e5
fix: use correct function name
bitcoin-tools Apr 26, 2024
9aba6b3
add cache-path to Ubuntu 22 and other good stuff
bitcoin-tools Apr 26, 2024
875bbef
handle case where no reboot is required
bitcoin-tools Apr 26, 2024
5208d3d
fix syntax bug
bitcoin-tools Apr 26, 2024
3f871d6
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools Apr 26, 2024
c3162d6
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools Apr 26, 2024
bf0968f
fix: avoid repeated code
bitcoin-tools Apr 26, 2024
219c20f
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools Apr 26, 2024
ab21c7c
fix: remove bad if condition
bitcoin-tools Apr 26, 2024
608d550
use an improved version of master's code
bitcoin-tools Apr 26, 2024
3bfd1eb
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools Apr 30, 2024
aca70d1
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools May 4, 2024
a50a7e1
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools May 5, 2024
9ab64fa
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools May 6, 2024
02d6e41
Merge branch 'master' into 431-install-software-updates-on-macos
bitcoin-tools May 16, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,14 @@ jobs:
- os: macos-13
os-friendly-name: macOS 13
check-environment-command: sw_vers && sysctl machdep.cpu.core_count machdep.cpu.thread_count machdep.cpu.brand_string && memory_pressure -Q
install-upgrades-command: softwareupdate --list && softwareupdate --install --recommended
cache-path: /Library/Updates
path-to-bitcoin-log: '/Users/runner/Library/Application Support/Bitcoin/debug.log'
- os: macos-latest
os-friendly-name: macOS 14
check-environment-command: sw_vers && sysctl machdep.cpu.core_count machdep.cpu.thread_count machdep.cpu.brand_string && memory_pressure -Q
install-upgrades-command: softwareupdate --list && softwareupdate --install --recommended
cache-path: /Library/Updates
path-to-bitcoin-log: '/Users/runner/Library/Application Support/Bitcoin/debug.log'
steps:
- uses: actions/checkout@v4
Expand Down
47 changes: 44 additions & 3 deletions nodebuilder
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
#
# A minimally-interactive script for launching a Bitcoin Core node
# shellcheck disable=SC2009
# shellcheck disable=SC2155

set -o errexit
Expand Down Expand Up @@ -350,6 +351,33 @@ install_system_updates_aptget() {
rm "${STDERR_INSTALL_LOG_FILE}"
}

install_system_updates_darwin() {
softwareupdate --install --os-only --recommended &
softwareupdate_pid="$!"

# Continuously check for the presence of the restart dialog while softwareupdate is running
while ps -p "${softwareupdate_pid}" > /dev/null; do
ps aux #debug
# If the restart dialog is present, handle it
if ps aux | grep --quiet "[i]nstallassistant_springboard"; then
if is_running_in_ci || is_running_in_container; then
installassistant_pid=$(ps aux | grep "[i]nstallassistant_springboard" | awk '{print $2}')

# DEBUG TESTING HERE DELETE BEFORE MERGING
# MIGHT ALSO NEED TO SEND A kill -TERM "${installassistant_pid}"
# MIGHT ALSO NEED TO TRY kill "${softwareupdate_pid}"
kill -INT "${installassistant_pid}"
else
echo "The system needs to restart to finish installing updates. Please click the restart button."
exit 0
fi
fi

# Wait a bit before checking again
sleep 1
done
}

install_system_updates_dnf() {
sudo dnf clean all && sudo dnf --assumeyes --quiet upgrade > /dev/null
}
Expand Down Expand Up @@ -617,9 +645,7 @@ Linux)
sudo reboot
exit 0
fi
printf '%s\n' 'ok.'

printf '%s' 'Ensuring runtime dependencies... '
printf '%s\n%s' 'ok.' 'Ensuring runtime dependencies... '
case "${TARGET_OPERATING_SYSTEM}" in
alpine)
install_runtime_dependencies_apk
Expand Down Expand Up @@ -675,6 +701,21 @@ Darwin)
throw_error 'Check for active internet failed.'
printf '%s\n' 'ok.'
display_macos_warning
printf '%s' "Performing a system upgrade... "
softwareupdate --list #DEBUG PURPOSES DELETE THIS LINE BEFORE MERGING
reboot_required_list_macos="$(softwareupdate --list 2> /dev/null | grep "restart" || true)"
install_system_updates_darwin
if [ -n "${reboot_required_list_macos}" ] && ! is_running_in_ci; then
printf '\n%s\n%s\n' "REBOOT REQUIRED to upgrade the following:" "${reboot_required_list_macos}"
if [ "${unattended}" = false ]; then
printf '\n%s' "PRESS ENTER to reboot or press Ctrl+C to exit... "
read -r _
printf '\n'
fi
printf '%s\n' "Rebooting."
sudo reboot
exit 0
fi
printf '%s' 'Checking for git... '
install_runtime_dependencies_darwin
printf '%s\n' 'ok.'
Expand Down
Loading