Skip to content

Commit

Permalink
v9.7
Browse files Browse the repository at this point in the history
- DietPi-Patches | Fix Ethernet port migration
  • Loading branch information
MichaIng committed Aug 22, 2024
1 parent 7ba254e commit 9373e2d
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .update/patches
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ Patch_9_7()
G_DIETPI-NOTIFY 1 "Root filesystem is not located on partition 8 as intended, but \"$G_ROOTFS_DEV\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1

elif [[ $(lsblk -no START "$G_ROOTFS_DEV") != 286720 ]]
elif [[ $(partx -rgo START "$G_ROOTFS_DEV") != 286720 ]]
then
G_DIETPI-NOTIFY 1 "Root partition does not start at sector 286720 as intended, but \"$(lsblk -no START "$G_ROOTFS_DEV")\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1
Expand Down Expand Up @@ -1853,15 +1853,16 @@ Patch_9_7()
# LAN interface migration
G_DIETPI-NOTIFY 2 'Migrating LAN interface configs'
case $(</proc/device-tree/model) in
*R5S*) local eth0='eth2' eth1='eth0' eth2='eth1';;
*R5C*) local eth0='eth1' eth1='eth0' eth2='';;
*R5S*) local eth0='ethto2' eth1='ethto0' eth2='ethto1';;
*R5C*) local eth0='ethto1' eth1='ethto0' eth2='';;
*) :;;
esac
for i in /etc/network/interfaces{,.d/*}
do
G_EXEC sed -i -e "s/eth0/to$eth0/g" -e "s/eth1/to$eth1/g" "$i"
[[ $eth2 ]] && G_EXEC sed -i "s/eth2/to$eth2/g" "$i"
G_EXEC sed -i -e "s/to$eth0/$eth0/g" -e "s/to$eth1/$eth1/g" -e "s/to$eth1/$eth1/g" "$i"
[[ -f $i ]] || continue
G_EXEC sed -i -e "s/eth0/$eth0/g" -e "s/eth1/$eth1/g" "$i"
[[ $eth2 ]] && G_EXEC sed -i "s/eth2/$eth2/g" "$i"
G_EXEC sed -i 's/ethto/eth/g' "$i"
done
fi

Expand All @@ -1887,7 +1888,7 @@ Patch_9_7()
G_DIETPI-NOTIFY 1 "Root filesystem is not located on partition 8 as intended, but \"$G_ROOTFS_DEV\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1

elif [[ $(lsblk -no START "$G_ROOTFS_DEV") != 286720 ]]
elif [[ $(partx -rgo START "$G_ROOTFS_DEV") != 286720 ]]
then
G_DIETPI-NOTIFY 1 "Root partition does not start at sector 286720 as intended, but \"$(lsblk -no START "$G_ROOTFS_DEV")\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"
exit 1
Expand Down Expand Up @@ -1931,6 +1932,18 @@ Patch_9_7()
G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread --delete "$rootdrive" 1 2 3 4 5 6 7 8
G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread -N1 "$rootdrive" <<< '286720'
G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread -N1 "$rootdrive" <<< ',+' # Needed, since above command and '286720,+' somehow create the partition 2015 sectors smaller, resulting in too large filesystem size. Only a subsequent ',+' expands it to the true end of the drive.
# LAN interface migration
G_DIETPI-NOTIFY 2 'Migrating LAN interface configs'
case $(</proc/device-tree/model) in
*R6S*) local eth1='ethto2' eth2='ethto1';;
*) local eth0='skip';;
esac
[[ $eth0 == 'skip' ]] || for i in /etc/network/interfaces{,.d/*}
do
[[ -f $i ]] || continue
G_EXEC sed -i -e "s/eth1/$eth1/g" -e "s/eth2/$eth2/g" "$i"
G_EXEC sed -i 's/ethto/eth/g' "$i"
done
fi
fi

Expand Down

0 comments on commit 9373e2d

Please sign in to comment.