This file is indexed.

/usr/sbin/olsrd-adhoc-setup is in olsrd 0.6.6.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh


#- globals --------------------------------------------------------------------#

nmcli="/usr/bin/nmcli --mode tabular"

#- functions ------------------------------------------------------------------#

get_wlan_if()
{
    if [ -x /sbin/iwconfig ]; then
        echo `/sbin/iwconfig 2>&1 | grep 'IEEE 802.11' | head -1 | awk '{print $1}'`
    elif [ -x /usr/bin/nmcli ]; then
        echo `$nmcli dev list | grep -B6 WIFI-PROPERTIES| head -1 | awk '{print $2}'`
    else
        # wild guess, why not...
        echo "wlan0"
    fi
}

get_current_bssid()
{
    if [ -x /sbin/iwgetid ]; then
        iwgetid --ap --raw
    fi
}

#- main -----------------------------------------------------------------------#

if [ ! -x /sbin/iwconfig ]; then
    echo "/sbin/iwconfig required! sudo apt-get install wireless-tools"
    exit
fi

if [ -z "$1" ]; then
    wlan=$(get_wlan_if)
else
    wlan=$1
fi

if [ "$wlan" = "" ]; then
    echo "No wifi network interface found! Perhaps you need to modprobe?"
    exit
fi

if [ -z "$2" ]; then
    channel=5
else
    channel=$2
fi

if [ -z "$3" ]; then
    essid=commotionwireless.net
else
    essid="$3"
fi

if [ -z "$4" ]; then
    bssid=02:ca:ff:ee:ba:be
else
    bssid="$4"
fi

echo "Setting mesh on '$wlan' to channel $channel:"
echo "Attaching to '$essid' with BSSID '$bssid'"

# set NetworkManager to play nice
if [ -x /usr/bin/nmcli ]; then
	echo -n "Turning off NetworkManager wifi control: "
    $nmcli nm sleep false   2> /dev/null
    $nmcli nm wifi on   2> /dev/null
    $nmcli dev disconnect iface $wlan   2> /dev/null
fi

echo -n "Setting up ad-hoc networking: "

# ifconfig down before setting ad-hoc mode because some chips require that
/sbin/ifconfig $wlan down

# disassociate from current BSSID in case an ad-hoc BSSID already stuck there
/sbin/iwconfig $wlan ap $bssid

sleep 1

/sbin/iwconfig $wlan mode ad-hoc
/sbin/iwconfig $wlan channel $channel
/sbin/iwconfig $wlan essid $essid
/sbin/iwconfig $wlan key off
/sbin/iwconfig $wlan rate auto
/sbin/iwconfig $wlan txpower auto
# many devices don't support the follow options so hide the errors
/sbin/iwconfig $wlan modu auto  > /dev/null 2>&1
/sbin/iwconfig $wlan commit     > /dev/null 2>&1

/sbin/ifconfig $wlan up

# some cards want to be configured after the interface is up
sleep 5
mode=`iwgetid --mode --raw`
if [ "$mode" != "1" ]; then
    /sbin/iwconfig $wlan mode ad-hoc
    /sbin/iwconfig $wlan channel $channel
    /sbin/iwconfig $wlan essid $essid
    /sbin/iwconfig $wlan commit     > /dev/null 2>&1
fi

# Wait for things to settle before trying the next step
sleep 2
echo "done"

echo -n "Setting up IP address: "
# get MAC to generate hopefully unique IP address with, by using the last two
# hex pairs as the last two hex pairs for the IP address, converting the hex
# to decimal first.
MAC=`/sbin/ifconfig | grep $wlan | sed 's|.*HWaddr ||'`
MAC5=`echo $MAC | cut -d : -f 5`
MAC6=`echo $MAC | cut -d : -f 6`
ip3=`printf %d 0x$MAC5`
ip4=`printf %d 0x$MAC6`
net=172.29
ip=$net.$ip3.$ip4

/sbin/ifconfig $wlan inet $ip broadcast $net.255.255
echo "done"

echo "OLSR ad-hoc setup on $wlan using $essid on channel $channel with IP $ip"
echo "    ad-hoc Cell BSSID: `get_current_bssid`"