Skip to content

Instantly share code, notes, and snippets.

@frogkind
Last active June 25, 2024 11:43
Show Gist options
  • Save frogkind/8ec0d09caaa26bbf606c8c6b6b2b3fea to your computer and use it in GitHub Desktop.
Save frogkind/8ec0d09caaa26bbf606c8c6b6b2b3fea to your computer and use it in GitHub Desktop.
openwrt auto set tinyproxy bind when openvpn tun0 up (location: /etc/openvpn.user)
#!/bin/sh
#
# This file is interpreted as shell script.
# Put your custom openvpn action here, they will
# be executed with each opevnp event.
#
# $ACTION
# <down> down action is generated after the TUN/TAP device is closed
# <up> up action is generated after the TUN/TAP device is opened
# $INSTANCE Name of the openvpn instance which went up or down
if [[ "$ACTION" == "up" && "$2" == "tun0" ]] ; then
uci set tinyproxy.@tinyproxy[0].Bind=$5
uci commit tinyproxy
service tinyproxy restart
logger -t "openvpn($INSTANCE)" -p daemon.notice "set tinyproxy bind ip $5"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment