#! /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