
Je vous concocte ce petit guide pour les utilisateurs de linux qui aimerai automatisé la mise en place du fichier hosts d'Hajdar. En effet, comme notre cher serviteur le mets régulièrement à jour (merci pour son travail acharné) il est parfois assez
ouvrez un terminal dans "menu>accessoires>terminal"
tapez :
gedit hosts.shLe traitement de texte apparaît, copiez-collez ceci :
#!/bin/bashEnregistrez le fichier en hosts.sh, il devrait apparaître dans "/home/utilisateur".
#version 6
echo -n "Je télécharge l'archive ? O/N : "
read ouinon
if [ "$ouinon" = "o" ] || [ "$ouinon" = "O" ];
then
{
echo "Téléchargement :"
wget --directory-prefix=/tmp "http://kosvocore.free.fr/AdZHosts/AdZHosts.zip"
}
elif [ "$ouinon" = "n" ] || [ "$ouinon" = "N" ];
then
{
echo "Ok, bye !"
}
else
{
echo "Il faut taper O ou N !! Pas $ouinon"
}
fi
unzip /tmp/AdZHosts.zip -d /tmp/
if [ -e /tmp/hosts ] || [ -e /tmp/HOSTS ]
then
{
gksudo mv /tmp/HOSTS /tmp/hosts
gksudo mv /tmp/hosts /etc/
echo "Mission Accomplie !"
}
elif [ -e /tmp/AdZHosts/hosts ] || [ -e /tmp/AdZHosts/HOSTS ]
then
{
gksudo mv /tmp/AdZHosts/HOSTS /tmp/AdZHosts/hosts
gksudo mv /tmp/AdZHosts/hosts /etc/
echo "Mission Accomplie !"
}
else
{
echo "Fichier non trouvé"
}
fi
sudo rm /tmp/AdZHosts.zip
sudo rm -r /tmp/AdZHosts/
exit 0;
Cliquez droit dessus puis "propriétés>permissions" puis cocher :
"autorisé l'éxecution du fichier comme un programme"
Ouvrez un nouveau terminal puis tapez :
./hosts.shIl vous demande votre mot de passe pour remplacer dans /etc/
Et voilà, directement téléchargé et remplacé ;-)
N'hésitez pas à commenté pour que j'améliore ce tutoriel :-)
Hello.
RépondreSupprimerBon boulot!
J'ai un peu modifié ton script pour mes besoins, c'est du GPL alors je te le laisse ici :
________
#!/bin/bash
#téléchargement
echo -n "Télécharger le fichier hosts.txt ? O/N : "
read reponse
if [ "$reponse" = "o" ] || [ "$reponse" = "O" ];
then {
echo "Téléchargement ..."
wget -O hosts.txt "http://kosvocore.free.fr/AdZHosts/HOSTS.txt"
#backup /etc/hosts
if [ ! -e ./etc-hosts.bak ]
then {
cp /etc/hosts etc-hosts.bak
echo "Backup /etc/hosts = etc-hosts.bak ..."
}
fi
if [ -e ./hosts.txt ]
then {
cat etc-hosts.bak hosts.txt > hosts
echo "Mission Accomplie !"
}
else
{
echo "Fichier hosts.txt non trouvé"
}
fi
}
elif [ "$reponse" = "n" ] || [ "$reponse" = "N" ];
then {
echo "Ok, bye !"
}
else
{
echo "Il faut taper O ou N !! Pas $reponse"
}
fi
#modification /etc/hosts
echo -n "Modifier le fichier /etc/hosts ? O/N : "
read reponse
if [ "$reponse" = "o" ] || [ "$reponse" = "O" ];
then {
echo "Modification du fichier /etc/hosts ..."
sudo mv ./hosts /etc/hosts
}
elif [ "$reponse" = "n" ] || [ "$reponse" = "N" ];
then {
echo "Ok, bye !"
}
else
{
echo "Il faut taper O ou N !! Pas $reponse"
}
fi
___________
Respeckt.
@+...