| 1 | #!/bin/sh |
| 2 | # |
| 3 | # Retain *.network files from the current root |
| 4 | # |
| 5 | |
| 6 | echo "$(cat /etc/mender/artifact_info): Running $(basename "$0")" >&2 |
| 7 | |
| 8 | if [ ! -x /sbin/fw_printenv ]; then |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | current=$(/sbin/fw_printenv mender_boot_part | awk -F = '{ print $2 }') |
| 13 | |
| 14 | if [ $current = "2" ]; then |
| 15 | newroot=/dev/mmcblk0p3 |
| 16 | elif [ $current = "3" ]; then |
| 17 | newroot=/dev/mmcblk0p2 |
| 18 | else |
| 19 | echo "Unexpected current root: $current" >&2 |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | mount $newroot /mnt |
| 24 | |
| 25 | if [ $? -ne 0 ]; then |
| 26 | echo "Failed to mount $newroot" >&2 |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | sleep 2 |
| 31 | |
| 32 | if [ -d /mnt/etc/systemd/network ]; then |
| 33 | networks=$(ls -l /mnt/etc/systemd/network/*.network 2>/dev/null | wc -l) |
| 34 | |
| 35 | cp /etc/systemd/network/*.network /mnt/etc/systemd/network |
| 36 | echo "Copied /etc/systemd/network to newroot partition" >&2 |
| 37 | else |
| 38 | echo "Failed to find a /etc/systemd/network on newroot partition" >&2 |
| 39 | exit 1 |
| 40 | fi |
| 41 | |
| 42 | umount $newroot |
| 43 |