ne marche plus avec les nouvelles bornes, c'est utile que pour l'install party
darcs-hash:20051025183129-4ec08-d4a3fbe14a38645cbefae8904609f003891c703d.gz
This commit is contained in:
parent
b5b85aa1a6
commit
f103cf0736
1 changed files with 0 additions and 144 deletions
|
@ -1,144 +0,0 @@
|
||||||
|
|
||||||
#! /bin/sh
|
|
||||||
|
|
||||||
###################################
|
|
||||||
## Reconfigure une borne wifi ##
|
|
||||||
## du CR@NS en temps que routeur ##
|
|
||||||
###################################
|
|
||||||
|
|
||||||
# Ce scipt est à utiliser une fois que les interfaces de la bornes
|
|
||||||
# sont configurées
|
|
||||||
|
|
||||||
BORNE="install-party.crans.org"
|
|
||||||
DIR="/usr/scripts/install-party"
|
|
||||||
MACS="$DIR/MACS-install-party"
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
|
|
||||||
CLEF="/usr/scripts/gestion/clef-wifi"
|
|
||||||
SSH="ssh -i $CLEF -o StrictHostKeyChecking=no $BORNE"
|
|
||||||
SCP="scp -i $CLEF -o StrictHostKeyChecking=no"
|
|
||||||
|
|
||||||
usage () {
|
|
||||||
echo "Usage : "
|
|
||||||
echo " $0 --macs <borne> Modifie les MACS authorisées"
|
|
||||||
echo " $0 --services <borne> Relance les services"
|
|
||||||
echo " $0 --firewall <borne> Relance le firewall"
|
|
||||||
}
|
|
||||||
|
|
||||||
error=1
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
|
|
||||||
# Edition du fichier de MACS
|
|
||||||
|
|
||||||
if [[ "$1" == "--macs" ]]
|
|
||||||
then
|
|
||||||
/usr/bin/jed $MACS
|
|
||||||
error=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
|
|
||||||
# Reconfiguration des services
|
|
||||||
|
|
||||||
if [[ "$1" == "--services" ]]
|
|
||||||
then
|
|
||||||
# génération du script
|
|
||||||
echo "Création du script de reconfiguration"
|
|
||||||
cat > $DIR/boot.sh <<EOF
|
|
||||||
# ajout de la route
|
|
||||||
route add default gw 138.231.136.4 dev vlan0
|
|
||||||
|
|
||||||
# résolution de noms
|
|
||||||
echo "search crans.org" > /tmp/resolv.conf
|
|
||||||
echo "nameserver 138.231.136.6" >> /tmp/resolv.conf
|
|
||||||
echo "nameserver 138.231.136.10" >> /tmp/resolv.conf
|
|
||||||
|
|
||||||
# alias pour le dns
|
|
||||||
echo "127.0.0.1 localhost" > /etc/hosts
|
|
||||||
echo "138.231.136.7 debian.ens-cachan.fr ftp.crihan.fr" >> /etc/hosts
|
|
||||||
|
|
||||||
# dns
|
|
||||||
killall dnsmasq 2> /dev/null
|
|
||||||
/usr/sbin/dnsmasq
|
|
||||||
|
|
||||||
# dhcp filaire
|
|
||||||
echo "start 192.168.0.10" > /tmp/udhcpd.conf
|
|
||||||
echo "end 192.168.0.254" >> /tmp/udhcpd.conf
|
|
||||||
echo "interface vlan1" >> /tmp/udhcpd.conf
|
|
||||||
echo "opt dns 192.168.0.1 138.231.136.6" >> /tmp/udhcpd.conf
|
|
||||||
echo "option subnet 255.255.255.0" >> /tmp/udhcpd.conf
|
|
||||||
echo "option dns 138.231.136.10" >> /tmp/udhcpd.conf
|
|
||||||
echo "opt router 192.168.0.1" >> /tmp/udhcpd.conf
|
|
||||||
killall udhcpd 2> /dev/null
|
|
||||||
/usr/sbin/udhcpd /tmp/udhcpd.conf
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# envoi du fichier et execution
|
|
||||||
chmod 744 $DIR/boot.sh
|
|
||||||
echo "Envoi du script"
|
|
||||||
$SCP $DIR/boot.sh $BORNE:/tmp/boot.sh > /dev/null
|
|
||||||
|
|
||||||
# execution du script
|
|
||||||
echo "Execution du script"
|
|
||||||
$SSH /tmp/boot.sh
|
|
||||||
|
|
||||||
# destruction du fichier
|
|
||||||
rm -f $DIR/boot.sh
|
|
||||||
|
|
||||||
error=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
|
|
||||||
# Reconfiguration du firewall
|
|
||||||
|
|
||||||
if [[ "$1" == "--firewall" ]] || [[ "$1" == "--macs" ]]
|
|
||||||
then
|
|
||||||
# génération du firewall
|
|
||||||
echo "Génération du firewall"
|
|
||||||
cat > $DIR/firewall.sh <<EOF
|
|
||||||
iptables -F
|
|
||||||
iptables -X
|
|
||||||
iptables -F -t nat
|
|
||||||
iptables -X -t nat
|
|
||||||
iptables -P FORWARD ACCEPT
|
|
||||||
iptables -t nat -P PREROUTING DROP
|
|
||||||
iptables -t nat --protocol icmp -d 192.169.0.1 -j ACCEPT
|
|
||||||
iptables -t nat -A PREROUTING -i vlan0 -j ACCEPT
|
|
||||||
iptables -t nat -A PREROUTING -i vlan1 -s ! 138.231.136.10 -p tcp --dport 80 -j DNAT --to 138.231.136.10:3128
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat $MACS | sed 's/ //g' | grep -v '#' | grep -v '^$' | while true
|
|
||||||
do
|
|
||||||
read mac
|
|
||||||
if [ "$mac" = "" ] ; then break ; fi
|
|
||||||
echo "iptables -t nat -A PREROUTING -i vlan1 -m mac --mac-source $mac -j ACCEPT" >> $DIR/firewall.sh
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "iptables -A POSTROUTING -t nat -o vlan0 -j MASQUERADE" >> $DIR/firewall.sh
|
|
||||||
|
|
||||||
# envoi du fichier et execution
|
|
||||||
chmod 744 $DIR/firewall.sh
|
|
||||||
echo "Envoi du firewall"
|
|
||||||
$SCP $DIR/firewall.sh $BORNE:/tmp/firewall.sh > /dev/null
|
|
||||||
|
|
||||||
# execution du script
|
|
||||||
echo "Lancement du firewall"
|
|
||||||
$SSH /tmp/firewall.sh
|
|
||||||
|
|
||||||
# destruction du fichier
|
|
||||||
rm -f $DIR/firewall.sh
|
|
||||||
|
|
||||||
error=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
#########################################################################
|
|
||||||
|
|
||||||
if [ "$error" = "1" ]
|
|
||||||
then
|
|
||||||
usage
|
|
||||||
exit 2
|
|
||||||
fi
|
|
Loading…
Add table
Add a link
Reference in a new issue