source: repoman/bin/sendFileMcast

lgromero-new-oglive
Last change on this file was c28eefa, checked in by Natalia Serrano <natalia.serrano@…>, 19 months ago

Log to syslog in a number of shell scripts

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