Speech:Spring 2016 X-10 Code

All files should be placed into the 'bin' directory.

=File: myping.sh= ping -c 1 "$1" >/dev/null
 * 1) !/bin/sh

=File: X10=
 * 1) !/bin/bash

asterix=192.168.1.1 obelix=192.168.1.2 miraculix=192.168.1.3 traubadix=192.168.1.1 majestix=192.168.1.1 idefix=192.168.1.1 automatix=192.168.1.1 brutus=192.168.1.1 rome=192.168.1.1 test=10.0.0.113
 * 1) Definitions of IP addresses
 * 1) End of host list

while [ "$host" != "quit" ]; do echo "Please choose a server to connect to:"

select choice in "Asterix" "Obelix" "Miraculix" "Test Server"; do case $choice in   	"Asterix")    echo "Attempting to connect to Asterix..."    if myping.sh $asterix; then   	 #Server is on and responding to pings   	 echo "Asterix is alive."   	 echo "Do you want to connect? yes/no"   	 #The next if statement will trigger the SSH command.   	 read input3   	 if [ "$input3" = "yes" ]; then   		 echo "Now connecting to Asterix…"   		 ssh $asterix   	 #Should trigger the off function for heyu if requested       	 else   		 echo "Do you want to turn this server off? yes/no"   		 read inputoff   		 if [ "$inputoff" = "yes" ]; then   			 #Turn off corresponding server module.   			 heyu foff #Whatever the module is   		 fi #end of inputoff   	 fi # end of input3    else   	 #Server is off or unresponsive to ping   	 echo "Asterix is offline. Do you want to turn it on? yes/no"   	 read input2 if [ "$input2" = "yes" ]; then # This will call ‘heyu’ to turn on the # module, then wait for bootup, # before finally doing an SSH into the system echo "Turning on power. Waiting for bootup." heyu fon M1  		 #Wait roughly ten minutes for bootup, change if too #long of a wait. It depends on the server. sleep 300 echo "Connecting to Asterix…" ssh $asterix fi # End of input2 fi # End of outer if statement for Asterix
 * #End of Asterix Select

"Obelix")   	#Example    echo "Obelix"

"Miraculix")   	#Example    echo "Miraculix"

"Test Server")   echo "Attempting to connect to Test Server..."    if myping.sh $test; then   	 #Server is on and responding to pings   	 echo "Test Server is alive."   	 echo "Do you want to connect? yes/no"   	 #The next if statement will trigger the SSH command.   	 read input3   	 if [ "$input3" = "yes" ]; then   		 echo "Now connecting to Test Server…"   		 ssh $test      	 else   		 #Should trigger the off function for   		 #heyu if requested       		 echo "Do you want to turn this server off? yes/no"   		 read inputoff   		 if [ "$inputoff" = "yes" ]; then   			 # Turn off corresponding server module.   			 heyu foff M1 #Whatever the module is   		 fi   	 fi    else   	 #Server is off or unresponsive to ping   	 echo "Test Server is offline. Do you want to turn it on? yes/no"   	 read input2   	 if [ "$input2" = "yes" ]; then   		 # This will call ‘heyu’ to turn on the   		 # module, then wait for bootup, # before finally doing an SSH into the system echo "Turning on power. Waiting for bootup." heyu fon M1  		 #Wait roughly ten minutes for bootup, change if too #long of a wait. It depends on the server. sleep 300 echo "Connecting to Test Server…" ssh $test fi   fi # End of outer if statement for Test Server
 * #End of Test ServerSelect

esac done #select statement done #while statement