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