Skip to content

Commit

Permalink
added protections against empty unrd, made cmdline dismount more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
j005u committed Oct 29, 2022
1 parent d12acbd commit 11f09fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions tests/02-enforce_slot_1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ if [ $? -ne 2 ]; then
exit 1
fi

#check for deleted unrd empty regression
unrd -d slot_1.status_active

sh $UNITS/$UNIT

if [ $? -ne 2 ]; then
echo "$UNIT did could not detect wrong slot"
exit 1
fi

sh $UNITS/$UNIT fix

#we expect a reboot
Expand Down
7 changes: 4 additions & 3 deletions units/01-corrupt_slot_1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#this script enforces wtfos usage to slot 1 and will re-flash slot 1 before switching if it appears corrupt
check () {
#check whatever our conditions is - this may be more complicated for other issues
if [ $(unrd slot_1.status_successful) != "1" ] || [ $(unrd slot_1.status_bootable) != "1" ]; then
if [ "$(unrd slot_1.status_successful)" != "1" ] || [ "$(unrd slot_1.status_bootable)" != "1" ]; then
echo "Slot 1 is corrupt, can reflash from Slot 2"
return 2

Expand All @@ -14,10 +14,11 @@ fix () {
echo "reflashing slot_1"
echo "please wait, this will take a few minutes"
if [ -f /cache/ota.zip ] ; then
if mount | grep -q '/proc/cmdline' -q; then
while mount | grep -q '/proc/cmdline' -q; do
echo "removing cmdline bindmount"
umount /proc/cmdline
fi
sleep 1
done
echo "reflashing from ota.zip"
echo "please wait, this will take a few minutes"
update_engine --update_package=/cache/ota.zip
Expand Down
3 changes: 1 addition & 2 deletions units/02-enforce_slot_1.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#/bin/sh

#this script enforces wtfos usage to slot 1 and will re-flash slot 1 before switching if it appears corrupt
check () {
#check whatever our conditions is - this may be more complicated for other issues
if [ $(unrd slot_1.status_active) == "1" ] && [ $(unrd slot_1.status_successful) == "1" ]; then
if [ "$(unrd slot_1.status_active)" == "1" ] && [ "$(unrd slot_1.status_successful)" == "1" ]; then
##and return 0 if all is well
return 0
else
Expand Down

0 comments on commit 11f09fb

Please sign in to comment.