OpenWrt-Tools/DynDNS/install.sh

27 lines
782 B
Bash

# Download scripts
mkdir /root/dyndns
wget https://git.znachor.cz/znachor/OpenWrt-Tools/raw/branch/master/DynDNS/ip.lua -O /root/dyndns/ip.lua
wget https://git.znachor.cz/znachor/OpenWrt-Tools/raw/branch/master/DynDNS/dyndns.lua -O /root/dyndns/dyndns.lua
# Download lua bit library
opkg update
opkg install luabitop
# Set local domain
domain=$(uci get dhcp.@dnsmasq[0].domain)
sed -i "s/.lan/.$domain/gi" /root/dyndns/dyndns.lua
# Create dhcp script
echo "cd /root/dyndns/ && lua dyndns.lua" > /root/dyndns/dyndns.sh
# Allow execution
chmod +x /root/dyndns/*.*
# Add dhcpscript to the config
uci set dhcp.@dnsmasq[0].dhcpscript='/root/dyndns/dyndns.sh'
# Add addnlist to the config
uci set dhcp.@dnsmasq[0].addnhosts='/tmp/dyndns'
# Reload dnsmasq
/etc/init.d/dnsmasq reload