[UPDATE] - refact deb + generate
This commit is contained in:
parent
192382c8c2
commit
d4300b4ca5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
client/web/index.html
|
client/web/index.html
|
||||||
|
./build
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
cd $(dirname $0)
|
|
||||||
|
|
||||||
SondeFile=$(pwd)/sonde.cfg
|
|
||||||
source service.cfg
|
|
||||||
source functions
|
|
||||||
ConfFile=$1
|
|
||||||
|
|
||||||
[[ "${Crypted}" == "yes" ]] && NcCmd="timeout ${TimeOut} cryptcat -k ${LocalPassword} " || NcCmd="timeout ${TimeOut} nc "
|
|
||||||
while [[ ! -f /tmp/endmonitor ]]
|
|
||||||
do
|
|
||||||
if [[ -f /tmp/Monithor_${ConfFile}-tmp ]]
|
|
||||||
then
|
|
||||||
GenerateWebEnd /tmp/Monithor_${ConfFile}-tmp
|
|
||||||
sleep ${Rotation}
|
|
||||||
else
|
|
||||||
while read DATA
|
|
||||||
do
|
|
||||||
Remote=$(echo $DATA| cut -d"#" -f1| cut -d":" -f1)
|
|
||||||
Port=$(echo $DATA| cut -d"#" -f1| cut -d":" -f2)
|
|
||||||
Cmd=$(echo $DATA| cut -d"#" -f2)
|
|
||||||
Arg=$(echo $DATA| cut -d"#" -f3)
|
|
||||||
Res=$( echo -e "${Cmd}#${Arg}" | eval ${NcCmd} ${Remote} ${Port} 2> /dev/null)
|
|
||||||
Ret=$?
|
|
||||||
GenerateWeb "${Res:-5|No sonde $Cmd on serveur $Remote}" ${Cmd:-Nodata} ${Arg:-Noadata} ${Remote:-Nodata} /tmp/Monithor_${ConfFile}-tmp
|
|
||||||
done < ${ConfFile}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,76 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
PrintRes() {
|
|
||||||
|
|
||||||
echo "$1"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CheckAllEnd() {
|
|
||||||
|
|
||||||
if [[ ! -f /tmp/webmonithor ]]
|
|
||||||
then
|
|
||||||
Total=$1
|
|
||||||
Actual=0
|
|
||||||
for ActualFile in $(find /tmp/ -name Monithor_\*-tmp)
|
|
||||||
do
|
|
||||||
[[ ! -z $(tail -n 1 $ActualFile | grep 'End of') ]] && Actual=$((Actual + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ${Total} -eq ${Actual} ]]
|
|
||||||
then
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>MoniThor on '${RemoteIp}' </title>
|
|
||||||
<meta http-equiv="refresh" content="1" />
|
|
||||||
</head>
|
|
||||||
<title>MONITHOR</title>
|
|
||||||
Date : '$(date +'%Y-%m-%d %H:%M:%S')'
|
|
||||||
<table border="1" color="#FFFFFF">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="4">MoniThor Result</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>' > /tmp/webmonithor
|
|
||||||
|
|
||||||
cat /tmp/Monithor_*-tmp >> /tmp/webmonithor
|
|
||||||
|
|
||||||
echo '
|
|
||||||
</tbody>
|
|
||||||
</table> ' >> /tmp/webmonithor
|
|
||||||
mv /tmp/webmonithor ../web/index.html
|
|
||||||
rm /tmp/Monithor_* -f
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateWebEnd(){
|
|
||||||
echo '<!--End of '$1' '$(pwd)'-->' >> $1
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GenerateWeb(){
|
|
||||||
|
|
||||||
Val=$(echo $1 | cut -d"|" -f1)
|
|
||||||
Txt=$(echo $1 | cut -d"|" -f2)
|
|
||||||
Sonde=$2
|
|
||||||
Arg=$3
|
|
||||||
Remote=$4
|
|
||||||
File=$5
|
|
||||||
Color=red
|
|
||||||
[[ $Val == "0" ]] && Color=green
|
|
||||||
[[ $Val == "1" ]] && Color=yellow
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<tr> <td>'$Remote'</td> <td>'$Sonde'</td> <td>'$Arg'</td> <td style="background-color:'${Color}';" > '$Val' </td> <td> '$Txt'</td> </tr>' >> ${File}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cd $(dirname $0)/../web/
|
|
||||||
source ../conf-client/functions
|
|
||||||
python -m SimpleHTTPServer ${1} &
|
|
||||||
|
|
||||||
|
|
||||||
echo '<html>
|
|
||||||
<head>
|
|
||||||
<title>MoniThor on '${RemoteIp}' </title>
|
|
||||||
<meta http-equiv="refresh" content="1" />
|
|
||||||
</head>
|
|
||||||
<title>MONITHOR</title>
|
|
||||||
|
|
||||||
!!!! Initialization !!!!
|
|
||||||
|
|
||||||
' > index.html
|
|
||||||
|
|
||||||
while [[ ! -f /tmp/endmonitor ]]
|
|
||||||
do
|
|
||||||
if [[ ! -z $(ls -1 /tmp/ | grep Monithor_.*-tmp) ]]
|
|
||||||
then
|
|
||||||
CheckAllEnd $2
|
|
||||||
echo INSIDE
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
source $(dirname $0)/conf-client/service.cfg
|
|
||||||
source $(dirname $0)/conf-client/functions
|
|
||||||
|
|
||||||
if [[ "$1" == "start" ]]
|
|
||||||
then
|
|
||||||
[[ -f /tmp/endmonitor ]] && rm -f /tmp/endmonitor
|
|
||||||
rm /tmp/Monitor* /tmp/webmonithor &> /dev/null
|
|
||||||
|
|
||||||
TotalConfig=$(ls -1 ./conf-client | grep Card_.*\.cfg|wc -l)
|
|
||||||
for Conf in $(ls -1 ./conf-client | grep Card_.*\.cfg)
|
|
||||||
do
|
|
||||||
screen -dmS ${Conf} bash ./conf-client/exec.sh ${Conf}
|
|
||||||
done
|
|
||||||
screen -dmS webserver bash ./conf-client/webserver.sh ${WebPort} $TotalConfig
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$1" == "stop" ]]
|
|
||||||
then
|
|
||||||
killall python &> /dev/null
|
|
||||||
rm /tmp/Monithor* &> /dev/null
|
|
||||||
touch /tmp/endmonitor
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
10.10.10.3:1666#file#/tmp/coucou
|
|
||||||
10.10.10.3:1666#file#/tmp/nop
|
|
||||||
10.10.10.3:1666#file#
|
|
||||||
10.10.10.3:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
10.10.10.4:1666#file#/tmp/coucou
|
|
||||||
10.10.10.4:1666#file#/tmp/nop
|
|
||||||
10.10.10.4:1666#file#
|
|
||||||
10.10.10.4:1666#NotRealSondeName#reboot
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
RemoteIp=10.10.10.3:1666
|
|
||||||
LocalPassword='Evil@MonitoR-666'
|
|
||||||
Crypted=no
|
|
||||||
Rotation=1
|
|
||||||
TimeOut=2
|
|
||||||
WebPort=80
|
|
||||||
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
10.10.10.3:1666#file#/tmp/coucou
|
|
||||||
10.10.10.3:1666#file#/tmp/nop
|
|
||||||
10.10.10.3:1666#file#
|
|
||||||
10.10.10.3:1666#NotRealSondeName#reboot
|
|
||||||
10.10.10.4:1666#file#/tmp/coucou
|
|
||||||
10.10.10.4:1666#file#/tmp/nop
|
|
||||||
10.10.10.4:1666#file#
|
|
||||||
10.10.10.4:1666#NotRealSondeName#reboot
|
|
||||||
67
generate.sh
Executable file
67
generate.sh
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
BinNeed="dpkg-deb realpath"
|
||||||
|
Wai=$(dirname $(realpath $0))
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
|
||||||
|
echo "$0
|
||||||
|
permet de générer les versions de monithor server et client en paquet debian"
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
GetOut () {
|
||||||
|
[[ $1 == "pkg" ]] && echo "Le paquet $2 est nécessaire" && usage 1
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckDep() {
|
||||||
|
for CheckBinNeed in ${BinNeed}
|
||||||
|
do
|
||||||
|
TestCheckBinNeed=$(which $CheckBinNeed)
|
||||||
|
[[ -z $TestCheckBinNeed ]] && GetOut pkg $CheckBinNeed
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
GitVersion() {
|
||||||
|
|
||||||
|
LastTag=$(git tag | sort | head -n1| sed 's/[a-Z]//g')
|
||||||
|
NewTag=${LastTag}-rebuild
|
||||||
|
}
|
||||||
|
|
||||||
|
CpArchName() {
|
||||||
|
cp -Rf monithor-${1} /tmp/monithor-${1}_${2}_all
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SedControl() {
|
||||||
|
sed -i "/^Version/s/:.*/: ${2}/g" /tmp/monithor-${1}_${2}_all/DEBIAN/control
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildDeb(){
|
||||||
|
echo -n "Gen monithor-${1} [$2] : "
|
||||||
|
cd /tmp/ &> /dev/null
|
||||||
|
dpkg-deb --build --root-owner-group monithor-${1}_${2}_all &> /dev/null
|
||||||
|
[[ "$?" -eq "0" ]] && echo "OK" || echo "FAILED"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CleanTemp() {
|
||||||
|
mkdir $Wai/build &> /dev/null
|
||||||
|
mv monithor-*deb $Wai/build
|
||||||
|
rm -Rf monithor-*
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ ! -z $1 ]] && usage
|
||||||
|
|
||||||
|
CheckDep
|
||||||
|
GitVersion
|
||||||
|
|
||||||
|
CpArchName server $NewTag
|
||||||
|
CpArchName client $NewTag
|
||||||
|
SedControl server $NewTag
|
||||||
|
SedControl client $NewTag
|
||||||
|
BuildDeb client $NewTag
|
||||||
|
BuildDeb server $NewTag
|
||||||
|
CleanTemp
|
||||||
@ -1,38 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd $(dirname $0)/conf-server/
|
|
||||||
|
|
||||||
ScriptDir=$(pwd)/scripts/
|
|
||||||
SondeFile=$(pwd)/sonde.cfg
|
|
||||||
source service.cfg
|
|
||||||
|
|
||||||
[[ "${Crypted}" == "yes" ]] && NcCmd="cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort} " || NcCmd="nc -l ${LocalIp} ${LocalPort}"
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
#coproc cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort}
|
|
||||||
coproc eval ${NcCmd}
|
|
||||||
while read -r cmd; do
|
|
||||||
logger "Running $cmd"
|
|
||||||
cpt=0
|
|
||||||
while read DATA
|
|
||||||
do
|
|
||||||
Sonde=$(echo ${DATA}| cut -d"#" -f1)
|
|
||||||
Exec=$(echo ${DATA}| cut -d"#" -f2)
|
|
||||||
RealCmd=$(echo ${cmd} | cut -d"#" -f1)
|
|
||||||
ArgCmd=$(echo ${cmd} | cut -d"#" -f2)
|
|
||||||
if [[ "${RealCmd}" == "$Sonde" ]]
|
|
||||||
then
|
|
||||||
logger "Exec $Exec $Arg $cpt"
|
|
||||||
[ "$1" == '-d' ] && echo "############ Exec $Exec $Arg $cpt" 1>&2
|
|
||||||
bash ${ScriptDir}/${Exec} $ArgCmd
|
|
||||||
cpt=$((cpt+1))
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done < ${SondeFile}
|
|
||||||
[[ "${cpt}" -eq 0 ]] && logger "You Failed $Sonde $Exec $Arg"
|
|
||||||
|
|
||||||
done <&"${COPROC[0]}" >&"${COPROC[1]}"
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
Exit() {
|
|
||||||
|
|
||||||
|
|
||||||
Val=$(echo $1| cut -d"|" -f1)
|
|
||||||
Txt=$(echo $1| cut -d"|" -f2)
|
|
||||||
echo "$Val|$Txt"
|
|
||||||
exit $Val
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
source $(dirname $0)/FunctionOutput
|
|
||||||
|
|
||||||
File="${1}"
|
|
||||||
|
|
||||||
[[ -z ${File} ]] && Exit "5|no argument"
|
|
||||||
|
|
||||||
|
|
||||||
[[ -f ${File} ]] && Exit "0|File $File exist" || Exit "2|File $File is NOT present"
|
|
||||||
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
LocalIp=127.0.0.1
|
|
||||||
LocalPort=8080
|
|
||||||
#########
|
|
||||||
Crypted=no
|
|
||||||
LocalPassword='Evil@MonitoR-666'
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
network#ip.sh
|
|
||||||
file#file-present.sh
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user