[dcddace] | 1 | #!/bin/bash |
---|
| 2 | #/** |
---|
| 3 | # bootOsCustom |
---|
| 4 | #@brief Plantilla para script de configuración personalizada de sistema operativo restaurado. |
---|
| 5 | #@param $1 nº de disco |
---|
| 6 | #@param $2 nº de partición |
---|
| 7 | #@warning Renombrar este fichero como "bootOsCustom" para personalizar el script estándar "bootOs". |
---|
[6963f42] | 8 | #@note La partición a inicializar debe estar montada |
---|
[dcddace] | 9 | #**/ |
---|
| 10 | # CONFIGURAR: Partición de datos de Windows que no queremos ocultar |
---|
| 11 | PARTDATA=0 |
---|
| 12 | |
---|
| 13 | PROG="$(basename $0)" |
---|
[6963f42] | 14 | # Control de errores |
---|
[dcddace] | 15 | if [ $# -lt 2 ]; then |
---|
| 16 | ogRaiseError $OG_ERR_FORMAT "Formato: $PROG ndisco nparticion" |
---|
| 17 | exit $? |
---|
| 18 | fi |
---|
| 19 | |
---|
[6963f42] | 20 | # Parámetros obligatorios. |
---|
| 21 | DISK="$1" # Nº de disco. |
---|
| 22 | PART="$2" # Nº de partición. |
---|
| 23 | |
---|
| 24 | # Paso 0: Añadir código para realizar control de errores de los parámetros de entrada (recomendado). |
---|
| 25 | |
---|
| 26 | # Paso 1: Adaptar el código de ejemplo para postconfiguración personalizada. |
---|
| 27 | # Nota: el script "bootOs" llama al script "bootOsCustom" después de realizar la operaciones de inicio estándar y antes de desmontar las particiones e iniciar el sistema operativo. |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | MNTDIR=$(ogMount $DISK $PART) |
---|
[c436360] | 31 | NAME="$(ogGetHostname)" |
---|
| 32 | NAME=${NAME:-"pc"} |
---|
[6963f42] | 33 | OSTYPE=$(ogGetOsType $DISK $PART) |
---|
[c436360] | 34 | |
---|
[dcddace] | 35 | case "$OSTYPE" in |
---|
| 36 | Windows) |
---|
[c436360] | 37 | ## Borrar marcas de arrranque de todos los Windows instalados en el disco. |
---|
| 38 | #echo "[30] Borrar marcas de arrranque de todos los Windows instalados en el disco." |
---|
| 39 | #for (( i=1; i<=$(ogGetPartitionsNumber $1); i++ )); do |
---|
| 40 | # [ "$(ogGetOsType $1 $i)" == "Windows" ] && ogMount $1 $i &>/dev/null |
---|
| 41 | #done |
---|
| 42 | #rm -f /mnt/*/ogboot.* |
---|
| 43 | |
---|
| 44 | ## Mostrar las particiones NTFS de sistema (dos opciones) |
---|
| 45 | ## Opción 1: SIN ocultar las demás. |
---|
| 46 | #echo "[40] Mostrar y activar particion de Windows $PART." |
---|
| 47 | #[ $(ogGetPartitionType $1 $2) == "HNTFS" ] && ogUnhidePartition $1 $2 |
---|
| 48 | |
---|
| 49 | ## Opción 2: Ocultamos las demás. |
---|
| 50 | #echo "[40] Activar particion de Windows $PART y ocultar las demás." |
---|
[6963f42] | 51 | #for (( i=1; i<=$(ogGetPartitionsNumber $DISK); i++ )); do |
---|
| 52 | # if [ $i == $PART -o $i == $PARTDATA ]; then |
---|
| 53 | # [ $(ogGetPartitionType $DISK $PART) == "HNTFS" ] && ogUnhidePartition $1 $PART |
---|
| 54 | # # Activo la particion si no es de datos |
---|
| 55 | # [ $i -ne $PARTDATA ] && ogSetPartitionActive $DISK $i |
---|
| 56 | # else |
---|
| 57 | # [ "$(ogGetPartitionType $DISK $i)" == NTFS ] && ogHidePartition $DISK $i |
---|
| 58 | # fi |
---|
| 59 | #done |
---|
[dcddace] | 60 | ;; |
---|
| 61 | Linux) |
---|
[c436360] | 62 | ## Modificar el nombre del equipo |
---|
| 63 | #echo "[30] Asignar nombre Linux \"$NAME\"." |
---|
| 64 | #ETC=$(ogGetPath $1 $2 /etc) |
---|
| 65 | #[ -d "$ETC" ] && echo "$NAME" >$ETC/hostname 2>/dev/null |
---|
| 66 | |
---|
| 67 | ## Sustituir UUID o LABEL por su dispositivo en definición de sistema de archivo raíz. |
---|
| 68 | #if [ -f "$ETC/fstab" ]; then |
---|
| 69 | # echo "[40] Actualizar fstab con particion raiz \"$PART\"." |
---|
| 70 | # awk -v P="$PART " '{ if ($2=="/" && $1!~/^#/) {sub(/^.*$/, P, $1)} |
---|
| 71 | # print }' $ETC/fstab >/tmp/fstab |
---|
| 72 | # mv /tmp/fstab $ETC/fstab |
---|
| 73 | #fi |
---|
| 74 | |
---|
[6963f42] | 75 | ## Cambiar claves usuarios, copiando fichero /etc/passwd |
---|
| 76 | ## En el servidor el nuevo fichero debe situarse en el directorio del grupo: |
---|
| 77 | ## /opt/opengnsys/images/groups/nombre_aula |
---|
| 78 | #if [ -r $(ogGetGroupDir)/passwd ]; then |
---|
| 79 | # echo "[65] Cambiar claves de usuarios." |
---|
| 80 | # cp $(ogGetGroupDir)/passwd $MNTDIR/etc |
---|
| 81 | #fi |
---|
[dcddace] | 82 | ;; |
---|
| 83 | esac |
---|