PC2st.ir جان دستت درد نکنه ، چند بار این <2 رو امتحان کردم ولی بعد از grep گذاشته بودم دستت درد نکنه .
#!/bin/bash
set `whoami`
if [ "$1" != "root" ];
then
echo "Permission denied: You must be root"
exit
fi
syspart=`{
grub --batch <<EOF |grep \(hd[0-9],[0-9]\)
find /boot/grub/stage1
quit
EOF
} 2> /dev/null`
set `expr substr $syspart 2 3`
sysdev=$1
{
grub --batch <<EOF
root $syspart
setup ($sysdev)
quit
EOF
} 2> /dev/null
echo ""
echo "Changes will take effect after reboot"
echo "Do you want to reboot now?<y/n>"
read -n 1 answer
echo ""
if [ "$answer" = "y" ] || [ "$answer" = "Y" ] || [ "$answer" = "" ];
then
reboot now
fi
exit