2016-06-13 23:17:19 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
puits=false
|
|
|
|
sourc=false
|
2023-04-09 20:46:08 +02:00
|
|
|
dest="127.0.0.1"
|
2016-06-13 23:17:19 +02:00
|
|
|
|
2023-04-09 20:46:08 +02:00
|
|
|
usage() { echo "Usage: $0 [-p|-s destination] port" 1>&2; exit 1; }
|
2016-06-13 23:17:19 +02:00
|
|
|
|
2023-04-09 20:46:08 +02:00
|
|
|
while getopts "ps:" o; do
|
2018-05-03 18:41:58 +02:00
|
|
|
case "${o}" in
|
|
|
|
p)
|
|
|
|
puits=true
|
|
|
|
;;
|
|
|
|
s)
|
|
|
|
sourc=true
|
2023-04-09 20:46:08 +02:00
|
|
|
dest=${OPTARG}
|
2018-05-03 18:41:58 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
2016-06-13 23:17:19 +02:00
|
|
|
done
|
2023-04-09 20:46:08 +02:00
|
|
|
if (([ "$sourc" = true ] && [ $# -ne 3 ]) || ([ "$puits" = true ] && [ $# -ne 2 ])) || (([ "$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
|
2023-04-09 20:46:08 +02:00
|
|
|
port=${@: -1}
|
2016-06-13 23:17:19 +02:00
|
|
|
|
|
|
|
if [ "$puits" = true ]; then
|
|
|
|
cd build
|
2023-04-09 20:46:08 +02:00
|
|
|
./server $port
|
2016-06-13 23:17:19 +02:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$sourc" = true ]; then
|
|
|
|
|
|
|
|
cd build
|
2023-04-09 20:46:08 +02:00
|
|
|
./client $dest $port
|
2016-06-13 23:17:19 +02:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
|