From 845541aec47e9a295232778ccd387466ed021b16 Mon Sep 17 00:00:00 2001 From: chove Date: Thu, 11 Nov 2004 05:42:01 +0100 Subject: [PATCH] script de configuration des bornes pour l'install party il sera dans le PATH le jour de l'install party : usage : configure_borne --macs => dite le fichier de macs configure_borne --firewall => relance le firewall configure_borne --services => relance les services (aprs un reboot) darcs-hash:20041111044201-4ec08-ed6a23529023dc67dd07373bbe4eed9479b565cf.gz --- install-party/configure_borne | 122 ++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100755 install-party/configure_borne diff --git a/install-party/configure_borne b/install-party/configure_borne new file mode 100755 index 00000000..e6c829ce --- /dev/null +++ b/install-party/configure_borne @@ -0,0 +1,122 @@ +#! /bin/sh + +################################### +## Reconfigure une borne wifi ## +## du CR@NS en temps que routeur ## +################################### + +BORNE="install-party.crans.org" +DIR="/home/chove/bornes" +MACS="$DIR/MACS-$BORNE" + +######################################################################### + +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 --services " + echo " $0 --firewall " +} + +error=1 + +######################################################################### + +# Reconfiguration des services + +if [[ "$1" == "--services" ]] +then + # génération du script + echo "Création du script de reconfiguration" + cat > $DIR/boot.sh < /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.9 debian.ens-cachan.fr" >> /etc/hosts +echo "138.231.136.9 ftp.crihan.fr" >> /etc/hosts + +# dns +killall dnsmasq 2> /dev/null +/usr/sbin/dnsmasq + +# dhcp +echo "start 192.168.0.10" > /tmp/udhcpd. +echo "end 192.168.0.254" >> /tmp/udhcpd.conf +echo "interface vlan1" >> /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" ]] +then + # génération du firewall + echo "Génération du firewall" + cat > $DIR/firewall.sh <> $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