+usage() {
+ cat <<EOF
+usage: ${0##*/} [-h] [-t 2|test] [-m WIRELESS_MAC]
+setup my router in general: dhcp, dns, etc.
+
+Type 2 or 3 is for setting up a backup device, there are two kinds so
+that you can switch the main device to a backup, then a backup to the
+main. Type test is for setting up a testing device.
+
+Passing an empty string for WIRELESS_MAC will cause the device's native
+mac to be used.
+
+EOF
+
+ exit $1
+}
+
+
+dev2=false
+test=false
+hostname=wrt
+libremanage_host=wrt2
+
+lanip=1
+while getopts hm:t: opt; do
+ case $opt in
+ h) usage ;;
+ t)
+ case $2 in
+ 2|3)
+ dev2=true
+ libremanage_host=wrt
+ ;;&
+ 2)
+ lanip=4
+ hostname=wrt2
+ ;;
+ 3)
+ lanip=14
+ hostname=wrt3
+ ;;
+ test)
+ test=true
+ ;;
+ *) echo "$0: unexpected arg to -t: $*" >&2; usage 1 ;;
+ esac
+ ;;
+ m) mac=$OPTARG ;;
+ *) echo "$0: Internal error! unexpected args: $*" >&2 ; usage 1 ;;
+ esac
+done
+shift "$((OPTIND-1))" # Discard the options and sentinel --
+
+if [[ ! $mac ]] && ! $test; then
+ # if we wanted to increment it
+ #WIRELESSMAC=${WIRELESSMAC:0: -1}$((${WIRELESSMAC: -1} + 2))
+ mac=$WIRELESSMAC
+fi
+
+if (( $# != 0 )); then
+ usage 1
+fi
+
+
+macpre=${mac:0: -1}
+macsuf=${mac: -1}
+
+
+p_updated=false