<commit_before>#!/bin/sh

## Network Configuration
. network.conf

## Fix Missing DNS Servers
uci set network.lan.dns="$DNS_SERVERS"
uci commit
/etc/init.d/network restart

## Update & Install Packages
opkg update
opkg install qos-scripts ddns-scripts miniupnpd uhttpd-mod-tls curl l7-protocols kmod-leds-wndr3700-usb luci-ssl luci-app-qos

## System Configuration
uci set system.@system[0].hostname="$HOST_NAME"
uci set system.@system[0].zonename="$TIMEZONE_NAME"
uci set system.@system[0].timezone="$TIMEZONE"

## IP Address
uci set network.lan.ipaddr="$HOST_IP_ADDRESS"
uci set network.lan.netmask="$HOST_NETMASK"

## Remove Default Wireless Setup
uci delete wireless.@wifi-iface[1]
uci delete wireless.@wifi-iface[0]

## Radio [2GHz]
uci set wireless.radio0.hwmode=11ng
uci set wireless.radio0.htmode=HT40-
uci set wireless.radio0.txpower=22
uci set wireless.radio0.channel=6
uci delete wireless.radio0.disabled

## Radio [5GHz]
uci set wireless.radio1.country="$COUNTRY"

## Wifi [2GHz]
uci add wireless wifi-iface
uci set wireless.@wifi-iface[-1].device=radio0
uci set wireless.@wifi-iface[-1].mode=ap
uci set wireless.@wifi-iface[-1].ssid="$WIFI1_SSID"
uci set wireless.@wifi-iface[-1].key="$WIFI1_KEY"
uci set wireless.@wifi-iface[-1].encryption=psk-mixed
uci set wireless.@wifi-iface[-1].network=lan

## Create DHCP & Hostname list
DEVICE_LIST=$(cat $DEVICES_FILE | grep -v '^#\|^$')
IFS=$'\12'
for d in $DEVICE_LIST
	do
		d_host=$(echo $d | awk '{ print $1 }')
		d_ip=$(echo $d | awk '{ print $2 }')
		d_mac=$(echo $d | awk '{ print $3 }')	
		
		if [ -n "$d_host" -a -n "$d_mac" -a -n "$d_ip" ]; then
			uci add dhcp host
			uci set dhcp.@host[-1].name=$d_host
			uci set dhcp.@host[-1].mac=$d_mac
			uci set dhcp.@host[-1].ip=$d_ip
		fi
		
		if [ -n "$d_host" -a -n "$d_ip" ]; then
			uci add dhcp domain
			uci set dhcp.@domain[-1].name=$d_host
			uci set dhcp.@domain[-1].ip=$d_ip
		fi
	done

## Firewall Redirects
uci add firewall redirect
uci set firewall.@redirect[0]._name=ssh_desktop
uci set firewall.@redirect[-1].src=wan
uci set firewall.@redirect[-1].src_dport="$REDIRECT_EXTERNAL_PORT"
uci set firewall.@redirect[-1].dest_ip="$REDIRECT_INTERNAL_IP"
uci set firewall.@redirect[-1].dest_port="$REDIRECT_INTERNAL_PORT"
uci set firewall.@redirect[-1].proto=tcp

## Disable uhttp on port 80
uci delete uhttpd.main.listen_http

## uhttpd Keys
uci set uhttpd.px5g.commonname="$HOST_NAME"<commit_msg>add DNS server to dhcp<commit_after>#!/bin/sh

## Network Configuration
. network.conf

## Fix Missing DNS Servers
uci set network.lan.dns="$DNS_SERVERS"
uci commit
/etc/init.d/network restart

## Update & Install Packages
opkg update
opkg install qos-scripts ddns-scripts miniupnpd uhttpd-mod-tls curl l7-protocols kmod-leds-wndr3700-usb luci-ssl luci-app-qos

## System Configuration
uci set system.@system[0].hostname="$HOST_NAME"
uci set system.@system[0].zonename="$TIMEZONE_NAME"
uci set system.@system[0].timezone="$TIMEZONE"

## IP Address
uci set network.lan.ipaddr="$HOST_IP_ADDRESS"
uci set network.lan.netmask="$HOST_NETMASK"

## Remove Default Wireless Setup
uci delete wireless.@wifi-iface[1]
uci delete wireless.@wifi-iface[0]

## Radio [2GHz]
uci set wireless.radio0.hwmode=11ng
uci set wireless.radio0.htmode=HT40-
uci set wireless.radio0.txpower=22
uci set wireless.radio0.channel=6
uci delete wireless.radio0.disabled

## Radio [5GHz]
uci set wireless.radio1.country="$COUNTRY"

## Wifi [2GHz]
uci add wireless wifi-iface
uci set wireless.@wifi-iface[-1].device=radio0
uci set wireless.@wifi-iface[-1].mode=ap
uci set wireless.@wifi-iface[-1].ssid="$WIFI1_SSID"
uci set wireless.@wifi-iface[-1].key="$WIFI1_KEY"
uci set wireless.@wifi-iface[-1].encryption=psk-mixed
uci set wireless.@wifi-iface[-1].network=lan

## Create DHCP & Hostname list
DEVICE_LIST=$(cat $DEVICES_FILE | grep -v '^#\|^$')
IFS=$'\12'
for d in $DEVICE_LIST
	do
		d_host=$(echo $d | awk '{ print $1 }')
		d_ip=$(echo $d | awk '{ print $2 }')
		d_mac=$(echo $d | awk '{ print $3 }')	
		
		if [ -n "$d_host" -a -n "$d_mac" -a -n "$d_ip" ]; then
			uci add dhcp host
			uci set dhcp.@host[-1].name=$d_host
			uci set dhcp.@host[-1].mac=$d_mac
			uci set dhcp.@host[-1].ip=$d_ip
		fi
		
		if [ -n "$d_host" -a -n "$d_ip" ]; then
			uci add dhcp domain
			uci set dhcp.@domain[-1].name=$d_host
			uci set dhcp.@domain[-1].ip=$d_ip
		fi
	done

##Sending DNS list to clients
dhcp.@dnsmasq[0].server="$DNS_SERVERS"

## Firewall Redirects
uci add firewall redirect
uci set firewall.@redirect[0]._name=ssh_desktop
uci set firewall.@redirect[-1].src=wan
uci set firewall.@redirect[-1].src_dport="$REDIRECT_EXTERNAL_PORT"
uci set firewall.@redirect[-1].dest_ip="$REDIRECT_INTERNAL_IP"
uci set firewall.@redirect[-1].dest_port="$REDIRECT_INTERNAL_PORT"
uci set firewall.@redirect[-1].proto=tcp

## Disable uhttp on port 80
uci delete uhttpd.main.listen_http

## uhttpd Keys
uci set uhttpd.px5g.commonname="$HOST_NAME"
{'fraction_non_alphanumeric': 0.15345424903199512, 'fraction_numerical': 0.02221316486651722, 'mean_word_length': 4.706976744186046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3259063', 'n_tokens_mistral': 2044, 'n_tokens_neox': 1940, 'n_words': 439}