source: client/engine/Net.lib @ 9eefff4

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 9eefff4 was 61c14c3, checked in by jcxifre <jcxifre@…>, 15 years ago

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

  • Property mode set to 100755
File size: 2.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  1.0
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 1.0 - Integración en OpenGnSys 1.0
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 1.0 - Integración en OpenGnSys 1.0
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 1.0 - Integración en OpenGnSys 1.0
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
Note: See TracBrowser for help on using the repository browser.