Browse Source

First commit

Nicolo' Palazzini 5 years ago
commit
665ac249f3
3 changed files with 97 additions and 0 deletions
  1. 2 0
      conf
  2. 48 0
      echoctl
  3. 47 0
      functions

+ 2 - 0
conf

@@ -0,0 +1,2 @@
+LCM1=(abe crash duke glados lara link king pang pong snake sonic spyro yoshi)
+LCM2=(actarus elwood gex gin jake kirk martini picard q raziel sarek spock tron worf zombie)

+ 48 - 0
echoctl

@@ -0,0 +1,48 @@
+#!/bin/bash
+
+set -e
+set -u
+set -o pipefail
+
+command_parsed=0
+
+. functions
+. conf
+
+while getopts 'h12an:' OPTION; do
+  case "$OPTION" in
+	n)
+		node=$OPTARG
+		call_node node
+   	  	;;
+    	
+	1)
+		call_1
+		;;
+	2)
+		call_2
+		;;
+    a)
+		call_1
+		call_2
+		;;
+	h)
+		print_help      
+		;;
+    ?)
+		print_usage
+		exit 1
+ 		command_parsed=1
+	    ;;
+    :)
+      	echo "cosa fa?"
+      	;;
+  esac
+done
+
+if [ $command_parsed -eq 0 ]
+then
+    print_usage
+fi
+
+#shift "$(($OPTIND -1))"

+ 47 - 0
functions

@@ -0,0 +1,47 @@
+print_usage(){
+	echo
+	echo "script usage: $(basename $0) [-n node] [-a] [-1] [-2] [-h] " >&2
+	echo "type: '$(basename $0) -h' for help"
+	return 0
+}
+
+print_help(){
+	echo
+	echo "$(basename $0): a useless script"
+	echo
+	echo "options:"
+	echo "  -n Print the hostname of the specified node"
+	echo "  -a Print the hostname of all nodes"
+	echo "  -1 Print the hostname of all nodes in LCM1"
+	echo "  -2 Print the hostname of all nodes in LCM2"
+	echo "  -h  Print this help message"
+	command_parsed=1
+
+
+	return 0
+}
+
+call_node(){
+	printf "$1 says: "
+	ssh $1 'hostname' #come si fa a non mostrare il messaggio?
+	
+		
+	command_parsed=1
+
+}
+
+call_1(){
+	for i in {0..12}
+		do
+  	 		call_node ${LCM1[i]}
+		done
+	command_parsed=1
+}
+
+call_2(){
+	for i in {0..14}
+		do
+			call_node ${LCM2[i]}
+		done
+	command_parsed=1	
+}