source: repoman/bin/sendFileMcast

qndtest
Last change on this file was 063caa5, checked in by Ramón M. Gómez <ramongomez@…>, 5 years ago

#914: Reverting commit 3df93ab and using GAWK for regex compatibility.

  • 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# Si se solicita, mostrar ayuda.
15if [ "$*" == "help" ]; then
16    echo "Formato: $PROG fichero|nombreImagen datosMulticast"
17    echo "Ejemplo: $PROG /opt/opengnsys/images/imagen1.pgz 9000:full-duplex:239.194.17.2:70M:20:120"
18    echo "Ejemplo: $PROG imagen1 9000:full:239.194.17.2:70M:20:120"
19    exit 0
20fi
21# Error si no se reciben 2 parámetros.
22if [ $# -ne 2 ]; then
23    echo "$PROG Error: Formato: $PROG fichero|nombreImagen datosMulticast" 
24    exit 1
25fi
26
27# Fichero a enviar (camino completo o relativo al directorio del repositorio).
28FICH="$1"
29if [ "${FICH:0:15}" != "$OPENGNSYS" ]; then
30    FICHIMG="$OGIMG/$FICH"
31else
32    FICHIMG="$FICH"
33fi
34if [ ! -f "$FICHIMG" ]; then
35    echo "$PROG Error: Fichero \"$FICHIMG\" no accesible" 
36    exit 2
37fi
38
39# Parámetros de sesión separado por ":".
40PARAMS=$(echo "$2" | \
41        awk -F: '$1~/^[0-9]+$/ {v1=$1}
42                 tolower($2)~/^half(-duplex)?$/ {v2="--half-duplex"}
43                 tolower($2)~/^full(-duplex)?$/ {v2="--full-duplex"}
44                 $3~/^[0-9]{1,3}(\.[0-9]{1,3}){3}$/ {v3=$3}
45                 $4~/^[0-9]+[mM]$/ {v4=tolower($4)}
46                 $5~/^[0-9]+$/ {v5=$5}
47                 $6~/^[0-9]+$/ {v6=$6}
48                 END {print v1,v2,v3,v4,v5,v6}
49                ')
50read -re PORTBASE METHOD ADDRESS BITRATE NCLIENTS MAXTIME <<< "$PARAMS"
51if [ -z "$MAXTIME" ]; then
52    echo "$PROG Error: Datos de sesión incorrectos: \"$2\"" 
53    exit 3
54fi
55
56# Valores estandar no configurables.
57CERROR="8x8/128"
58
59# Envío de fichero por Multicast.
60# Se desabilita el uso de mbuffer: esta versión del upd-sender no la admite.
61#which mbuffer &> /dev/null && MBUFFER="--pipe 'mbuffer -m 20M'"
62$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"
63
Note: See TracBrowser for help on using the repository browser.