2024-06-04 11:56:22 +02:00

62 lines
1.2 KiB
Bash

#!/bin/bash
# Test si root
if [ "$EUID" -ne 0 ]
then echo "Merci d'éxécuter en tant que root"
exit
fi
# Test si accès à Internet
echo "Test d'accès à Internet..."
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then
echo "Accès à internet OK"
else
echo ""
echo "Merci de connecter ce PC à internet avant d'éxécuter ce programme"
exit
fi
# Demande confirmation
while true; do
read -p "Etes vous sûr de vouloir réinitialiser l'utilisateur loritz ? (y/n) " yn
case $yn in
[yY] ) echo "OK, nous allons commencer !";
break;;
[nN] ) echo "Ah... Dommage";
exit;;
* ) echo Réponse invalide;;
esac
done
# Début du travail
echo ""
echo "***** Suppression de l'utilisateur loritz *****"
echo ""
userdel -r -f loritz
sleep 5s
echo ""
echo "***** Suppression config réseau *****"
echo ""
rm -r /etc/NetworkManager/system-connections/*
echo ""
echo "***** Réinitialisation de l'utilisateur loritz *****"
echo ""
su ansible -c "ansible-pull -U https://git.axolito.fr/Axel/laptop_playbook.git"
echo ""
echo "***** Réinitialisation terminée *****"
echo ""
echo "***** Le PC va redémarrer dans 5 secondes *****"
echo ""
sleep 5s
reboot