#!/bin/bash

action="$1"

CONFPATH="/etc/speaker.conf"

case ${action} in
    set_rtsp)
        rtsp_access="`sysconf ${CONFPATH} get ipc rtsp_access`"
        if [ "foo${rtsp_access}" = "fooyes" ];then
            echo "1" > /proc/sys/net/ipv4/ip_forward
            iptables -F && iptables -t nat -F
            iptables -t nat -A PREROUTING  -p tcp --dport 554 -j DNAT --to-destination 10.231.132.139:554
            exit 0
        else
            echo "0" > /proc/sys/net/ipv4/ip_forward
            iptables -F && iptables -t nat -F
            exit 0
        fi
    ;;

    set_yaml)
        sed -i '/^!!omap/d' /tmp/conf
        sed -i 's/!!omap//g' /tmp/conf
        sed -i 's/^- //g' /tmp/conf
        sed -i 's/^  - /  /g' /tmp/conf
    ;;

    *)
        exit 0
    ;;
esac