#!/bin/bash


mkdir -p /opt/script

# 更换软件源
echo """src/gz openwrt_core http://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.9/targets/ramips/mt76x8/packages
src/gz openwrt_base http://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.9/packages/mipsel_24kc/base
src/gz openwrt_freifunk http://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.9/packages/mipsel_24kc/freifunk
src/gz openwrt_luci http://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.9/packages/mipsel_24kc/luci
src/gz openwrt_packages http://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.9/packages/mipsel_24kc/packages
src/gz openwrt_routing http://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.9/packages/mipsel_24kc/routing
src/gz openwrt_telephony http://mirrors.tuna.tsinghua.edu.cn/openwrt/releases/19.07.9/packages/mipsel_24kc/telephony
""" > /etc/opkg/distfeeds.conf

opkg update &&

opkg install libustream-openssl &&
opkg install coreutils-nohup &&
opkg install luasocket &&

wget -P /opt/script https://file.tyxhetc.cn/multicast_receiver.lua
wget -P /opt/script https://file.tyxhetc.cn/multicast_sender.lua

sed -i '$i\sleep 8\nnohup lua /opt/script/multicast_receiver.lua > /tmp/nohup.out &' /etc/rc.local

nohup lua /opt/script/multicast_receiver.lua > /tmp/nohup.out &
