[UPDATE] - add debian package and rebuild
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
ScriptDir=/usr/local/bin/monithor-server.d/
|
||||
SondeFile=/etc/monithor-server/sonde.cfg
|
||||
source /etc/monithor-server/service.cfg
|
||||
|
||||
[[ "${Crypted}" == "yes" ]] && NcCmd="cryptcat -k ${LocalPassword} -l ${LocalIp} -p ${LocalPort} " || NcCmd="nc -l ${LocalIp} ${LocalPort}"
|
||||
|
||||
if [[ "${1}" == "start" ]]
|
||||
then
|
||||
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 &
|
||||
fi
|
||||
|
||||
if [[ "${1}" == "stop" ]]
|
||||
then
|
||||
|
||||
for Pid in $(ps axf| grep -E 'nc -l|monithor-server' | grep -v grep | awk '{print $1}' | sort )
|
||||
do
|
||||
kill ${Pid}
|
||||
done
|
||||
fi
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
Exit() {
|
||||
|
||||
|
||||
Val=$(echo $1| cut -d"|" -f1)
|
||||
Txt=$(echo $1| cut -d"|" -f2)
|
||||
echo "$Val|$Txt"
|
||||
exit $Val
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
#!/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"
|
||||
|
||||
Reference in New Issue
Block a user