#!/bin/bash nbpc=0 echo " ======================================== " echo " ! LANCEZ CE SCRIPT EN ROOT ! " echo " \$ sudo -i " echo " Les actions suivantes ne pourront " echo " etre realisees dans le cas contraire : " echo " - modification de l'adresse MAC " echo " ======================================= " echo "Entrez le numero du pc" read nbpc nbpc=$(echo $nbpc | bc) if [ $nbpc -lt 10 ] then nbpc="0$nbpc" fi service network-manager stop echo " =================================== " echo " Modification du nom de la machine : " echo DesclicksXub$nbpc echo " =================================== " name=DesclicksXub${nbpc} echo -e "${name}\n" > /etc/hostname hostname ${name} sed -e "s/^127.0.1.1\s*\(Desclicks\|cyberlis\).*/127.0.1.1 ${name}/" -i /etc/hosts echo " =================================== " echo " Modification de l adresse MAC" echo " =================================== " eth=`ip link show | grep -o eth[0-9][0-9]*` echo ip link set dev $eth address 00:00:00:00:0D:$nbpc ip link set dev $eth address 00:00:00:00:0D:$nbpc if grep -qe '^hwaddress ether' /etc/network/interfaces then sed -e "s/\(hwaddress ether\).*/\1 00:00:00:00:0d:$nbpc/" -i /etc/network/interfaces else echo -e "hwaddress ether 00:00:00:00:0d:$nbpc\n" >> /etc/network/interfaces fi service network-manager start