print_usage(){ echo echo "script usage: $(basename $0) [-s node] [-k node] [-m] [-h] " >&2 echo "type: '$(basename $0) -h' for help" } print_help(){ echo echo "$(basename $0): a useless script" echo echo "options:" echo " -s Start the service on the specified node" echo " -k Kill the service on the specified node" echo " -m Monitor function: display all the nodes on which the service is runnig" echo " -h Print this help message" command_parsed=1 return 0 } start_node(){ ssh $1 'sleep 300 &> /dev/null &' #da sostituire con il comando per xfreerdp echo "Service started on $1" #aggiungere la gestione di un nome errato command_parsed=1 return 0 } start_1(){ for i in {0..12} do start_node ${LCM1[i]} done return 0 } start_2(){ for i in {0..14} do start_node ${LCM2[i]} done return 0 } monitor(){ #da migliorare: lentissima! echo "Service running on:" for i in {0..12} do #printf "${LCM1[i]}: " ssh ${LCM1[i]} 'ps aux | grep "sleep 300" | grep -v grep' > /dev/null if [ $? -eq 0 ]; then echo ${LCM1[i]} fi done for i in {0..14} do ssh ${LCM2[i]} 'ps aux | grep "sleep 300" | grep -v grep' > /dev/null if [ $? -eq 0 ]; then echo ${LCM1[i]} fi done command_parsed=1 return 0 } kill_process(){ ssh $1 'pkill sleep' #pericoloso (testato e funzionante con pkill xfreerdp) #aggiungere la gestione di un nome errato command_parsed=1 return 0 } kill_1(){ for i in {0..12} do kill_process ${LCM1[i]} done return 0 } kill_2(){ for i in {0..14} do kill_process ${LCM2[i]} done return 0 }