sleep 1/sbin/sysctl net.wlan.devices | /usr/bin/cut -d ' ' -f2 | /usr/bin/grep -o run[0-9] > /dev/null && /usr/local/etc/rc.reload_interface/usr/local/bin/beep
#!/bin/sh## PROVIDE: mywlanpnp# REQUIRE: LOGIN# KEYWORD: shutdown## Bobbis@forum.opnsense.org 07.10.2017 Version 0.001## mywlanpnp enables you to use an USB-Wireless Device as pnp like.# Make sure that you have allready the USB-Wireless Device configured before using this script.# This script is just tested with only one USB-Wireless Device, in my case an "run0" Device.# Modify the code to your own suit.## HINT: Wait 10Seconds before disconnect or reconnect the USB-Wireless Device for better compatibility.## Place this Script under /usr/local/etc/rc.d/mywlanpnp and set chmod execute flags.# Note:# Set "mywlanpnp_enable=YES" in /etc/rc.conf.d/mywlanpnp to run this script at boot.#. /etc/rc.subrname="mywlanpnp"rcvar=${name}_enablemywlanpnp_enable=${mywlanpnp_enable-"NO"}start_cmd="${name}_start"stop_cmd="${name}_stop"load_rc_config $namefile=/var/log/system.logusb_disconnected_string="run[0-9]: at uhub[0-9], port [0-9], addr [0-9] (disconnected)" #run0: at uhub5, port 5, addr 2 (disconnected)usb_connected_string="run[0-9]: <[0-9].[0-9]> on usbus[0-9]" #run0: <1.0> on usbus5mywlanpnp_start() { if [ ! -f /var/run/mywlanpnp.pid ] then echo -n "Starting services: mywlanpnp" /usr/local/sbin/clog -f $file | while IFS='' read -r line; do case "$line" in *${usb_connected_string}*) #/usr/bin/head -1 | echo "connected" sleep 1 #/sbin/sysctl net.wlan.devices | /usr/bin/cut -d ' ' -f2 | /usr/bin/grep -o run[0-9] > /dev/null && /usr/local/etc/rc.interfaces_wan_configure opt1 /sbin/sysctl net.wlan.devices | /usr/bin/cut -d ' ' -f2 | /usr/bin/grep -o run[0-9] > /dev/null && /usr/local/etc/rc.reload_interfaces /usr/local/bin/beep ;; *${usb_disconnected_string}*) #/usr/bin/head -1 | echo "disconnected" sleep 1 /bin/pgrep hostapd > /dev/null && sleep 1 && /bin/pgrep hostapd | /usr/bin/xargs kill && /usr/local/etc/rc.reload_interfaces /usr/local/bin/beep ;; esac done & echo $! > /var/run/mywlanpnp.pid echo "." else echo "It appears mywlanpnp is already running. NOT starting!" fi}mywlanpnp_stop() { if [ ! -f /var/run/mywlanpnp.pid ] then echo "It appears mywlanpnp is not running." else echo -n "Stopping services: mywlanpnp" kill `cat /var/run/mywlanpnp.pid` rm /var/run/mywlanpnp.pid echo "." fi}run_rc_command "$1"
/sbin/sysctl net.wlan.devices | /usr/bin/cut -d ' ' -f2 | /usr/bin/grep -o run[0-9] > /dev/null && /usr/local/etc/rc.reload_interface
/sbin/sysctl net.wlan.devices | /usr/bin/cut -d ' ' -f2 | /usr/bin/grep -o run[0-9] > /dev/null && /usr/local/bin/php /usr/local/etc/rc.reload_interface