Subversion Repositories ALCASAR

Rev

Rev 838 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
838 richard 1
#/bin/bash
2
# $Id: alcasar-nf.sh 791 2012-01-13 21:31:36Z richard $
3
 
4
# alcasar-dhcp.sh
5
# by Rexy
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
8
# active ou desactive le service DHCP sur le réseau de consultation
9
# enable or disable the DHCP service on consultation LAN
10
 
11
SED="/bin/sed -i"
841 richard 12
CHILLI_CONF_FILE="/etc/chilli.conf"
838 richard 13
ALCASAR_CONF_FILE="/usr/local/etc/alcasar.conf"
841 richard 14
ETHERS_FILE="/usr/local/etc/alcasar-ethers"
838 richard 15
 
841 richard 16
PRIVATE_IP_MASK=`grep PRIVATE_IP $ALCASAR_CONF_FILE|cut -d"=" -f2`
17
PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
18
PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
19
PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2`
20
PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2`
21
PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX
22
 
838 richard 23
usage="Usage: alcasar-dhcp.sh {--on | -on} | {--off | -off}"
24
nb_args=$#
25
args=$1
26
if [ $nb_args -eq 0 ]
27
then
28
	echo "$usage"
29
	exit 1
30
fi
31
case $args in
32
	-\? | -h* | --h*)
33
		echo "$usage"
34
		exit 0
35
		;;
36
	--off|-off) # disable DHCP service
841 richard 37
		$SED "s?^#statip.*?statip\t\t$PRIVATE_NETWORK_MASK?g" $CHILLI_CONF_FILE
38
		$SED "s?^#nodynip.*?nodynip?g" $CHILLI_CONF_FILE
39
		$SED "s?^ethers.*?#ethers\t\t$ETHERS_FILE?g" $CHILLI_CONF_FILE
838 richard 40
		$SED "s?^DHCP.*?DHCP=off?g" $ALCASAR_CONF_FILE
41
		/etc/init.d/chilli restart
42
		;;
841 richard 43
	--on|-on) # enable DHCP service
44
		$SED "s?^statip.*?#statip\t\t$PRIVATE_NETWORK_MASK?g" $CHILLI_CONF_FILE
45
		$SED "s?^nodynip.*?#nodynip?g" $CHILLI_CONF_FILE
46
		$SED "s?^#ethers.*?ethers\t\t$ETHERS_FILE?g" $CHILLI_CONF_FILE
47
		$SED "s?^DHCP.*?DHCP=on?g" $ALCASAR_CONF_FILE
48
		/etc/init.d/chilli restart
49
		;;
838 richard 50
	*)
51
		echo "Argument inconnu :$1";
52
		echo "$usage"
53
		exit 1
54
		;;
55
esac
56