SW/ControlSW/Archive/Dirigent/1219BeforeGit/Tools.sh

#!/bin/bash

#./Dirigent.sh -r PingCheck
function PingCheck()
{
    $LogFunctionStart
	for Dev in $ALLDevs;
        do 
            ping -q -c 1 $Dev >/dev/null;
            if [ $? -ne 0 ]; then 
                LogIt "Ping $Dev ...KO, problem"; critical_error "ping $Dev KO";exit 1
            else 
                LogIt "Ping $Dev ...OK;"
            fi;
       done;\
    $LogFunctionEnd
}


#http://192.168.2.116/phppgadmin/

function DataBaseQuerry
{
    echo "$1"|psql -qAt -U golem golem_database #Real
    #echo 100 #Offline
}



function RsyncDevices
{
    for Dev in $RASPs; do
       echo $Dev sync ..
       rsync --copy-links -r -e ssh $GWDirigentDir/Infrastructure/$Dev.sh $GWDirigentDir/Tools.sh $GWDirigentDir/Commons.sh $GWDirigentDir/Drivers golem@$Dev:
    done 
    for Dev in $DASs; do
       echo $Dev sync ..
       cp $GWDirigentDir/DASs/$Dev.sh ~/
    done 
    echo Jeste Dirigent, Web, Miscs   sync ..
    cp -r -v $GWDirigentDir/Dirigent.sh $GWDirigentDir/Web.sh $GWDirigentDir/Tools.sh $GWDirigentDir/Commons.sh $GWDirigentDir/Drivers/ $GWDirigentDir/Infrastructure/  ~/
}

function RsyncDeviceFromDirigent
{
      echo "Syncing $ThisDev.sh ."
      rsync golem@Dirigent:$GWDirigentDir/$SUBDIR/$ThisDev.sh .
      rsync golem@Dirigent:$GWDirigentDir/Commons.sh .
      rsync golem@Dirigent:$GWDirigentDir/Tools.sh .
}




function mRelax
{
    sleep 0.1
}


function Relax
{
    sleep 1
}

#./Dirigent.sh -k
function KillAllGMs
{
    killall -u golem
}

function EditHosts
{
    for Dev in Dirigent $RASPs; do echo doing Dev: $Dev; ssh golem@$Dev -Y xterm -e "sudo emacs -nw /etc/hosts";done
}