Obecanje iz teme http://www.mycity.rs/phpbb/viewtopic.php?t=31085
Sledeci skript je sa PCLinuxOS LiveCD-a i sluzi da povrati lilo ukoliko je unisten instaliranjem nekog drugog OS-a.
#!/usr/bin/env bash
set -x #comment it out if you don't want debug
if [ $UID != 0 ] ; then
echo "This script requires root privileges."
exit 0
fi
# X or text console
case "`tty`" in
/dev/tty[1-8])
MODE=text
DIA=kdialog
;;
/dev/pts/*|/dev/ttyp*)
MODE=x
export XDIALOG_HIGH_DIALOG_COMPAT=1
[ -x /usr/bin/gdialog ] && DIA=gdialog
[ -x /usr/bin/Xdialog ] && DIA=Xdialog
[ $DIA = dialog ] && MODE=text
;;
*)
MODE=text
DIA=dialog
;;
esac
# text mode if DISPLAY is not set
if [ -z "$DISPLAY" ] ; then
MODE=text
DIA=dialog
fi
BT="Lilo recreation dialog"
TMP=/tmp/redolilo.$$
mkdir -p /mnt/loop
fdisk -l|grep "^/dev.*Linux$"|tr -d '*'|
while read dev x x size x
do
mount $dev /mnt/loop
distro=`cat /mnt/loop/etc/mandrake-release 2>/dev/null|awk '{print \$1 }'`
if [ "$distro" = "pclinuxos" ] ; then
size=${size%+}
echo $dev $[size/1024]_MB off>> $TMP
fi
umount /mnt/loop
done
NUMPCLOS="`wc -l <$TMP`"
PCLOSPART="`cat $TMP`"
T1="PCLinuxOS partition selection"
M1="No PCLinuxOS installation could be found on your hard disks. The script will be terminated."
if [ $NUMPCLOS -eq 0 ]; then
$DIA --backtitle "$BT" --title "$T1" --msgbox "$M1" 15 40
rm -f $TMP
exit 0
fi
if [ $NUMPCLOS > 1 ]; then
#more than one PCLOS partition
M1="More than one PCLinuxOS installation found, Please select the one you want to reinstall lilo from"
$DIA --backtitle "$BT" --title "$T1" --radiolist "$M1" 15 80 $NUMPCLOS \
$PCLOSPART 2> $TMP
FSCHOICE="`cat $TMP`"
M1="No partition chosen. The script will be terminated."
if [ -z "$FSCHOICE" ] ; then
$DIA --backtitle "$BT" --title "$T1" --msgbox "$M1" 15 40
rm -f $TMP
exit 0
fi
dev=$FSCHOICE
NUMPCLOS=1
fi
M1="The /etc/lilo.conf of the chosen partition will displayed \
You can edit the the configuration and save your changes\
You will be asked if you want to recreate your bootloader"
if [ $NUMPCLOS -eq 1 ]; then
mount $dev /mnt/loop
$DIA --backtitle "$BT" --title "Edit" --msgbox "$M1" 15 40
kedit /mnt/loop/etc/lilo.conf
M1="Do you want to reset your bootloader?"
$DIA --backtitle "$BT" --title "$T1" --yesno "$M1" 15 60
x=$?
if [ $x != 0 ] ; then
M1="Cancelled. The script will be terminated."
$DIA --backtitle "$BT" --title "$T1" --msgbox "$M1" 15 40
rm -f $TMP
exit 0
fi
# the actual reset is commented out for debugging
mount -t proc none /mnt/loop/proc
mount -t none /dev /mnt/loop/dev -o bind
/sbin/lilo -v -r /mnt/loop
umount /mnt/loop/dev
umount /mnt/loop/proc
fi
rm -f $TMP
Korisnik je potrebno da bude u grafickom rezimu rada (KDE, GNOME...).
Potrebno je otvoriti terminal, ulogovati se kao root (su ili sudo) i pokrenuti ovaj skript.
Potrebno je da LiveCD poseduje KEdit da bi ovaj skript funkcionisao pravilno.
Skript, ovakav kakav jeste, moze da napravi lilo.conf samo za PCLinuxOS, ali mislim da je zanimljiv, i da ljudi mogu da ga prilagode i drugim distribucijama.
|