I have made some modifications to the init script that runs when my PC boots to take me to a /bin/sh shell so I can run some custom scripts. When I exit from here the init statement should mount the root file system and switch_root to it.
This all works correctly however the same init statement will be run on two types of pc's and the address of the root fs is different between them. On one PC it sits on /dev/sda1 and on the other /dev/hda1. To select the appropriate addresses I used dmesg to find out if it was the i5 PC and if/else statements to select the right hard drive location.
When I try use a if/else statement in the init script it ends up preforming both the if and the else code. Is there any reason the if else statements wouldn't work the exact same in the init script (it's all shell scripts isn't it?
Here is the if else statement from the init script.
echo Attempting to switch root
# Check if the PC is an i5 otherwise its an AMD
dmesg | grep i5
if [ $? -ne 1 ]; then # It's a i5
echo "i5 PC Detected"
mount /dev/hda1 /mnt
else # It's a AMD
echo "AMD PC Detected"
mount /dev/sda1 /mnt
exec switch_root /mnt /sbin/init