| | 7 | # Exit if any command exits with a non-zero status |
|---|
| | 8 | set -o errexit |
|---|
| | 9 | |
|---|
| | 10 | trap errorhandler 0 1 2 3 15 |
|---|
| | 11 | |
|---|
| | 12 | errorhandler() { |
|---|
| | 13 | echo -e "\n" |
|---|
| | 14 | echo "WARNING: An error may have occurred while flashing" |
|---|
| | 15 | echo "the NAND with the new root filesystem. The SD card" |
|---|
| | 16 | echo "may be bad if the untarring process segfaulted or" |
|---|
| | 17 | echo "the system might not have tar installed with bzip2" |
|---|
| | 18 | echo "support if the process never started." |
|---|
| | 19 | if [ -n "$(grep /media/nand /proc/mounts)" ] ; then |
|---|
| | 20 | umount /media/nand |
|---|
| | 21 | fi |
|---|
| | 22 | exit 1 |
|---|
| | 23 | } |
|---|
| | 24 | |
|---|
| 10 | | if ! tar jxvf /media/mmcblk0p2/rootfs.tar.bz2 -C /media/nand ; then |
|---|
| 11 | | echo "An error occurred while flashing the NAND with the new root filesystem." |
|---|
| 12 | | echo "The SD card may be bad if the untarring process segfaulted or the system" |
|---|
| 13 | | echo "might not have tar installed with bzip2 support if the process never started." |
|---|
| 14 | | else |
|---|
| 15 | | echo "default-on" > /sys/class/leds/oswaldboard\:\:usr/trigger |
|---|
| 16 | | echo "SUCCESS: The device has been flashed with a new root filesystem. The SD" |
|---|
| 17 | | echo " card should now be removed before turning off the device." |
|---|
| 18 | | fi |
|---|
| | 28 | tar jxvf /media/mmcblk0p2/rootfs.tar.bz2 -C /media/nand |
|---|