#!/bin/sh
# adhoc.sh
# 2012-03-28
#
# Ad-hoc networking
#
# wpa_supplicant needs to be disabled before running this script.
#
# Usage: INT=wlan0 IP=192.168.0.1 ./adhoc.sh
INT=${INT:-wlan0}
IP=${IP:-192.168.0.1}
if [ $(id -u) -ne 0 ]; then
echo "Error: This script must be run as root."
exit 1
fi
echo "Ad-hoc network: Interface=$INT IP=$IP"
ifconfig "$INT" down
iwconfig "$INT" mode ad-hoc
iwconfig "$INT" channel 6
iwconfig "$INT" essid 'adhoc'
ifconfig "$INT" "$IP" up