Skip to content
Snippets Groups Projects
Commit 849498f4 authored by Jonas Höglund's avatar Jonas Höglund Committed by Yalu Zhang
Browse files

mcast-pa: Simplify startup

parent c7c05a76
Branches
No related tags found
No related merge requests found
...@@ -51,26 +51,11 @@ define Package/mcast-pa/install ...@@ -51,26 +51,11 @@ define Package/mcast-pa/install
$(INSTALL_DIR) $(1)/sbin $(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mcast-pa $(1)/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mcast-pa $(1)/sbin/
$(INSTALL_DIR) $(1)/usr/prpl/scripts
$(CP) ./files/usr/prpl/scripts/* $(1)/usr/prpl/scripts/
##
# install iptv scripts from here now too
#
# NOTE: these should probably be in their own package
##
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/etc/init.d/iptv $(1)/etc/init.d/. $(INSTALL_BIN) ./files/etc/init.d/mcast-pa $(1)/etc/init.d/mcast-pa
# HACK / FIXME - don't do this! make a uci-default instead
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_BIN) ./files/etc/config/iptv $(1)/etc/config/.
$(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/etc/uci-defaults/mcast-pa $(1)/etc/uci-defaults/99-mcast-pa $(INSTALL_BIN) ./files/etc/uci-defaults/mcast-pa $(1)/etc/uci-defaults/99-mcast-pa
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_BIN) ./files/etc/hotplug.d/iface/60-iptv $(1)/etc/hotplug.d/iface/.
endef endef
$(eval $(call BuildPackage,mcast-pa)) $(eval $(call BuildPackage,mcast-pa))
config iptv
# valid modes are: bridged | wan2lan | video2lan
option mode 'wan2lan'
config igmp
option fastleave '1'
option force_v2 '1'
config blocks
list entries '(*|239.255.255.0/24)'
list entries '(*|224.0.0.0/24)'
list entries '(*|239.192.0.0/16)'
#!/bin/sh
###############################################################################
# _____ _ ______ _____ #
# / ___| | | | ___ \ __ \ #
# \ `--. _ __ ___ __ _ _ __| |_| |_/ / | \/ #
# `--. \ '_ ` _ \ / _` | '__| __| /| | __ #
# /\__/ / | | | | | (_| | | | |_| |\ \| |_\ \ #
# \____/|_| |_| |_|\__,_|_| \__\_| \_|\____/ Inc. #
# #
###############################################################################
# #
# copyright 2018 by SmartRG, Inc. #
# Santa Barbara, CA #
# #
###############################################################################
# #
# Author: Colin Whittaker #
# #
# Purpose: Reload iptv when changes occur to interfaces other than LAN #
# #
###############################################################################
case $INTERFACE in
lan*)
exit 0
;;
LAN*)
exit 0
;;
esac
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
[ "$ACTION" = ifupdate -a -z "$IFUPDATE_ADDRESSES" -a -z "$IFUPDATE_DATA" ] && exit 0
/etc/init.d/iptv restart
logger -t mcproxy "Reloading iptv due to $ACTION of $INTERFACE ($DEVICE)"
#!/bin/sh /etc/rc.common
###############################################################################
# _____ _ ______ _____ #
# / ___| | | | ___ \ __ \ #
# \ `--. _ __ ___ __ _ _ __| |_| |_/ / | \/ #
# `--. \ '_ ` _ \ / _` | '__| __| /| | __ #
# /\__/ / | | | | | (_| | | | |_| |\ \| |_\ \ #
# \____/|_| |_| |_|\__,_|_| \__\_| \_|\____/ Inc. #
# #
###############################################################################
# #
# copyright 2018 by SmartRG, Inc. #
# Santa Barbara, CA #
# #
###############################################################################
# #
# Author: Colin Whittaker #
# #
# Purpose: Configure mcproxy, mcast-pa and linux bridge based on iptv config #
# #
###############################################################################
START=99
USE_PROCD=1
. /lib/functions/network.sh
clear_section() {
local sec="$1"
while [ $? -eq 0 ]; do
uci delete $sec > /dev/null 2>/dev/null
done
}
setcfg() {
cfg=$1
}
set_instance() {
local name="$1"
local upif="$2"
local downif="br-lan"
local len
local i=1
local val
sec=$(uci add mcproxy instance)
uci set mcproxy.${sec}.name="$name"
uci set mcproxy.${sec}.upstream="$upif"
uci set mcproxy.${sec}.downstream="$downif"
uci set mcproxy.${sec}.disabled='0'
uci get iptv.blocks > /dev/null
if [ $? -eq 0 ]; then
# Make the blocks tables
config_get len blocks entries_LENGTH
[ -z "$len" ] && return 0
sec=$(uci add mcproxy table)
uci set mcproxy.${sec}.name="blocks"
while [ $i -le "$len" ]; do
config_get val blocks entries_ITEM$i
uci add_list mcproxy.${sec}.entries="$val"
i="$((i + 1))"
done
# Add all behaviors
sec=$(uci add mcproxy behaviour)
uci set mcproxy.${sec}.instance="$name"
uci set mcproxy.${sec}.section="upstream"
uci set mcproxy.${sec}.interface="$upif"
uci set mcproxy.${sec}.direction="in"
uci set mcproxy.${sec}.table="blocks"
sec=$(uci add mcproxy behaviour)
uci set mcproxy.${sec}.instance="$name"
uci set mcproxy.${sec}.section="upstream"
uci set mcproxy.${sec}.interface="$upif"
uci set mcproxy.${sec}.direction="out"
uci set mcproxy.${sec}.table="blocks"
sec=$(uci add mcproxy behaviour)
uci set mcproxy.${sec}.instance="$name"
uci set mcproxy.${sec}.section="downstream"
uci set mcproxy.${sec}.interface="$downif"
uci set mcproxy.${sec}.direction="in"
uci set mcproxy.${sec}.table="blocks"
sec=$(uci add mcproxy behaviour)
uci set mcproxy.${sec}.instance="$name"
uci set mcproxy.${sec}.section="downstream"
uci set mcproxy.${sec}.interface="$downif"
uci set mcproxy.${sec}.direction="out"
uci set mcproxy.${sec}.table="blocks"
fi
}
setup_mcpd_config() {
local action=$1
# valid modes are: bridged | video2lan | wan2lan
local iptv_mode
local igmp_v2
config_load iptv
config_foreach setcfg iptv
config_get iptv_mode $cfg mode
config_foreach setcfg igmp
config_get igmp_v2 $cfg "force_v2"
# set IGMP version in bridge
/usr/prpl/scripts/set_force_v2.sh $igmp_v2
# set IGMP version in mcproxy
local mcpd_igmp_ver=""
if [ "$igmp_v2" = '1' ] ; then
mcpd_igmp_ver="IGMPv2"
else
mcpd_igmp_ver="IGMPv3"
fi
uci set mcproxy.mcproxy.protocol="$mcpd_igmp_ver"
logger -p crit -t "iptv" "setup_mcpd_config(): action=$action, mode=$iptv_mode, mcpd_igmp_ver=$mcpd_igmp_ver"
# Clear the old instance table and behaviors
clear_section "mcproxy.@instance[0]"
clear_section "mcproxy.@behaviour[0]"
clear_section "mcproxy.@table[0]"
# set mcpd proxy mode
if [ "$iptv_mode" = "video2lan" ] ; then
uci set mcproxy.mcproxy.disabled='0'
set_instance $iptv_mode "br-video"
elif [ "$iptv_mode" = "wan2lan" ] ; then
uci set mcproxy.mcproxy.disabled='0'
network_get_device upif wan
set_instance $iptv_mode $upif
elif [ "$iptv_mode" = "bridged" ] ; then
# Nothing to do
uci set mcproxy.mcproxy.disabled='1'
else
logger -p crit -t "iptv" "setup_mcpd_config(): bad iptv mode: $iptv_mode"
fi
# Install IGMP blocks into mcproxy
uci commit mcproxy
/etc/init.d/mcproxy restart
logger -p crit -t "iptv" "setup_mcpd_config mcproxy restarted()"
}
start_service() {
logger -p crit -t "iptv" "start_service()"
setup_mcpd_config start
if [ -e /usr/prpl/scripts/mcastpamgr.sh ]; then
/usr/prpl/scripts/mcastpamgr.sh iptv_start
fi
}
boot() {
logger -p crit -t "iptv" "boot()"
start
}
stop_service() {
logger -p crit -t "iptv" "stop_service()"
if [ -e /usr/prpl/scripts/mcastpamgr.sh ]; then
/usr/prpl/scripts/mcastpamgr.sh iptv_stop
fi
}
reload_service() {
logger -p crit -t "iptv" "reload_service()"
stop_service
start_service
}
service_triggers()
{
logger -p crit -t "iptv" "service_triggers()"
procd_add_reload_trigger iptv
}
#!/bin/sh /etc/rc.common
START=90
STOP=90
USE_PROCD=1
NAME=mcast-pa
PROG=/sbin/mcast-pa
start_service() {
# Is mcproxy configured?
wan=$(uci get mcproxy.@instance[0].upstream)
if [ -n $wan ]; then
procd_open_instance
procd_set_param command $PROG --wan $wan
procd_set_param respawn
procd_close_instance
fi
}
service_triggers()
{
procd_add_reload_trigger network mcproxy
}
stop_service()
{
killall mcast-pa
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment