#!/bin/bash # redirect all output into a logfile # exec 1>> /tmp/test.log 2>&1 case "$2" in CONNECTED) # do stuff on connect with wlan0 sleep 2; if grep -Fxq `iwgetid --ap --raw` /etc/theta_wg/ignore.txt then echo "none" else # code if not found wg-quick up wg0-ron fi ;; DISCONNECTED) # do stuff on disconnect with wlan0 wg-quick down wg0-ron ;; *) >&2 echo empty or undefined event for wlan0: "$2" exit 1 ;; esac