aboutsummaryrefslogtreecommitdiff
path: root/autoDHCP
blob: 5f52c70fce057c088de57c36d74a63d1bdbfb713 (plain)
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
#!/bin/env bash

interface="";
server="dhcpd"
ip="10.5.5.11"
range="/24"

# Todo : List interface ✓ 
#        Select first ✓
#        Select dhcpd or dnsmasq ❌
#        Select ip range ⍻
#        Select ip ⍻
#        Help ❌
#        Install from Makefile ❌

# Default interface is the first non-wireless interfaces (sorted alpha-num)





function guess_nowifi {
    for i in `ls /sys/class/net/`; do
        if [ ! -d "/sys/class/net/$i/wireless" ] ; then 
            if [ "$interface" ] ; then 
                if [[ "$i" < "$înterface" ]] ; then
                    interface="$i"
                fi
            else
                interface="$i"
            fi
        fi
    done
}



if [ -z "$interface" ] ; then
    guess_nowifi
fi



echo "Working on $interface"




sudo ip l set "$interface" up
sudo ip a r "${ip}${range}" dev "$interface"
sudo /usr/bin/dhcpd -4 -q -pf /run/dhcpd4.pid "$interface"