#!/bin/sh /etc/rc.common

START=98
DEBUG_OUTOUT=0

start()
{
    # 兼容5.15的netifd会检测板间通信口的mac导致VoIP单向通信问题
    local lan_macaddr=`uci get network.lan.macaddr`
    [ -n "$lan_macaddr" ] && uci set network.remote.macaddr="$lan_macaddr"
    [ -z "$lan_macaddr" ] && uci set network.remote.macaddr="00:14:78:00:00:00"
    uci commit network
    ubus call network reload
    /etc/init.d/remote_board reload

    if [ ! -c /dev/voip ]; then
        mknod /dev/voip c 214 0
        insmod /lib/modules/5.4.203/voip.ko
    fi
    ln -s /etc/voiceNotify/US /tmp/voiceNotify

    mkdir -p /var/tmp
    mkdir -p /var/voicemail_data
    if [ "x$DEBUG_OUTOUT" != "x0" ]; then
        echo "start voip_server_proxy to /dev/console &" > /dev/console
        nice -n -20 /usr/bin/voip_server_proxy > /dev/console &
    else
        echo "start voip_server_proxy to &" > /dev/console
        nice -n -20 /usr/bin/voip_server_proxy &
    fi
}

stop()
{
    killall -9 voip_server_proxy
}
