source: client/engine/Net.lib @ 5e1020c

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 5e1020c was 16919ef, checked in by ramon <ramongomez@…>, 14 years ago

Version 1.0: Creación de imágenes desde la consola en cliente no administrador.

  • Corrección en funciones ogGetRepoIp y ogGetServerIp.
  • Corrección de errata en script de interfaz web para cambiar modo de montaje del repositorio.
  • Modificación de permisos de instalación.

Modificado #291.

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

  • Property mode set to 100755
File size: 4.0 KB
Line 
1#!/bin/bash
2#/**
3#@file     Net.lib
4#@brief    Librería o clase Net
5#@class    Net
6#@brief    Funciones básicas de red.
7#@version  0.10
8#@warning  License: GNU GPLv3+
9#*/
10
11
12#/**
13#         ogGetHostname
14#@brief   Muestra el nombre del cliente.
15#@return  str_host - nombre de máquina
16#@version 0.10 - Integración en OpenGnSys 0.10
17#@author  Ramon Gomez, ETSII Universidad de Sevilla
18#@date    2010-02-11
19#*/ ##
20function ogGetHostname ()
21{
22local HOST
23# Tomar nombre de la variable HOSTNAME
24HOST="$HOSTNAME"
25# Si no, tomar del DHCP, opción host-name       /* (comentario para Doxygen)
26[ -z "$HOST" ] && HOST=$(awk -F\" '/option host-name/ {gsub(/;/,""); host=$2}
27                                   END {print host}
28                                  ' /var/lib/dhcp3/dhclient.leases)
29# Si no, leer el parámetro del kernel hostname  (comentario para Doxygen) */
30[ -z "$HOST" ] && HOST=$(awk 'BEGIN {RS=""; FS="="}
31                              $1~/hostname/ {print $2}' /proc/cmdline)
32[ "$HOSTNAME" != "$HOST" ] && export HOSTNAME="$HOST"
33echo $HOST
34}
35
36
37#/**
38#         ogGetNetInterface
39#@brief   Muestra la interfaz de red del sistema
40#@return  str_interfaz - interfaz de red
41#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
42#@note    Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
43#@author  Antonio J. Doblas Viso. Universidad de Malaga.
44#@date    2011-02-24
45#*/ ##
46function ogGetNetInterface ()
47{
48         echo $DEVICE
49
50}
51
52
53
54
55#/**
56#         ogGetIpAddress
57#@brief   Muestra la dirección IP del sistema
58#@return  str_ip - Dirección IP
59#@version 0.10 - Integración en OpenGnSys 0.10
60#@author  Ramon Gomez, ETSII Universidad de Sevilla
61#@date    2010-02-11
62#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
63#@note    Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
64#@author  Antonio J. Doblas Viso. Universidad de Malaga.
65#@date    2011-02-24
66#*/ ##
67function ogGetIpAddress ()
68{
69local IP
70if [ -n $IPV4ADDR ]
71then
72         echo $IPV4ADDR
73else
74        # Obtener direcciones IP.        /* (comentario para Doxygen)
75        IP=$(ip address show | awk '$2!~/lo/ { readline; if ($1~/inet$/) {sub (/\/.*/, ""); printf ("%s ", $2)}}')
76        # Mostrar sólo la primera.       (comentario para Doxygen) */
77        echo ${IP%% *}
78fi
79}
80
81
82#/**
83#         ogGetMacAddress
84#@brief   Muestra la dirección Ethernet del cliente.
85#@return  str_ether - Dirección Ethernet
86#@version 0.10 - Integración en OpenGnSys 0.10
87#@author  Ramon Gomez, ETSII Universidad de Sevilla
88#@date    2010-02-11
89#*/ ##
90function ogGetMacAddress ()
91{
92local MAC
93# Obtener direcciones Ethernet.
94MAC=$(ip address show | awk '$2!~/lo/ {readline; if ($1~/ether/) printf ("%s ", toupper($2));}')
95# Mostrar sólo la primera.
96echo ${MAC%% *}
97}
98
99
100#/**
101#         ogGetRepoIp
102#@brief   Muestra la dirección IP del repositorio de datos.
103#@return  str_ip - Dirección IP
104#@version 0.10 - Integración en OpenGnSys 0.10
105#@author  Ramon Gomez, ETSII Universidad de Sevilla
106#@date    2011-01-13
107#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
108#@note   Comprobacion segun protocolo de conexion al Repo
109#@author  Antonio J. Doblas Viso. Universidad de Malaga.
110#@date    2011-02-24
111#*/ ##
112function ogGetRepoIp ()
113{
114# Obtener direcciones IP, segun el protocolo de montaje
115if [ -n "$OGIMG" ]; then
116    case "$ogprotocol" in
117        nfs)  mount | grep " on $OGIMG " | cut -f1 -d: ;;
118        smb)  mount | grep " on $OGIMG " | cut -f3 -d/ ;;
119    esac
120fi
121}
122
123
124#/**
125#         ogGetServerIp
126#@brief   Muestra la dirección IP del Servidor de OpenGnSys.
127#@return  str_ip - Dirección IP
128#@version 0.10 - Integración en OpenGnSys 0.10
129#@author  Ramon Gomez, ETSII Universidad de Sevilla
130#@date    2011-01-13
131#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
132#@note   Comprobacion segun protocolo de conexion al Repo
133#@author  Antonio J. Doblas Viso. Universidad de Malaga.
134#@date    2011-02-24
135#*/ ##
136function ogGetServerIp ()
137{
138# Obtener direcciones IP.
139if [ -n "$PENGNSYS" ]; then
140    case "$ogprotocol" in
141        nfs)  mount | grep " on $OPENGNSYS " | cut -f1 -d: ;;
142        smb)  mount | grep " on $OPENGNSYS " | cut -f3 -d/ ;;
143    esac
144fi
145}
146
Note: See TracBrowser for help on using the repository browser.