22 function ogChangeRepo () 24 local SRCIMG NEWREPO REPO OGUNIT
26 if [
"$*" ==
"help" ]; then
27 ogHelp "$FUNCNAME" "$FUNCNAME IPREPO [ OgUnit ]" \
28 "$FUNCNAME 10.1.120.3" \
29 "$FUNCNAME 10.1.120.3 cdc" 35 ogRaiseError $OG_ERR_FORMAT
"$MSG_FORMAT: $FUNCNAME IPREPO [ OgUnit ]" 40 # Opciones de montaje: lectura o escritura 41 mount |grep
"ogimages.*rw," &>/dev/null && RW=
",rw" || RW=
",ro" 43 # Si REPO tomamos el repositorio y la unidad organizativa actual 45 OGUNIT=
"$(df | awk -F " " '/ogimages/ {sub(" 47 # Parametros de entrada. Si $1 =
"REPO" dejo el repositorio actual
48 [
"${1^^}" ==
"REPO" ] && NEWREPO=
"$REPO" || NEWREPO=
"${1}" 50 # Si $1 y $2 son el repositorio y la OU actual me salgo
51 [
"$NEWREPO" ==
"$REPO" ] && [
"$2" ==
"$OGUNIT" ] &&
return 0
53 source /scripts/functions
54 source /scripts/ogfunctions
56 [
"$2" ==
"" ] && SRCIMG=
"ogimages" || SRCIMG=
"ogimages/$2" 57 eval $(grep
"OPTIONS=" /scripts/ogfunctions)
59 ogEcho session log
"$MSG_HELP_ogChangeRepo $NEWREPO ${2%/}" 60 ogConnect $NEWREPO $ogprotocol $SRCIMG $OGIMG $RW
62 # Si da error volvemos a montar el inicial 64 ogConnect $REPO $ogprotocol $SRCIMG $OGIMG $RW
83 function ogGetGroupDir () 86 if [
"$*" ==
"help" ]; then
87 ogHelp "$FUNCNAME" "$FUNCNAME str_repo" \
88 "$FUNCNAME REPO ==> /opt/opengnsys/images/groups/Grupo1" 91 # Error si se recibe más de 1 parámetro. 99 GROUP=
"$(ogGetGroupName)" 100 if [ -n
"$GROUP" ]; then
101 DIR=$(
ogGetPath "$REPO" "/groups/$GROUP" 2>/dev/null)
102 [ -d
"$DIR" ] && echo
"$DIR" 104 # Para que no haya error al fallar la condición anterior
119 if [
"$*" ==
"help" ]; then
120 ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => Grupo1" 123 [ -n
"$group" ] && echo
"$group" 138 if [
"$*" ==
"help" ]; then
139 ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => pc1" 142 # Tomar nombre de la variable HOSTNAME 144 # Si no, tomar del DHCP, opción host-name 149 [ -z
"$HOST" ] && HOST=$(
awk 'BEGIN {RS=""; FS="="} 150 $1~/hostname/ {print $2}' /proc/cmdline)
151 [
"$HOSTNAME" !=
"$HOST" ] && export HOSTNAME=
"$HOST" 152 [ -n
"$HOST" ] && echo $HOST
174 if [
"$*" ==
"help" ]; then
175 ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.10" 178 if [ -n
"$IPV4ADDR" ]; then
181 # Obtener direcciones IP. 182 if [ -n
"$DEVICE" ]; then
183 IP=$(ip -o address show up dev
"$DEVICE" 2>/dev/null |
awk '{if ($3~/inet$/) {printf ("%s ", $4)}}')
185 IP=$(ip -o address show up |
awk '$2!~/lo/ {if ($3~/inet$/) {printf ("%s ", $4)}}')
188 # Mostrar solo la primera. 189 echo
"${IP%%/*}" # (comentario para Doxygen) */
207 if [
"$*" ==
"help" ]; then
208 ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 00:11:22:33:44:55" 211 # Obtener direcciones Ethernet. 212 if [ -n
"$DEVICE" ]; then
213 MAC=$(ip -o link show up dev
"$DEVICE" 2>/dev/null |
awk '{sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}')
215 MAC=$(ip -o link show up |
awk '$2!~/lo/ {sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}')
217 # Mostrar sólo la primera. 233 if [
"$*" ==
"help" ]; then
234 ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => eth0" 237 [ -n
"$DEVICE" ] && echo
"$DEVICE" 262 if [
"$*" ==
"help" ]; then
263 ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.2" 267 # Obtener direcciones IP, según el tipo de montaje. 268 eval $(findmnt -P -o SOURCE,FSTYPE $OGIMG)
270 nfs) echo
"$SOURCE" | cut -f1 -d: ;;
271 cifs) echo
"$SOURCE" | cut -f3 -d/ ;;
297 if [
"$*" ==
"help" ]; then
298 ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.2" 302 # Obtener direcciones IP, según el tipo de montaje. 303 eval $(findmnt -P -o SOURCE,FSTYPE $OPENGNSYS)
305 nfs) echo
"$SOURCE" | cut -f1 -d: ;;
306 cifs) echo
"$SOURCE" | cut -f3 -d/ ;;
322 function ogMakeGroupDir () 325 if [
"$*" ==
"help" ]; then
326 ogHelp "$FUNCNAME" "$FUNCNAME str_repo" \
327 "$FUNCNAME" "$FUNCNAME REPO" 330 # Error si se recibe más de 1 parámetro. 337 # Comprobar tipo de repositorio. 340 GROUP=
"$(ogGetGroupName)" 341 if [ -n
"$GROUP" ]; then
342 mkdir -p
"$DIR/groups/$GROUP" 2>/dev/null
function ogGetHostname()
Muestra el nombre del cliente. #.
function ogRaiseError()
Devuelve el mensaje y el código de error correspondiente. #.
function ogHelp()
Muestra mensaje de ayuda para una función determinda. #.
function ogGetPath()
Inicia el proceso de arranque de un sistema de archivos. #.
function ogGetGroupName()
Devuelve el nombre del grupo al que pertenece el cliente. #.
function ogGetNetInterface()
Muestra la interfaz de red del sistema #.
function ogGetMacAddress()
Muestra la dirección Ethernet del cliente. #.
function ogGetServerIp()
Muestra la dirección IP del Servidor de OpenGnSys. #.
function ogGetRepoIp()
Muestra la dirección IP del repositorio de datos. #.
function ogEcho()
Muestra mensajes en consola y lo registra en fichero de incidencias. #.
function ogGetIpAddress()
Muestra la dirección IP del sistema #.