source: client/engine/Net.lib @ fa43c91

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 fa43c91 was fb8c54b, checked in by ramon <ramongomez@…>, 14 years ago

Nuevas funciones ogGetServerIp y ogGetRepoIp incluidas en la librería Net.

git-svn-id: https://opengnsys.es/svn/trunk@1358 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 2.7 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#         ogGetIpAddress
39#@brief   Muestra la dirección IP del sistema
40#@return  str_ip - Dirección IP
41#@version 0.10 - Integración en OpenGnSys 0.10
42#@author  Ramon Gomez, ETSII Universidad de Sevilla
43#@date    2010-02-11
44#*/ ##
45function ogGetIpAddress ()
46{
47local IP
48# Obtener direcciones IP.        /* (comentario para Doxygen)
49IP=$(ip address show | awk '$2!~/lo/ { readline; if ($1~/inet$/) {sub (/\/.*/, ""); printf ("%s ", $2)}}')
50# Mostrar sólo la primera.       (comentario para Doxygen) */
51echo ${IP%% *}
52}
53
54
55#/**
56#         ogGetMacAddress
57#@brief   Muestra la dirección Ethernet del cliente.
58#@return  str_ether - Dirección Ethernet
59#@version 0.10 - Integración en OpenGnSys 0.10
60#@author  Ramon Gomez, ETSII Universidad de Sevilla
61#@date    2010-02-11
62#*/ ##
63function ogGetMacAddress ()
64{
65local MAC
66# Obtener direcciones Ethernet.
67MAC=$(ip address show | awk '$2!~/lo/ {readline; if ($1~/ether/) printf ("%s ", toupper($2));}')
68# Mostrar sólo la primera.
69echo ${MAC%% *}
70}
71
72
73#/**
74#         ogGetRepoIp
75#@brief   Muestra la dirección IP del repositorio de datos.
76#@return  str_ip - Dirección IP
77#@version 0.10 - Integración en OpenGnSys 0.10
78#@author  Ramon Gomez, ETSII Universidad de Sevilla
79#@date    2011-01-13
80#*/ ##
81function ogGetRepoIp ()
82{
83# Obtener direcciones IP.
84[ -n "$OGIMG" ] && mount | grep " $OGIMG .* nfs " | cut -f1 -d:
85}
86
87
88#/**
89#         ogGetServerIp
90#@brief   Muestra la dirección IP del Servidor de OpenGnSys.
91#@return  str_ip - Dirección IP
92#@version 0.10 - Integración en OpenGnSys 0.10
93#@author  Ramon Gomez, ETSII Universidad de Sevilla
94#@date    2011-01-13
95#*/ ##
96function ogGetServerIp ()
97{
98# Obtener direcciones IP.
99[ -n "$OPENGNSYS" ] && mount | grep " $OPENGNSYS .* nfs " | cut -f1 -d:
100}
101
102
Note: See TracBrowser for help on using the repository browser.