#!/bin/bash wd_c=0 free_c=0 time_wait_c=0 start() { while [ 1 ] do HTTPD_STAT="`ps|grep speaker-cgi|grep -v grep`" if [ -z "${HTTPD_STAT}" ];then killall speaker-cgi > /dev/null 2>&1 sleep 1 /etc/scripts/httpd.sh start wd_c=`expr $wd_c + 1` fi APIAGENT_STAT="`ps|grep api_agent|grep -v grep`" if [ -z "${APIAGENT_STAT}" ];then /etc/scripts/api_agent & fi AICTRL_STAT="`ps|grep serial_ctrl|grep -v grep`" if [ -z "${AICTRL_STAT}" ];then HWVer="`sysconf /etc/speaker.conf get system hard_version`" if [ ${HWVer:3:1} -ge 3 ];then /etc/scripts/shell_action.sh ai start fi fi REDIS_STAT="`ps|grep 'redis-server'|grep -v grep`" if [ -z "${REDIS_STAT}" ];then /usr/sbin/redis-server /etc/redis.conf > /dev/null 2>&1 & wd_c=`expr $wd_c + 1` fi OUTPUTCTRL_STAT="`ps|grep output_control|grep -v grep`" if [ -z "${OUTPUTCTRL_STAT}" ];then /etc/scripts/output_control & fi PROCESS_STAT="`ps|grep service_process|grep -v grep`" if [ -z "${PROCESS_STAT}" ];then /etc/scripts/service_process & fi ISPEAKER_STAT="`ps|grep -w "python3 /app/ispeaker-service/ispeaker" |grep -v grep`" if [ -z "${ISPEAKER_STAT}" ];then ISPEAKER_ENABLE="`sysconf /etc/speaker.conf get system broadcast_service`" SIP_ENABLE="`sysconf /etc/speaker.conf get account_info_1 enable`" MULTICAST_ENABLE="`sysconf /etc/speaker.conf get multicast_player enable`" if [ "foo${ISPEAKER_ENABLE}" = "fooyes" -a "foo${SIP_ENABLE}" = "fooyes" ] || [ "foo${MULTICAST_ENABLE}" = "fooyes" ];then if [ "foo${ISPEAKER_ENABLE}" = "fooyes" -a "foo${SIP_ENABLE}" = "fooyes" ];then killall ptpd2 > /dev/null 2>&1 /etc/scripts/shell_action.sh startSyncTimeToIPAC else killall ptpd2 > /dev/null 2>&1 fi killall ispeaker > /dev/null 2>&1 # sleep 1 /etc/scripts/ispeaker start wd_c=`expr $wd_c + 1` fi fi WAIT_STAT=$(netstat -apn | grep 1883 | awk '{print $6}' | tr -d ' ') if ! echo "$WAIT_STAT" | grep -q "ESTABLISHED" && echo "$WAIT_STAT" | grep -Eq "TIME_WAIT|CLOSE_WAIT|SYN_SENT|FIN_WAIT1"; then time_wait_c=`expr $time_wait_c + 1` if [ $time_wait_c -gt 3 ];then ISPEAKER_ENABLE="`sysconf /etc/speaker.conf get system broadcast_service`" SIP_ENABLE="`sysconf /etc/speaker.conf get account_info_1 enable`" if [ "foo${ISPEAKER_ENABLE}" = "fooyes" -a "foo${SIP_ENABLE}" = "fooyes" ];then killall ispeaker > /dev/null 2>&1 sleep 1 /etc/scripts/ispeaker start sleep 3 time_wait_c=0 fi fi else time_wait_c=0 fi PTP_STAT="`ps|grep -w ptpd2|grep -v grep`" if [ -z "${PTP_STAT}" ];then PTP_ENABLE="`sysconf /etc/speaker.conf get ptp enable`" if [ "foo${PTP_ENABLE}" = "fooyes" ];then ISPEAKER_ENABLE="`sysconf /etc/speaker.conf get system broadcast_service`" SIP_ENABLE="`sysconf /etc/speaker.conf get account_info_1 enable`" if [ "foo${ISPEAKER_ENABLE}" = "foono" -o "foo${SIP_ENABLE}" = "foono" ];then killall ptpd2 > /dev/null 2>&1 /etc/scripts/shell_action.sh startSyncTimeToPtpServer fi else ISPEAKER_ENABLE="`sysconf /etc/speaker.conf get system broadcast_service`" SIP_ENABLE="`sysconf /etc/speaker.conf get account_info_1 enable`" if [ "foo${ISPEAKER_ENABLE}" = "fooyes" -a "foo${SIP_ENABLE}" = "fooyes" ];then killall ptpd2 > /dev/null 2>&1 /etc/scripts/shell_action.sh startSyncTimeToIPAC fi fi fi ONVIFSERVER_STAT="`ps|grep -w onvifserver|grep -v grep`" RTSPSERVER_STAT="`ps|grep -w rtspserver|grep -v grep`" if [ -z "${ONVIFSERVER_STAT}" -o -z "${RTSPSERVER_STAT}" ];then ONVIF_ENABLE="`sysconf /etc/speaker.conf get onvif enable`" if [ "foo${ONVIF_ENABLE}" = "fooyes" ];then /etc/scripts/shell_action.sh set_onvif fi fi SIPPHONE_STAT="`ps|grep baresip|grep -v grep`" SIPSEV_STAT="`ps|grep 'bareservice'|grep -v grep`" if [ -z "${SIPPHONE_STAT}" -o -z "${SIPSEV_STAT}" ];then killall baresip > /dev/null 2>&1 killall bareservice > /dev/null 2>&1 # sleep 1 /etc/scripts/sipphone.sh start wd_c=`expr $wd_c + 1` fi ONVIF_STAT="`ps|grep 'onvif-discover'|grep -v grep`" if [ -z "${ONVIF_STAT}" ];then /etc/scripts/onvif-discover > /dev/null 2>&1 & fi EQ_STAT="`ps|grep 'eq_drc_process'|grep -v grep`" if [ -z "${EQ_STAT}" ];then /usr/bin/eq_drc_process > /dev/null 2>&1 & fi SPEAKER_CONF_ERROR_STAT="`grep "\['" /oem/etc/speaker.conf`" if [ ! -z "${SPEAKER_CONF_ERROR_STAT}" ];then sed -i "s/\['//g" /oem/etc/speaker.conf sed -i "s/'\]//g" /oem/etc/speaker.conf sed -i "s/', '//g" /oem/etc/speaker.conf sync fi VOLUME_CONF_ERROR_STAT="`grep "\['" /oem/etc/volctrl.conf`" if [ ! -z "${VOLUME_CONF_ERROR_STAT}" ];then sed -i "s/\['//g" /oem/etc/volctrl.conf sed -i "s/'\]//g" /oem/etc/volctrl.conf sed -i "s/', '//g" /oem/etc/volctrl.conf sync fi [ $wd_c -gt 10 ] && /sbin/reboot sleep 15 done } stop() { # stop sipphone /etc/scripts/sipphone.sh stop # stop ispeaker killall ispeaker > /dev/null 2>&1 killall service_process > /dev/null 2>&1 killall api_agent > /dev/null 2>&1 killall ptpd2 > /dev/null 2>&1 killall onvifserver > /dev/null 2>&1 killall rtspserver > /dev/null 2>&1 } restart() { stop sleep 2 start& } reload() { stop sleep 2 start& } case "$1" in start) start ;; stop) stop ;; restart|reload) restart ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit $?