-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlauncher.sh
64 lines (50 loc) · 2.15 KB
/
launcher.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Code adapted from posted example by Jordan Frimpter
# Command to grant permission to file to run [RUN THIS]: chmod +x launcher.sh
# Change this to your netid [CHANGE THIS]
netid=mxb230055
# Root directory of project [CHANGE THIS]
PROJDIR=/home/013/m/mx/mxb230055/aos-project1
# Directory where the config file is located on your local system [CHANGE THIS]
CONFIGLOCAL=/home/013/m/mx/mxb230055/aos-project1/config.txt
# Directory your compiled classes are in [CHANGE THIS if you move the classes]
BINDIR=$PROJDIR
# Your main project class [CHANGE THIS if you rename the project]
PROG=Node
# extension for hosts [CHANGE THIS if using a different host system (setting to "" should suffice)]
hostExtension="utdallas.edu"
# run command [CHANGE THIS if you want a different pattern or use a different software]
runCommand="java -cp $BINDIR $PROG $CONFIGLOCAL"
# remove $CONFIGLOCAL if you don't want to give your program the configuration file path as an argument
# loop through hosts, remove comment lines starting with # and $ and any carriage returns
n=0
# remove comments | remove other comments | remove carriage returns
cat $CONFIGLOCAL | sed -e "s/#.*//" | sed -e "/^\s*$/d" | sed -e "s/\r$//" |
(
# read the first valid line and collect only the number of hosts
read i
echo $i
ii=$( echo $i| awk '{ print $1 }' )
echo Hosts: $ii
# for each host, loop
while [[ $n -lt $ii ]]
do
# read the port number and host address
read line
p=$( echo $line | awk '{ print $1 }' )
host=$( echo $line | awk '{ print $2 }' )
# add host extension to string if missing from domain name
if [[ "$host" != *"$hostExtension"* ]];
then
host="$host.$hostExtension"
fi
echo $host
# issue command
echo issued command: gnome-terminal -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $netid@$host $runCommand; exec bash" &
gnome-terminal -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $netid@$host $runCommand; exec bash" &
sleep 1
# increment loop counter
n=$(( n + 1 ))
done
)
echo "Launcher complete"