source: client/shared/scripts/generateMenuDefault @ 3c3abbf

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 3c3abbf was d04e1b3, checked in by ramon <ramongomez@…>, 12 years ago

Versión 1.0.5, #416 #568: Script generateMenuDefault no inicia los sistemas operativos solo de datos (con sistema operativo asignado a "DATA".

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

  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/bin/bash
2# generateMenuDefault - Crea fichero con la página web de inicio del cliente
3#                       con información de red y de los sistemas operativos instalados,
4#                       crea fichero con información del contenido de la caché local.
5
6
7DEVICE=${DEVICE:-"eth0"}
8source /tmp/net-$DEVICE.conf
9FILEINFOHTML=$OGLOG/`ogGetIpAddress`.info.html
10FILEINFOCACHE=$OGLOG/`ogGetIpAddress`.cache.txt
11ogMountCache 2>/dev/null
12CACHECONTENIDO=`ls -m $OGCAC/$OGIMG 2>/dev/null`
13
14SPEED=$(LANG=C ethtool $DEVICE 2>/dev/null | awk '$1~/Speed/ {print $2}')
15case "${SPEED,,}" in
16        1000mb/s)       ;;
17        100mb/s)        SPEED="<font color=\"blue\">$SPEED</font>" ;;
18        10mb/s)         SPEED="<font color=\"grey\">$SPEED</font>" ;;
19        *)              SPEED="<font color=\"red\">$SPEED</font>" ;;
20esac
21DUPLEX=$(LANG=C ethtool $DEVICE 2>/dev/null | awk '$1~/Duplex/ {print $2}')
22case "${DUPLEX,,}" in
23        full)           ;;
24        *)              DUPLEX="<font color=\"red\">$DUPLEX</font>"
25esac
26CACHESIZEFREE=$(ogGetFreeSize `ogFindCache`)
27expr $CACHESIZEFREE / 1024 > $FILEINFOCACHE 2>/dev/null && echo '.MB,' >> $FILEINFOCACHE
28
29# Crear menú por defecto.
30cat > $FILEINFOHTML << EOT
31<div align="center" style="font-family: Arial, Helvetica, sans-serif;">
32<p style="color:#999999; font-size: 16px; margin: 2em;">
33
34<table border="1" width="100%">
35<tr>
36<td rowspan="2"><p align="left"><img border="0" src="../images/iconos/logoopengnsys.png"><p> </td>
37<td> $MSG_HOSTNAME </td> <td> $MSG_IPADDR </td> <td> $MSG_MACADDR </td> <td> $MSG_SPEED </td> <td> $MSG_DUPLEX </td> </tr>
38<tr> <td>$HOSTNAME </td> <td> $(ogGetIpAddress) </td> <td> $(ogGetMacAddress) </td> <td> $SPEED </td> <td> $DUPLEX </td> </tr>
39</table>
40</p>
41
42<h1>$MSG_MENUTITLE</h1>
43EOT
44
45# Si existe el fichero de configuración creado por el script getConfiguration, ...
46cfgfile=/tmp/getconfig
47if [ -f $cfgfile ]; then
48    # Tomar los datos del fichero.
49    awk -v boot="$MSG_BOOT" '
50         { n=split($0,sep,";");
51           for (i=1; i<n; i++) {
52               split (sep[i],dua,":");
53               if (dua[5]!="" && dua[5]!="DATA") {
54                   printf ("<p><a href=\"command:bootOs %s %s\">%s %s (%s, %s)</a></p>\n",
55                           dua[1],dua[2],boot,dua[5],dua[1],dua[2]);
56                   }
57               }
58         }' $cfgfile >>$FILEINFOHTML
59else
60    # Si no, obtener los datos de los discos.
61    for ((d=1; d<=$(ogDiskToDev | wc -w); d++)); do
62        for ((p=1; p<=$(ogGetPartitionsNumber $d); p++)); do
63            VERSION=$(ogGetOsVersion $d $p 2>/dev/null | cut -f2 -d:)
64            [ -n "$VERSION" ] && echo "<p><a href=\"command:bootOs $d $p\">$MSG_BOOT $VERSION ($d, $p)</a></p>" >>$FILEINFOHTML
65        done
66    done
67fi
68# Añadir opción de apagado.
69cat >> $FILEINFOHTML << EOT
70<p><a href="command:poweroff">$MSG_POWEROFF</a></p>
71</div>
72EOT
73
74# Crear contenido de la caché.
75cat >> $FILEINFOCACHE << EOT
76$CACHECONTENIDO
77EOT
78
Note: See TracBrowser for help on using the repository browser.