# B-1300 Buttons functions modifying

**URL:** <https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202>\
**Category:** Router\
**Created:** [March 19, 2020, 8:59am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202 "2020-03-19T08:59:13Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![antifascista](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@antifascista](https://forum.gl-inet.com/u/antifascista)\
**Post date:** [March 19, 2020, 8:59am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/1 "2020-03-19T08:59:13Z")

</div>

Hi.  
In B-1300 there isn’t toggle button like AR 750 o 750S then I’d modify one of the 2 buttons, preferably mesh button, to disable/enable Wireguard VPN client.  
I’have read posts about but referring to other models.  
How can I do this?  
Thanks

---

<div class="post-metadata">

**Author:** ![alzhao](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@alzhao](https://forum.gl-inet.com/u/alzhao)\
**Post date:** [March 19, 2020, 9:50am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/2 "2020-03-19T09:50:28Z")

</div>

Can you check if there is script in /etc/rc.button/ ?

If not pls check /etc/hotplug.d/

---

<div class="post-metadata">

**Author:** ![antifascista](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@antifascista](https://forum.gl-inet.com/u/antifascista)\
**Post date:** [March 19, 2020, 12:08pm UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/3 "2020-03-19T12:08:50Z")

</div>

In /etc/rc.button I have:  
BTN\_0, BTN\_1, failsafe, power, reset and rfkill.  
In /etc/hotplug.d I have:  
30-mesh-button, 40-wsplcd, 50-wps, 51-wps-reset, 52-wps-supplicant, 53-wps-repacd, 54-wps-extender.

---

<div class="post-metadata">

**Author:** ![alzhao](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@alzhao](https://forum.gl-inet.com/u/alzhao)\
**Post date:** [March 19, 2020, 12:10pm UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/4 "2020-03-19T12:10:09Z")

</div>

> [@antifascista](#):
>
> 30-mesh-button

This is the correct file you need to edit to customize the mesh button.

---

<div class="post-metadata">

**Author:** ![antifascista](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@antifascista](https://forum.gl-inet.com/u/antifascista)\
**Post date:** [March 19, 2020, 1:36pm UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/5 "2020-03-19T13:36:59Z")

</div>

Can You e explain to me how I modify it for?  
Do I have to delete all in the file?  
Can I use the content of the file of toggle button of my AR-750? But it’s a switch not a button…  
Thanks

---

<div class="post-metadata">

**Author:** ![alzhao](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@alzhao](https://forum.gl-inet.com/u/alzhao)\
**Post date:** [March 20, 2020, 5:33am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/6 "2020-03-20T05:33:53Z")

</div>

Each router is different. AR750 will have script in /etc/rc.button for the switch button function.

For B1300, you need to check the content of /etc/hotplug.d/30-mesh-button to understand how it works first.

---

<div class="post-metadata">

**Author:** ![antifascista](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@antifascista](https://forum.gl-inet.com/u/antifascista)\
**Post date:** [March 20, 2020, 10:39am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/7 "2020-03-20T10:39:59Z")

</div>

#!/bin/sh

[“$BUTTON” != “wps”] && exit 0

. /lib/functions/gl\_util.sh

random\_psk=  
random\_ssid=

func\_wps\_on(){  
local device disabled mode backhaul\_ap role  
config\_get device “$1” device  
config\_get disabled “$1” disabled  
config\_get mode “$1” mode  
config\_get backhaul\_ap “$1” backhaul\_ap  
role=“`uci get repacd.repacd.Role`”  
index=${device##wifi}  
if [“$mode” = “ap” -a “$disabled” != 1 -a “$backhaul\_ap” = 1 -a “$role” = “CAP”];then  
wps\_settings ${index}  
iwpriv ath${index}1 hide\_ssid 0  
fi  
}

wps\_settings(){  
local index  
index=$1  
if [-z “`grep push_button /var/run/hostapd-ath${index}1.conf`”]; then  
local macaddr=$(cat /sys/class/net/br-lan/address)  
uuid=$(echo “$macaddr” | sed ‘s/://g’)  
echo “eap\_server=1  
wps\_state=2  
ap\_setup\_locked=0  
device\_type=6-0050F204-1  
device\_name=OpenWrt AP  
[manufacturer=openwrt.org](http://manufacturer=openwrt.org)  
model\_name=WAP  
model\_number=123  
serial\_number=12345  
config\_methods=push\_button  
wps\_independent=1  
uuid=87654321-9abc-def0-1234-$uuid”\>\>/var/run/hostapd-ath${index}1.conf  
fi  
wpa\_cli -g /var/run/hostapd/global raw REMOVE ath${index}1  
wpa\_cli -g /var/run/hostapd/global raw ADD bss\_config=ath${index}1:/var/run/hostapd-ath${index}1.conf  
hostapd\_cli -i ath${index}1 -P /var/run/hostapd\_cli-ath${index}1.pid -a /lib/wifi/wps-hostapd-update-uci -p /var/run/hostapd-wifi${index} -B  
echo “timer” \>/sys/class/leds/mesh\_led/trigger  
echo “250” \>/sys/class/leds/mesh\_led/delay\_on  
echo “250” \>/sys/class/leds/mesh\_led/delay\_off  
}  
update\_mac(){  
local macaddr macaddr\_la  
config\_get macaddr “$1” macaddr  
macaddr\_la=$(macaddr\_setbit\_la $macaddr)  
uci set wireless.$1.macaddr=$macaddr\_la  
uci set wireless.$1.repacd\_auto\_create\_vaps=0  
uci commit wireless  
}

set\_up\_backhaul\_vap(){  
local device=$1  
uci batch \<\<EOF  
set wireless.bh\_ap\_$1=wifi-iface  
set wireless.bh\_ap\_$1.device=$1  
set wireless.bh\_ap\_$1.network=‘lan’  
set wireless.bh\_ap\_$1.mode=‘ap’  
set wireless.bh\_ap\_$1.disabled=‘0’  
set wireless.bh\_ap\_$1.repacd\_security\_unmanaged=‘1’  
set wireless.bh\_ap\_$1.wds=‘1’  
set wireless.bh\_ap\_$1.backhaul\_ap=‘1’  
set wireless.bh\_ap\_$1.ssid=$random\_ssid  
set wireless.bh\_ap\_$1.encryption=‘psk-mixed’  
set wireless.bh\_ap\_$1.blockdfschan=‘1’  
set wireless.bh\_ap\_$1.key=$random\_psk  
set wireless.bh\_ap\_$1.athnewind=‘0’  
set wireless.bh\_ap\_$1.hidden=‘1’  
set wireless.bh\_ap\_$1.ifname=ath${device##wifi}1  
EOF  
uci batch \<\<EOF  
set wireless.bh\_sta\_$1=‘wifi-iface’  
set wireless.bh\_sta\_$1.device=$1  
set wireless.bh\_sta\_$1.network=‘lan’  
set wireless.bh\_sta\_$1.mode=‘sta’  
set wireless.bh\_sta\_$1.disabled=‘0’  
set wireless.bh\_sta\_$1.repacd\_security\_unmanaged=‘1’  
set wireless.bh\_sta\_$1.wds=‘1’  
set wireless.bh\_sta\_$1.ssid=$random\_ssid  
set wireless.bh\_sta\_$1.encryption=‘psk-mixed’  
set wireless.bh\_sta\_$1.key=$random\_psk  
set wireless.bh\_sta\_$1.ifname=ath${device##wifi}2  
EOF  
uci commit wireless  
}

update\_vap\_config(){  
uci set wireless.$1.backhaul\_ap=0  
uci set wireless.$1.backhaul=0  
uci commit wireless  
}

get\_mesh\_role() {  
local role  
[“`swconfig dev switch0 show | grep port | grep "port:5 link:up" |wc -l`” -gt 0] && role=CAP || role=NonCAP  
echo “$role”  
}

mesh\_role(){  
local role  
if [“`uci get repacd.repacd.Enable`” = 0]; then  
role=$(get\_mesh\_role)  
uci set repacd.repacd.Role\_real=$role  
random\_psk=`dd if=/dev/urandom bs=1 count=8 2> /dev/null | openssl base64 | tr -d '=' | tr -d '$'`  
random\_ssid=`dd if=/dev/urandom bs=1 count=9 2> /dev/null | openssl base64 | tr -d '=' | tr -d '$'`

```
	uci set repacd.repacd.Enable=1
	uci commit repacd

	config_load wireless
	config_foreach update_mac wifi-device
	config_foreach update_vap_config wifi-iface
	["$role" != "CAP"] && random_psk="goodlife"
	config_foreach set_up_backhaul_vap wifi-device

	uci set hyd.Topology.ENABLE_NOTIFICATION_UNICAST=1
	uci set hyd.Topology.PERIODIC_QUERY_INTERVAL=15
	uci commit hyd

	if [$role = "CAP"]; then
		touch /tmp/pairing_in_process
		uci set wireless.wifi0.htmode=HT40
		uci set wireless.@wifi-iface[0].disablecoext=1
		uci commit wireless

		/etc/init.d/repacd start
		echo 1 >/sys/class/leds/mesh_led/brightness
	else

		
		/etc/init.d/lighttpd stop
		/etc/init.d/lighttpd disable
		/etc/init.d/gl_tertf stop
		killall -9 gltertf
		uci set dhcp.lan.ignore=1
		uci commit dhcp
		/etc/init.d/dnsmasq restart
		uci set network.lan.ifname='eth0 eth1'
		uci set network.lan.proto=dhcp
		uci delete network.wan
		uci delete network.tethering
		uci delete network.modem_1_1
		uci commit network
		uci set glconfig.autoupdate.enable=0
		uci commit glconfig
		echo timer >/sys/class/leds/mesh_led/trigger
		echo 250 >/sys/class/leds/mesh_led/delay_off
		echo 250 >/sys/class/leds/mesh_led/delay_on
		/etc/init.d/network restart
		/etc/init.d/repacd start
		ssdk_sh debug phy set 2 0 0x840; ssdk_sh debug phy set 3 0 0x840
		sleep 0.5
		ssdk_sh debug phy set 2 0 0x1240; ssdk_sh debug phy set 3 0 0x1240
		echo 0 >/sys/class/leds/mesh_led/brightness
	fi
fi

```

}

bridge\_mode=$(uci -q get glconfig.bridge.mode)  
[“$bridge\_mode” = “ap” -o “$bridge\_mode” = “relay” -o “$bridge\_mode” = “wds”] && exit 0

if [“$ACTION” = “released”]; then  
lock -n /var/run/mesh\_button.lock  
[$? = 1] && exit 0  
fi

if [“${ACTION}” = “released” -a “$BUTTON” = “wps”]; then  
lock -u /var/run/mesh\_led.lock  
killall -9 button\_pressed  
role=“`uci get repacd.repacd.Role`”  
if [“$role” = “NonCAP”]; then  
echo 0 \>/sys/class/leds/mesh\_led/brightness  
else  
echo 1 \>/sys/class/leds/mesh\_led/brightness  
fi  
elif [“${ACTION}” = “pressed” -a “$BUTTON” = “wps”]; then  
lock /var/run/mesh\_led.lock  
/usr/bin/button\_pressed MESH &  
fi

if [“$ACTION” = “released” -a “$BUTTON” = “wps” -a “$SEEN” -gt 8]; then  
/usr/sbin/de\_mesh.sh  
/etc/init.d/gl\_health start  
elif [“$ACTION” = “released” -a “$BUTTON” = “wps” -a “$SEEN” -gt 3]; then  
. /lib/functions.sh  
. /lib/functions/system.sh

```
stop_nodogsplash
kill -9 $(pgrep -f 'gl_health') 2>/dev/null

["`uci get repacd.repacd.Enable`" = 0] && {    
	if [-f /etc/config.tar]; then
		rm /etc/config.tar
	fi
	
	if ["$(get_mesh_role)" = "CAP"]; then
		cd /etc
		tar cf config.tar \
		config/wireless \
		config/network \
		config/gl_son \
		config/hyd \
		config/lbd \
		config/repacd \
		config/wsplcd \
		passwd passwd- shadow shadow- sysupgrade.conf
	else
		disable_all_vpn
		stop_all_vpn
		cd /etc
		tar cf config.tar config passwd passwd- shadow shadow- openvpn sysupgrade.conf
	fi
}

uci delete wireless.sta
uci delete wireless.guest5g
uci delete wireless.guest2g
uci delete network.wwan
uci commit wireless
uci commit network
# echo "mesh" >/etc/glproduct
uci set glconfig.bridge='service'
uci set glconfig.bridge.mode='mesh'
uci commit glconfig
/etc/init.d/gl_health stop
mesh_role
killall hostapd_cli
config_load wireless
config_foreach func_wps_on wifi-iface

```

fi

if [“$ACTION” = “released” && “$SEEN” -gt 3]; then  
cloud\_en=$(uci -q get glconfig.cloud.enable)  
[“$cloud\_en” = “1”] && ubus call mqtt notify &  
fi

[“$ACTION” = “released”] && lock -u /var/run/mesh\_button.lock

> Blockquote

This is the content of the file.  
How can I modify to start/stop wireguard vpn client?  
Thanks

---

<div class="post-metadata">

**Author:** ![antifascista](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@antifascista](https://forum.gl-inet.com/u/antifascista)\
**Post date:** [March 23, 2020, 8:47am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/9 "2020-03-23T08:47:14Z")

</div>

Anyone can help me about?  
Command to start or stop wireguard client is enough easy but how to check the previous state of wireguard to start or stop it?  
If WG is active then stop it else start it…  
Thanks

---

<div class="post-metadata">

**Author:** ![antifascista](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/f07891/32.png) [@antifascista](https://forum.gl-inet.com/u/antifascista)\
**Post date:** [March 26, 2020, 1:04am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/10 "2020-03-26T01:04:19Z")

</div>

I have tried to modify the file with my personal script but releasing button there’s not action. So I have edited reset button file with the same script and it’s works perfectly.

---

<div class="post-metadata">

**Author:** ![alzhao](https://forum-assets.gl-inet.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@alzhao](https://forum.gl-inet.com/u/alzhao)\
**Post date:** [March 26, 2020, 2:15am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/11 "2020-03-26T02:15:35Z")

</div>

Both button should work in the same way.

---

<div class="post-metadata">

**Author:** ![bruce](https://forum-assets.gl-inet.com/user_avatar/forum.gl-inet.com/bruce/32/35649_2.png) [@bruce](https://forum.gl-inet.com/u/bruce)\
**Post date:** [October 29, 2025, 4:10am UTC](https://forum.gl-inet.com/t/b-1300-buttons-functions-modifying/10202/13 "2025-10-29T04:10:15Z")

</div>


