version 1.0.2 Instalación de grub en boot sector del linux restaurado #450

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2362 a21b9725-9963-47de-94b9-378ad31fedc9
remotes/github/debian-pkg
Antonio Doblas Viso 2011-10-22 14:38:01 +00:00
parent 51f686cdf1
commit ab82469e83
2 changed files with 76 additions and 0 deletions

View File

@ -595,3 +595,73 @@ sleep 5
ps aux > /dev/null | grep $! | grep -E "T|S" | kill -9 $! > /dev/null
}
# ogGrubInstallPartition int_disk int_partition
#@brief Instala/actualiza el gestro grub en el "boot sector" de la partición indicada
#@param int_disk
#@param indt_part
#@return
#@exception OG_ERR_FORMAT Formato incorrecto.
#@version 1.0.2 - Primeras pruebas.
#@author Antonio J. Doblas Viso. Universidad de Malaga.
#@date 2011-10-29
#*/ ##
function ogGrubInstallPartition {
# Variables locales.
local PART DISK DIRCONF SCHROOTDEVICE
# Si se solicita, mostrar ayuda.
if [ "$*" == "help" ]; then
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition" \
"$FUNCNAME 1 1 "
return
fi
# Error si no se reciben 2 parámetros.
[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
DISK=$1; PART=$2; DIRCONF="/etc/schroot"
VERSION=$(ogGetOsVersion $DISK $PART)
echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?)
SCHROOTLOCATION=$(ogMount $DISK $PART)
SCHROOTDEVICE=$(ogDiskToDev $DISK $PART)
rm ${DIRCONF}/schroot.conf
cat >> ${DIRCONF}/schroot.conf << EOF
[linux]
description=$VERSION
type=plain
directory=$SCHROOTLOCATION
EOF
cat >> $SCHROOTLOCATION/root/installgrub.sh <<EOF
#!/bin/bash
grub-install --recheck --force $SCHROOTDEVICE
update-grub2
EOF
chmod 777 $SCHROOTLOCATION/root/installgrub.sh
mount --bind /dev $SCHROOTLOCATION/dev
mount --bind /dev/pts $SCHROOTLOCATION/dev/pts
mount --bind /proc $SCHROOTLOCATION/proc
mount --bind /sys $SCHROOTLOCATION/sys
schroot -c linux -- /root/installgrub.sh
rm $SCHROOTLOCATION/root/installgrub.sh
umount $SCHROOTLOCATION/dev/pts
umount $SCHROOTLOCATION/dev
umount $SCHROOTLOCATION/proc
umount $SCHROOTLOCATION/sys
}

View File

@ -15,6 +15,9 @@
#@version 1.0.1 - Configura el sector de la particion y el gestor de windows para iniciarse desde cualquier particion.
#@author Antonio J. Doblas Viso. Universidad de Malaga.
#@date 2011-05-20
#@version 1.0.2 - Configura el sector de la particion y el gestor de linux para iniciarse desde cualquier particion.
#@author Antonio J. Doblas Viso. Universidad de Malaga.
#@date 2011-11-22
@ -46,3 +49,6 @@ if [ "$(ogGetOsType $1 $2)" = "Windows" ]; then
ogWindowsRegisterPartition $1 $2 C $1 $2
fi
if [ "$(ogGetOsType $1 $2)" = "Linux" ]; then
ogGrubInstallPartition $1 $2
fi