I have this script that is currently launching a tool's graphical user interface. I want to add another functionality in switch case which is to kill the tool if needed. Right now I have different scripts doing this. I want to integrate the bits and pieces.
Currently, the script I have looks like this:
#!/bin/bash
tart_array=($1)
ip=()
tarts=()
for i in ${tart_array[@]}; do
echo "Tart #: $i"
case "$i" in
1)
IP=10.171.0.10
;;
2)
IP=10.171.0.11
;;
3)
IP=10.171.0.12
;;
4)
IP=10.171.0.13
;;
5)
IP=10.171.0.14
;;
*)
echo "Invalid TARTS '$i'" >&2;
exit
;;
esac
ip+=(${IP=[i]})
# echo "$ip"
tarts=(${tart_array[@]})
# echo "$tarts"
echo " ---- Launching Tart $i ---- "
sshpass -p "tart123" ssh -Y -X -L 5900:$IP:5901 tarts@$IP <<EOF1
export DISPLAY=:1
gnome-terminal -e "bash -c \"pwd; cd /home/tarts; pwd; ./launch_tarts.sh exec bash\""
exit
EOF1
done
Just like Launching TARTS I want to add Killing TARTS in the above switch case statement. Just for example for killing the tool I am doing:
echo "Killing Tart $i"
sshpass -p "tart123" ssh -tt -o StrictHostKeyChecking=no [email protected] <<EOF
. ./tartsenvironfile.8.1.1.0
nohup yes | kill_tarts mcgdrv &
nohup yes | kill_tarts server &
pkill -f traf
pkill -f terminal-server
exit
EOF
Can some one please guide how can I integrate Launching and Killing functionality in my script using the same switch case?