summarylogtreecommitdiffstats
path: root/coova-chilli
blob: dccfc06afb60ae11b4ced48520c5f9f89f83e625 (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
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
129
130
131
132
133
134
135
136
#!/bin/bash

daemon_name=coova-chilli

. /etc/rc.conf
. /etc/rc.d/functions
. /etc/chilli/functions

DAEMON=/usr/sbin/chilli
NAME=chilli
DESC=chilli
START_CHILLI=1

if [ "$START_CHILLI" != "1" ] ; then
   echo "Chilli default off. Look at /etc/default/chilli"
   exit 0
fi

test -f $DAEMON || exit 0

MULTI=$(ls /etc/chilli/*/chilli.conf 2>/dev/null)
[ -z "$DHCPIF" ] && [ -n "$MULTI" ] && {
    for c in $MULTI; 
    do
	echo "Found configuration $c"
	DHCPIF=$(basename $(echo $c|sed 's#/chilli.conf##'))
	export DHCPIF
	echo "Running DHCPIF=$DHCPIF $0 $*"
	sh $0 $*
    done
    exit
}

if [ -n "$DHCPIF" ]; then
    CONFIG=/etc/chilli/$DHCPIF/chilli.conf
else
    CONFIG=/etc/chilli.conf
fi

[ -f $CONFIG ] || {
    echo "$CONFIG Not found"
    exit 0
}


case "$1" in
  start)
    stat_busy "Starting Coovachilli"
    /sbin/modprobe tun >/dev/null 2>&1
	echo 1 > /proc/sys/net/ipv4/ip_forward
	
	writeconfig
	radiusconfig
	
	test ${HS_ADMINTERVAL:-0} -gt 0 && {	
            (crontab -l 2>&- | grep -v $0
		echo "*/$HS_ADMINTERVAL * * * * $0 radconfig"
		) | crontab - 2>&-
	}

	ifconfig $HS_LANIF 0.0.0.0

    [ ! -d /var/run/coovachilli ] && install -d /var/run/coovachilli
    if $DAEMON start >/dev/null ; then
      add_daemon $daemon_name
      stat_done
    else
      stat_fail
      exit 1
    fi
    ;;

  stop)
    stat_busy "Stopping Coovachilli"
    crontab -l 2>&- | grep -v $0 | crontab -
    if $DAEMON stop >/dev/null ; then
      rm_daemon $daemon_name
      stat_done
    else
      stat_fail
      exit 1
    fi
    ;;

  

  restart)
    stat_busy "Restarting Coovachilli"
    if $DAEMON restart >/dev/null ; then
      add_daemon $daemon_name
      stat_done
    else
      stat_fail
      exit 1
    fi
    ;;
  
  condrestart)
    stat_busy "Restarting Coovachilli"
    if DAEMON restart >/dev/null ; then
      add_daemon $daemon_name
      stat_done
    else
      stat_fail
      exit 1
    fi
    ;;
  
  status)
    stat_busy "Checking Coovachilli status";
    ck_status $daemon_name
    ;;
  
  reload)
    stat_busy "Reloading Coovachilli"
    if $DAEMON graceful >/dev/null ; then
      add_daemon $daemon_name
      stat_done
    else
      stat_fail
      exit 1
    fi
    ;;
   
   radconfig)
	[ -e $MAIN_CONF ] || writeconfig
	radiusconfig
	;;

  

  *)
    echo "usage: $0 {start|stop|restart|condrestart|status|reload|radconfig}"
esac

exit 0