-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fixes to takeover upgrade script in preparation for release #408
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,7 +186,7 @@ function cleanup_work_dir() { | |
# Ensure takover path is not just '/' because deletion command is | ||
if [[ -n "${work_dir}" && "${#work_dir}" -gt 3 ]]; then | ||
if [[ -d "${work_dir}" ]]; then | ||
rm -rf "${work_dir:?}/*" | ||
rm -rf "${work_dir:?}/"* | ||
fi | ||
fi | ||
} | ||
|
@@ -300,6 +300,11 @@ starttime=$(date +%s) | |
if [ -d "/mnt/data/resinhup" ] && [ ! -e "/mnt/data/balenahup" ]; then | ||
ln -s "/mnt/data/resinhup" "/mnt/data/balenahup" | ||
fi | ||
# Directory for downloaded/temporary files. MUST be in data partition since stores | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved up higher in the script so always defined for users. |
||
# sizable downloaded OS image. Conserves memory for takeover binary. Must define | ||
# before a call to 'log ERROR'. | ||
work_dir="/mnt/data/takeover" | ||
|
||
# LOGFILE init and header | ||
logtime=$(date +"%Y%m%d_%H%M%S") | ||
LOGFILE="/mnt/data/balenahup/$SCRIPTNAME.${logtime}.log" | ||
|
@@ -454,9 +459,6 @@ case $VERSION in | |
;; | ||
esac | ||
|
||
# Ensure working directory is empty; takeover binary does not cleanup on failure. | ||
cleanup_work_dir | ||
|
||
# Verify data partition filesystem/storage is clean. Flashing over bad sectors | ||
# may brick device. | ||
data_device=$(mount |grep /mnt/data |awk '{print $1}' |head -n 1) | ||
|
@@ -467,28 +469,29 @@ if [ -n "${data_device}" ]; then | |
fi | ||
fi | ||
|
||
# Ensure takeover environment is prepared. We'll add files here. MUST be in | ||
# data partition since stores sizable downloaded OS image. Conserves memory for | ||
# takeover binary. | ||
work_dir="/mnt/data/takeover" | ||
# Ensure any already existing working directory is empty; takeover binary does | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just moved closer to where directory is created for clarity. |
||
# not clean it up on failure. | ||
cleanup_work_dir | ||
mkdir -p "${work_dir}" | ||
|
||
# Retrieve target hostOS image and takeover binary | ||
download_target_image | ||
download_takeover_binary "v0.9.0-dev.1" | ||
download_takeover_binary latest | ||
|
||
progress 50 "Running OS update" | ||
|
||
# Run takeover | ||
# Must run from a writable directory; takeover creates temp files there | ||
cd ${work_dir} | ||
|
||
# No need to specify config.json path; defaults to /mnt/boot. | ||
# API check fails on BoB, so disabled | ||
# We do *not* expect takeover to return on success; it flashes the device with | ||
# the new balenaOS. | ||
res=$(./takeover -i balenaos.img.gz \ | ||
# Takeover returns '1' on failure in stage 1, so handled by the ERR trap defined | ||
# above. | ||
# Takeover reboots on failure in stage 2 and on eventual success, and so does | ||
# not return here. Takeover itself reports failure/success to balenaCloud when | ||
# it reboots due to the --report-hup-progress option below. | ||
# No need to specify config.json path to takeover; defaults to /mnt/boot. | ||
./takeover -i balenaos.img.gz \ | ||
--no-ack --no-nwmgr-check --no-os-check \ | ||
--log-level debug --fallback-log --fallback-log-file "advanced.${logtime}.log" \ | ||
--s2-log-level debug --report-hup-progress) | ||
log ERROR "Takeover result ${res}; OS not updated" | ||
--log-level debug --fallback-log --fallback-log-dir balenahup \ | ||
--fallback-log-filename "advanced.${logtime}.log" \ | ||
--s2-log-level debug --report-hup-progress |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need the globbing character outside the parentheses to work.