Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- _script="$(readlink -f ${BASH_SOURCE[0]})"
- _base="$(dirname $_script)"
- cd $_base
- . isbilling.conf
- if [ ! -z "$1" ]; then
- echo $1 | /usr/bin/nc $bindhost $bindport
- exit
- fi
- cd $workdir
- # redirecting errors to file
- exec 2>> logs/error.log
- # functions
- . inc/func.sh
- toLog INFO "started"
- function checksum_tables() {
- # checking tarifs,vgroups,staff in lb_base
- action=$(execExt scripts/checksum_tables)
- if [ "$action" == "1" ]; then
- toLog INFO "tables has changed"
- fi
- catchError "checksum_tables"
- }
- function asr_tasks() {
- # checking asr tasks from asr_tasks in lb_base
- tasks=$(execExt scripts/asr_tasks)
- if [ "$tasks" != "0" ]; then
- toLog INFO "executed $tasks tasks on ASR"
- fi
- catchError "asr_tasks"
- }
- function dpi_tasks() {
- # checking dpi tasks from dpi_tasks in lb_base
- tasks=$(execExt scripts/dpi_tasks)
- if [ "$tasks" != "0" ]; then
- toLog INFO "executed $tasks tasks on DPI"
- fi
- catchError "dpi_tasks"
- }
- function wrapper() {
- while true; do
- signal=""
- read -t 1 signal
- case "$signal" in
- all)
- toLog INFO "forced all by signal"
- checksum_tables
- asr_tasks
- dpi_tasks
- ;;
- asr_tasks)
- toLog INFO "forced asr_tasks by signal"
- asr_tasks
- ;;
- dpi_tasks)
- toLog INFO "forced dpi_tasks by signal"
- dpi_tasks
- ;;
- esac
- sleep 1
- sleeping=$((sleeping+2))
- if [ "$sleeping" == "$sleeptime" ]; then
- checksum_tables
- asr_tasks
- dpi_tasks
- sleeping=0
- fi
- done
- }
- coproc WRAP { wrapper; }
- writePID $$
- while true; do
- nc -l -k $bindhost $bindport <&${WRAP[0]} >&${WRAP[1]}
- sleep 1
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement