source: client/shared/lib/engine/tests/crearTestDisk1 @ 1d1e06d

Last change on this file since 1d1e06d was 72875ec, checked in by ramon <ramongomez@…>, 12 years ago

Versión 1.0.5, #295: Eliminar función obsoleta ogFsToId.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@3550 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 3.8 KB
Line 
1#!/bin/bash
2# Descripcion: Crea un test no destructivo de la libreria Disk.lib conficurandolo
3#       para un cliente concreto.
4#       Se ejecuta en el servidor y el test creado se utiliza en el cliente
5#       Los datos los toma de la base de administración.
6# Uso: creaTestDisk1 NombreCliente
7#
8# Falta: la bd no tiene información de las particiones lógicas (el script sí esta preparado para ellas)
9#       la bd no tiene datos del tamaño del disco
10
11
12# Variables.
13PROG=$(basename $0)
14OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
15SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
16TESTDIR="$OPENGNSYS/client/lib/engine/tests/NoModify"
17TESTFILE="$TESTDIR/Disk1-$1.shtest "
18# Control básico de errores.
19if [ $# -ne 1 ]; then
20        echo "$PROG: Error de ejecución"
21        echo "Formato: $PROG NOMBRE_PC"
22        exit 1
23fi
24
25# Obtener datos de acceso a la Base de datos.
26source $SERVERCONF
27
28# Comprobar si se recibe nombre de aula o de equipo.
29PARTICIONES=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
30   "SELECT ordenadores_particiones.numpar, tipospar.tipopar, ordenadores_particiones.tamano
31        FROM tipospar INNER JOIN ordenadores_particiones INNER JOIN ordenadores
32        WHERE tipospar.codpar=ordenadores_particiones.codpar
33        AND ordenadores.idordenador=ordenadores_particiones.idordenador
34        AND nombreordenador='$1'
35        ORDER By ordenadores_particiones.numpar;")
36# Si la cadena esta vacia, error
37if [ -z "$PARTICIONES" ]; then
38        echo "El equipo $1 no existe en la base de datos"
39        exit 2
40fi
41
42# Ejemplo para añadir partitiones lógicas
43#PARTICIONES="$PARTICIONES 5 LINUX-SWAP 1999999"
44PRI=$( echo ${PARTICIONES%%\ 5\ *}|awk '{print $2"_"$3" "$5"_"$6" "$8"_"$9" "$11"_"$12}' |sed s/\ _//g |sed s/\ //g)
45
46if $(echo $PARTICIONES |grep " 5 " >/dev/null); then
47   LOG=$( echo ${PARTICIONES##*\ 5\ }|awk '{print $1"_"$2" "$4"_"$5" "$7"_"$8" "$10"_"$11" "}' |sed s/\ _//g |sed s/\ //g)
48else
49   LOG=""
50fi
51AUX=$(echo  $PARTICIONES| wc -w)
52let NUMPART=AUX/3
53P1SIZE=$(echo $PARTICIONES|cut -d\  -f3)
54P1TYPE=$(echo $PARTICIONES|cut -d\  -f2)
55case "$P1TYPE" in
56    EMPTY)      P1ID=0  ;;
57    FAT12)      P1ID=1  ;;
58    EXTENDED)   P1ID=5  ;;
59    FAT16)      P1ID=6  ;;
60    NTFS|EXFAT) P1ID=7  ;;
61    FAT32)      P1ID=b  ;;
62    HFAT12)     P1ID=11 ;;
63    HFAT16)     P1ID=16 ;;
64    HNTFS)      P1ID=17 ;;
65    HFAT32)     P1ID=1b ;;
66    LINUX-SWAP) P1ID=82 ;;
67    EXT[234]|REISERFS|REISER4|XFS|JFS)
68                P1ID=83 ;;
69    LINUX-LVM)  P1ID=8e ;;
70    SOLARIS)    P1ID=bf ;;
71    CACHE)      P1ID=ca ;;
72    LINUX-RAP1ID) P1ID=fd ;;
73    *)          P1ID="" ;;
74esac
75
76cat > $TESTFILE << EOF
77Ejemplo de test funciones de particionado no destrutivo
78=======================================================
79
80# Desmontamos antes de empezar
81$ ogUnmountAll 1 2>/dev/null
82
83$ ogUnmountCache 2>/dev/null
84
85# Cambio de formato
86
87$ ogDevToDisk /dev/sda
881
89
90$ ogDevToDisk /dev/sda1
911 1
92
93$ ogDiskToDev
94/dev/sda
95
96$ ogDiskToDev 1
97/dev/sda
98
99$ ogDiskToDev 1 1
100/dev/sda1
101
102$ ogTypeToId NTFS
1037
104
105$ ogTypeToId LINUX
10683
107
108$ ogTypeToId LINUX GPT
1098300
110
111
112# Tamaño de disco  (cuando haya informacion en la base de datos)
113
114#$ ogGetDiskSize 1
115#312571224
116
117# Tamaño de la particion
118
119$ ogGetPartitionSize 1 1
120$P1SIZE
121
122# Información de  las particiones
123$ ogListPartitions 1 | tr : _ | sed s/EXT[234]/LINUX/g | sed s/\ //g
124$PRI$LOG
125$ ogListPrimaryPartitions 1 | tr : _ | sed s/EXT[234]/LINUX/g | sed s/\ //g
126$PRI
127
128$ ogListLogicalPartitions 1 | tr : _ | sed s/EXT[234]/LINUX/g
129$LOG
130
131$ ogGetPartitionsNumber
132$NUMPART
133
134# Partición activa
135
136$ ogSetPartitionActive 1 2 >/dev/null
137$ ogGetPartitionActive 1
1382
139
140$ ogSetPartitionActive 1 1 >/dev/null
141$ ogGetPartitionActive 1
1421
143
144
145# Tipo de particiones
146
147$ ogGetPartitionId 1 1
148$P1ID
149
150
151# Montamos la cache al final
152$ ogMountCache >/dev/null 2>&1
153
154
155EOF
156
157
158
159echo "Test creado en $TESTFILE"
160echo "Las particiones logicas hay que incluirlas a mano, porque no hay información de las mismas en la base de datos."
Note: See TracBrowser for help on using the repository browser.