From 44c89e4e049f4278ad041d138e9a846e1f132a26 Mon Sep 17 00:00:00 2001 From: Axel Date: Thu, 23 May 2024 08:05:32 +0200 Subject: [PATCH] Ajout script reinitialisation --- local.yml | 3 ++- tasks/bin.yml | 7 +++++++ tasks/files/bin/reset-loritz | 39 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tasks/bin.yml create mode 100644 tasks/files/bin/reset-loritz diff --git a/local.yml b/local.yml index d57d910..e896f76 100644 --- a/local.yml +++ b/local.yml @@ -13,4 +13,5 @@ - include_tasks: tasks/users.yml - include_tasks: tasks/cron.yml - include_tasks: tasks/packages.yml - - include_tasks: tasks/loritz-user.yml \ No newline at end of file + - include_tasks: tasks/loritz-user.yml + - include_tasks: tasks/bin.yml \ No newline at end of file diff --git a/tasks/bin.yml b/tasks/bin.yml new file mode 100644 index 0000000..6cd0911 --- /dev/null +++ b/tasks/bin.yml @@ -0,0 +1,7 @@ +- name: Copie scriptes vers bin + copy: + src: files/bin/ + dest: /usr/bin/ + owner: root + group: root + mode: 0755 \ No newline at end of file diff --git a/tasks/files/bin/reset-loritz b/tasks/files/bin/reset-loritz new file mode 100644 index 0000000..d63a468 --- /dev/null +++ b/tasks/files/bin/reset-loritz @@ -0,0 +1,39 @@ +#!/bin/bash + +# Test si root +if [ "$EUID" -ne 0 ] + then echo "Merci d'éxécuter en tant que root" + 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 "***** Réinitialisation de l'utilisateur loritz *****" +echo "" + +userdel -r -f loritz +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 \ No newline at end of file