source: client/engine/Net.lib @ a7125bf

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 a7125bf was bd27de2, checked in by adv <adv@…>, 14 years ago

ogGetNetInterface() interfaz en uso; ogGetServerIp()smb/nfs; ogGetRepoIp() smb/nfs

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

  • Property mode set to 100755
File size: 4.1 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
115case $ogprotocol in
116        nfs)
117                [ -n "$OGIMG" ] && mount | grep " $OGIMG .* nfs " | cut -f1 -d:
118        ;;
119        smb)
120           [ -n "$OGIMG" ] && mount | grep ogimages | awk -F"addr=" '{print $2}' | cut -f1 -d","
121        ;;
122esac
123}
124
125
126#/**
127#         ogGetServerIp
128#@brief   Muestra la dirección IP del Servidor de OpenGnSys.
129#@return  str_ip - Dirección IP
130#@version 0.10 - Integración en OpenGnSys 0.10
131#@author  Ramon Gomez, ETSII Universidad de Sevilla
132#@date    2011-01-13
133#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
134#@note   Comprobacion segun protocolo de conexion al Repo
135#@author  Antonio J. Doblas Viso. Universidad de Malaga.
136#@date    2011-02-24
137#*/ ##
138function ogGetServerIp ()
139{
140# Obtener direcciones IP.
141case $ogprotocol in
142        nfs)
143                [ -n "$OPENGNSYS" ] && mount | grep " $OPENGNSYS .* nfs " | cut -f1 -d:
144        ;;
145        smb)
146           [ -n "$OGIMG" ] && mount | grep ogclient | awk -F"addr=" '{print $2}' | cut -f1 -d","
147        ;;
148esac
149}
150
151
Note: See TracBrowser for help on using the repository browser.