#!/bin/sh # Ideado a partir de: # http://www.pcworld.com/howto/article/0,aid,118200,00.asp # # Registro de cambios: # # 26 ene 2004: # * Detección primitiva de el número de opción de Windows # * Configurabilidad: # - No hace falta ser root si se define FORZAR_ROOT a != 1. Para # evitar errores de configuración, si el ejecutable de grub # no se encuentra mostramos un error. # - MENU_LST define el lugar donde está la configuración # de grub. En algunos sistemas está (¿estaba?) en /etc. # DEVICE_MAP define el lugar de device.map. # - El interfaz gráfico de su y los ejecutables de grub # y de reinicio son configurables. # - Los errores son gráficos si estamos en X-Window # 21 ene 2004: # * Si el usuario no es root hacemos un su o un gksu sobre # este script ######### Configuración ######### FORZAR_ROOT=1 MENU_LST=/boot/grub/menu.lst DEVICE_MAP=/boot/grub/device.map SU_GRAFICO=gksu DIALOGO_ERROR="zenity --error --text " GRUB=`which grub` REBOOT=`which reboot` #num_opciones=`grep -ic '^[^#]*title' $MENU_LST` t=`grep -i '^[^#]*title' $MENU_LST | grep -in 'windows' | sed 's/:.*$//'` OPCION_WINDOWS=`expr $t - 1` if [ $FORZAR_ROOT -eq 1 ]; then if [ `id -u` -ne 0 ]; then if [ "$DISPLAY" ]; then $SU_GRAFICO "sh $0" || { exit 1 } else su -c "sh $0" || { exit 1 } fi exit 0 fi fi if [ -z "$GRUB" ]; then mensaje_error="¡El ejecutable de grub no se ha encontrado en el path!" if [ -z $DISPLAY ]; then echo $mensaje_error >&2 else $DIALOGO_ERROR "$mensaje_error" fi exit 2 fi $GRUB --device-map=$DEVICE_MAP --batch <