2016-06-13 23:17:19 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
puits=false
|
|
|
|
sourc=false
|
|
|
|
protocol="tcp"
|
2020-04-03 11:36:58 +02:00
|
|
|
port=`expr \`id -u\` % 3000 + 14578`
|
2023-04-23 11:25:38 +02:00
|
|
|
interrupted=1
|
2016-06-13 23:17:19 +02:00
|
|
|
|
|
|
|
usage() { echo "Usage: $0 [[-p|-s] [-t (tcp|mictcp)]" 1>&2; exit 1; }
|
|
|
|
|
2023-04-23 11:25:38 +02:00
|
|
|
# Stop all components gracefully
|
|
|
|
function graceful_stop ()
|
|
|
|
{
|
|
|
|
|
|
|
|
echo "Arret"
|
|
|
|
killall -9 cvlc > /dev/null 2>&1
|
|
|
|
killall -9 vlc > /dev/null 2>&1
|
|
|
|
killall -9 gateway > /dev/null 2>&1
|
|
|
|
|
|
|
|
if [ $interrupted -eq 1 ]; then
|
|
|
|
# Set return code to 2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# initialise trap to call graceful_stop function
|
|
|
|
# when signal 2 (SIGINT) is received
|
|
|
|
trap "graceful_stop" 2
|
|
|
|
|
2018-05-01 18:30:13 +02:00
|
|
|
while getopts "pst:" o; do
|
2018-05-03 18:41:58 +02:00
|
|
|
case "${o}" in
|
|
|
|
t)
|
|
|
|
protocol=${OPTARG}
|
|
|
|
if [ "$protocol" != "tcp" ] && [ "$protocol" != "mictcp" ]; then
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
puits=true
|
|
|
|
;;
|
|
|
|
s)
|
|
|
|
sourc=true
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
2016-06-13 23:17:19 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
if ([ "$puits" = true ] && [ "$sourc" = true ]) || ([ "$puits" = false ] && [ "$sourc" = false ]) ; then
|
2018-05-03 18:41:58 +02:00
|
|
|
usage
|
|
|
|
exit 1
|
2016-06-13 23:17:19 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$puits" = true ]; then
|
|
|
|
|
|
|
|
echo "Lancement du puits, protocole " $protocol
|
2020-04-03 11:36:58 +02:00
|
|
|
cvlc rtp://127.0.0.1:$port > /dev/null 2>&1 &
|
2016-06-13 23:17:19 +02:00
|
|
|
|
|
|
|
if [ "$protocol" = "mictcp" ]; then
|
|
|
|
cd build
|
2020-04-03 11:36:58 +02:00
|
|
|
./gateway -p -t $protocol $port &
|
2018-05-03 18:41:58 +02:00
|
|
|
cd ..
|
2016-06-13 23:17:19 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$sourc" = true ]; then
|
|
|
|
|
|
|
|
echo "Lancement de la source, protocol " $protocol
|
|
|
|
cd build
|
2020-04-03 11:36:58 +02:00
|
|
|
./gateway -s -t $protocol 127.0.0.1 $port &
|
2016-06-13 23:17:19 +02:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Appuyez sur ENTREE pour arreter"
|
2018-05-01 18:30:13 +02:00
|
|
|
read line
|
2023-04-23 11:25:38 +02:00
|
|
|
interrupted=0
|
|
|
|
graceful_stop
|