#! /bin/sh #---------------------------------------------------------------------------------- # /var/install/bin/telegram-control - control process to monitor telegram-cli # # Copyright (c) 2016-2023 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2016-02-22 jed # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------------- # read eislib . /var/install/include/eislib #exec 2>/tmp/telegram-control-trace-$$.log #set -x interval=20 # start control process if [ -f /var/run/telegram-control.start ] then while [ 1 ] do { if [ -f /var/run/telegram-restart-request ] then # stop process /usr/sbin/service stop telegram /usr/bin/logger -p "local0.warning" -t "telegram" "process control has stopped telegram-cli as requested!" sleep 2 rm -f /var/run/telegram-restart-request fi # check if spamd process is running pid=`pgrep "telegram-cli"` if [ -z "${pid}" ] then # no - restart process /usr/sbin/service --quiet start telegram /usr/bin/logger -p "local0.warning" -t "telegram" "process control has restarted telegram-cli!" sleep 2 fi } > /dev/null sleep ${interval} done & else mecho --info "Please use the service command to start/stop or restart the telegram-cli process." fi