OpenWrt Forum Archive

Topic: Can I script changes to network, wireless and dnsmasq.conf in 1 file?

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm playing around with the builds on a regular basis but have many settings that I need to apply every time.
Would it be possible to create one master file which can
* Set the wan network settings (pppoe/username/password)
* Change the wireless settings
* add a line to dnsmasq.conf
* add redirects to the firewall

I also add a authorised_keys file in dropbear...

Uploading file is no problem, especially not after the authorised key has been added.

Thanks.

You can use the files folder in your toplevel build directory and/or use a uci-defaults script..

Here's the UCI script I use to set some stuff in my build:

#!/bin/sh

uci batch <<EOF

set system.@system[0].zonename='Europe/Oslo'
set system.@system[0].timezone='CET-1CEST,M3.5.0,M10.5.0/3'
set system.@system[0].log_size='64'
set system.@system[0].cronloglevel='9'

set network.vpn='interface'
set network.vpn.proto='none'
set network.vpn.ifname='tun0'

set network.tor='interface'
set network.tor.proto='static'
set network.tor.ipaddr='192.168.2.1'
set network.tor.netmask='255.255.255.0'

delete dhcp.@dnsmasq[0].resolvfile
set dhcp.@dnsmasq[0].noresolv='1'
add_list dhcp.@dnsmasq[0].addnhosts='/etc/hosts.block'
add_list dhcp.@dnsmasq[0].server='127.0.0.1#5353'
add_list dhcp.@dnsmasq[0].server='/0.openwrt.pool.ntp.org/8.8.8.8'
add_list dhcp.@dnsmasq[0].server='/1.openwrt.pool.ntp.org/8.8.8.8'
add_list dhcp.@dnsmasq[0].server='/2.openwrt.pool.ntp.org/8.8.8.8'
add_list dhcp.@dnsmasq[0].server='/3.openwrt.pool.ntp.org/8.8.8.8'

set dhcp.tor='dhcp'
set dhcp.tor.interface='tor'
set dhcp.tor.start='100'
set dhcp.tor.limit='150'
set dhcp.tor.leasetime='12h'

set uhttpd.pixelserv='uhttpd'
set uhttpd.pixelserv.listen_http='81'
set uhttpd.pixelserv.home='/www_blank'
set uhttpd.pixelserv.error_page='/blank.gif'

set wireless.@wifi-device[0].country='00'
set wireless.@wifi-device[0].disabled='0'
set wireless.@wifi-device[0].log_level='3'

set wireless.@wifi-iface[0].encryption='psk2'
set wireless.@wifi-iface[0].key='changeme'
set wireless.@wifi-iface[0].wps_pushbutton='0'

set wireless.@wifi-device[1].country='00'
set wireless.@wifi-device[1].disabled='0'
set wireless.@wifi-device[1].log_level='3'

set wireless.@wifi-iface[1].encryption='psk2'
set wireless.@wifi-iface[1].key='changeme'
set wireless.@wifi-iface[1].wps_pushbutton='0'

set wireless.tor='wifi-iface'
set wireless.tor.network='tor'
set wireless.tor.mode='ap'
set wireless.tor.ssid='OpenWrt Tor'
set wireless.tor.encryption='psk2'
set wireless.tor.key='changeme'
set wireless.tor.disabled='1'

commit
EOF

All the things you mention can be done with UCI except editing dnsmasq.conf which can be done with echo and a pipe or editing the default before building.

Thanks arokh & written_direcon, that was exactly what I needed!

(Last edited by johanrd on 7 Nov 2014, 08:43)

The discussion might have continued from here.