source: repoman/bin/sendFileMcast @ 7534054

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-instalacion
Last change on this file since 7534054 was 71b93c5d, checked in by Irina Gómez <irinagomez@…>, 6 years ago

Fixs multicast error: create 'read' alias defining line break character as default delimiter.

  • Property mode set to 100755
File size: 2.2 KB
Line 
1#!/bin/bash
2#@brief   Envía un fichero por multicast   ORIGEN(fichero) DESTINO(sessionmulticast)
3#@param   path_file      Camino completo del fichero a enviar
4#@param   str_session    Datos de sesión (Puerto:Duplex:IP:Mpbs:Nclientes:Timeout)
5
6
7PROG=$(basename $0)
8OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
9OGIMG=$OPENGNSYS/images
10OGBIN=$OPENGNSYS/bin
11PATH=$PATH:$OGBIN
12REPO_IFACE="$(/opt/opengnsys/bin/getRepoIface)"
13
14# Compatibilidad con Ubuntu 18
15source $OPENGNSYS/lib/osadapter.sh
16
17# Si se solicita, mostrar ayuda.
18if [ "$*" == "help" ]; then
19    echo "Formato: $PROG fichero|nombreImagen datosMulticast"
20    echo "Ejemplo: $PROG /opt/opengnsys/images/imagen1.pgz 9000:full-duplex:239.194.17.2:70M:20:120"
21    echo "Ejemplo: $PROG imagen1 9000:full:239.194.17.2:70M:20:120"
22    exit 0
23fi
24# Error si no se reciben 2 parámetros.
25if [ $# -ne 2 ]; then
26    echo "$PROG Error: Formato: $PROG fichero|nombreImagen datosMulticast"
27    exit 1
28fi
29
30# Fichero a enviar (camino completo o relativo al directorio del repositorio).
31FICH="$1"
32if [ "${FICH:0:15}" != "$OPENGNSYS" ]; then
33    FICHIMG="$OGIMG/$FICH"
34else
35    FICHIMG="$FICH"
36fi
37if [ ! -f "$FICHIMG" ]; then
38    echo "$PROG Error: Fichero \"$FICHIMG\" no accesible"
39    exit 2
40fi
41
42# Parámetros de sesión separado por ":".
43PARAMS=$(echo $2 | \
44        awk -F: '$1~/^[0-9]*$/ {print $1}
45                 tolower($2)~/^(half)(-duplex)?$/ {print "half-duplex"}
46                 tolower($2)~/^(full)(-duplex)?$/ {print "full-duplex"}
47                 $3~/^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$/ {print $3}
48                 $4~/^[0-9]*[mM]/ {print toupper($4)}
49                 $5~/^[0-9]*/ {print $5}
50                 $6~/^[0-9]*/ {print $6}
51                ')
52read -e PORTBASE METHOD ADDRESS BITRATE NCLIENTS MAXTIME <<< $PARAMS
53if [ -z "$MAXTIME" ]; then
54    echo "$PROG Error: Datos de sesión incorrectos: \"$2\""
55    exit 3
56fi
57
58# Valores estandar no configurables.
59CERROR="8x8/128"
60
61# Envío de fichero por Multicast.
62# Se desabilita el uso de mbuffer: eesta versión del upd-sender no la admite.
63#which mbuffer &> /dev/null && MBUFFER="--pipe 'mbuffer -m 20M'"
64$OGBIN/udp-sender $MBUFFER --nokbd --retries-until-drop 65 --portbase $PORTBASE --$METHOD --interface $REPO_IFACE --mcast-data-address $ADDRESS --fec $CERROR --max-bitrate $BITRATE --ttl 16 --min-clients $NCLIENTS --max-wait $MAXTIME --file "$FICHIMG"
65
Note: See TracBrowser for help on using the repository browser.