#!/bin/sh default_dev='wlan0=funston' die() { printf 'Error: %s\n' "$*" >&2; exit 1; } with_pwd_path() { local PATH="$PATH":. "$@" } restart=$(with_pwd_path which restart-linux-device) || die "command 'restart-linux-device' is not available." if [ $(id -u) = 0 ]; then sudo= else sudo=sudo fi dev=${1:-$default_dev} rawdev=${dev%=*} [ "$VERBOSE" ] && set -x $sudo $restart $rawdev $sudo ifdown --force $rawdev # It's not clear to me why this is necessary, but it is. $sudo ifup $dev