Skip to content

Instantly share code, notes, and snippets.

@AzimsTech
Last active March 14, 2024 17:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AzimsTech/e73cbc51ee56d3c4a038ebd9badfcbfe to your computer and use it in GitHub Desktop.
Save AzimsTech/e73cbc51ee56d3c4a038ebd9badfcbfe to your computer and use it in GitHub Desktop.
UCI Defaults Templates for TM Unifi ISP

Table of Contents

  1. Basic Setup
  2. Where to Use?
  3. References

Basic Setup

# Beware! This content will be in /rom/etc/uci-defaults/ in plain-text as part of the image.
# Uncomment lines to apply:
#
wlan_name="ssid@unifi"
wlan_password="password"
#
# root_password=""
lan_ip_address="192.168.1.1"
#
pppoe_username="username@unifi"
pppoe_password="password"
vlan="500"

if [ -n "$root_password" ]; then
  (echo "$root_password"; sleep 1; echo "$root_password") | passwd > /dev/null
fi

# Configure LAN
# More options: https://openwrt.org/docs/guide-user/base-system/basic-networking
if [ -n "$lan_ip_address" ]; then
  uci set network.lan.ipaddr="lan_ip_address"
  uci commit network
fi

# Configure WLAN
# More options: https://openwrt.org/docs/guide-user/network/wifi/basic#wi-fi_interfaces
if [ -n "$wlan_name" -a -n "$wlan_password" -a ${#wlan_password} -ge 8 ]; then
  uci set wireless.@wifi-iface[0].encryption='psk2'
  uci set wireless.@wifi-iface[0].ssid="$wlan_name"
  uci set wireless.@wifi-iface[0].key="$wlan_password"
  uci commit wireless
fi

# Configure VLAN
if [ -n "$vlan" ]; then
  uci add network device
  uci set network.@device[-1].type='8021q'
  uci set network.@device[-1].ifname='wan'
  uci set network.@device[-1].vid="$vlan"
  uci set network.@device[-1].name="wan.$vlan"
  uci commit network
fi

# Configure PPPoE
# More options: https://openwrt.org/docs/guide-user/network/wan/wan_interface_protocols#protocol_pppoe_ppp_over_ethernet
if [ -n "$pppoe_username" -a "$pppoe_password" ]; then
  uci set network.wan.proto=pppoe
  uci set network.wan.username="$pppoe_username"
  uci set network.wan.password="$pppoe_password"
  if [ -n "$vlan" ]; then
    uci set network.wan.device="wan.$vlan"
  fi
  uci commit network
fi

⬆️ Go to top

Where to Use?

⬆️ Go to top

References

⬆️ Go to top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment