From cc63dbf51e7aff8976bb6d26282524a246e37f98 Mon Sep 17 00:00:00 2001 From: "anthony.boillot" Date: Thu, 20 Feb 2025 14:26:27 +0100 Subject: [PATCH] tp03 + 04 --- sisr1/tp04_scripts_admin/Users.csv | 30 +++++++++++++++++++++++ sisr1/tp04_scripts_admin/createGroups.sh | 31 ++++++++++++++++++++++++ sisr1/tp04_scripts_admin/createLogins.sh | 25 +++++++++++++++++++ sisr1/tp04_scripts_admin/gitpush.sh | 16 ++++++++++++ sisr1/tp04_scripts_admin/logins.csv | 30 +++++++++++++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 sisr1/tp04_scripts_admin/Users.csv create mode 100644 sisr1/tp04_scripts_admin/createGroups.sh create mode 100644 sisr1/tp04_scripts_admin/createLogins.sh create mode 100644 sisr1/tp04_scripts_admin/gitpush.sh create mode 100644 sisr1/tp04_scripts_admin/logins.csv diff --git a/sisr1/tp04_scripts_admin/Users.csv b/sisr1/tp04_scripts_admin/Users.csv new file mode 100644 index 0000000..9dfb324 --- /dev/null +++ b/sisr1/tp04_scripts_admin/Users.csv @@ -0,0 +1,30 @@ +Ermengarde,Berthelmot,eberthelmot0@webmd.com,Female,Accountant, +Kassi,Bunker,kbunker1@xinhuanet.com,Female,Production, +Moises,McCallum,mmccallum2@i2i.jp,Male,Production, +Patrizio,Lune,plune3@upenn.edu,Male,Accountant, +Blanch,Everix,beverix4@php.net,Female,Accountant, +Stafani,Kibbel,skibbel5@marriott.com,Female,Production, +Ignacius,Mosdell,imosdell6@cloudflare.com,Male,Management, +Jeana,Waller-Bridge,jwallerbridge7@mapy.cz,Female,Management, +Elroy,Dressel,edressel8@opera.com,Male,Production, +Thea,Strettell,tstrettell9@nature.com,Female,Production, +Solomon,Insoll,sinsolla@utexas.edu,Male,Accountant, +Carri,Feedome,cfeedomeb@ask.com,Female,Accountant, +Padraic,Chetwind,pchetwindc@last.fm,Male,Management, +Solly,D'Ugo,sdugod@uiuc.edu,Male,Production, +Konstanze,MacCostigan,kmaccostigane@seattletimes.com,Female,Accountant, +Roxane,Powlesland,rpowleslandf@pcworld.com,Female,Management, +Orelle,Kennealy,okennealyg@arstechnica.com,Female,Production, +Sukey,Soitoux,ssoitouxh@shinystat.com,Female,Production, +Nelli,Syce,nsycei@blogger.com,Female,Production, +Clarisse,Shillam,cshillamj@dailymotion.com,Female,Production, +Carin,Gueny,cguenyk@naver.com,Female,Management, +Donny,Riepel,driepell@addtoany.com,Male,Production, +Daniella,Ralfe,dralfem@wunderground.com,Female,Production, +Lexy,Clynmans,lclynmansn@furl.net,Female,Production, +Gardiner,Adamthwaite,gadamthwaiteo@spotify.com,Male,Production, +Woodman,Lippett,wlippettp@purevolume.com,Male,Production, +Nadya,Munnion,nmunnionq@flavors.me,Female,Production, +Llewellyn,Habershon,lhabershonr@alibaba.com,Male,Production, +Isaak,Greatrex,igreatrexs@seesaa.net,Male,Production, +Darill,Frostdyke,dfrostdyket@cafepress.com,Male,Production, diff --git a/sisr1/tp04_scripts_admin/createGroups.sh b/sisr1/tp04_scripts_admin/createGroups.sh new file mode 100644 index 0000000..7126b18 --- /dev/null +++ b/sisr1/tp04_scripts_admin/createGroups.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +file='./Users.csv' + +while read ligne +do + # A chaque itération, stocker le métier dans $metier + metier=$(echo $ligne | cut -d "," -f5) + + # On regarde si les group existe + # tail /etc/group + + # Vérification de la présence du groupe Accountant -> ajout de la fonction "Accountant" à $groups + if [[ $(echo $ligne | grep "Accountant") == "" ]] ; then + groupadd accountant + fi + + # Vérification de la présence du groupe Management -> ajout de la fonction "Management" à $groups + if [[ $(echo $ligne | grep "Management") == "" ]] ; then + groupadd management + fi + + # Vérification de la présence du groupe Production -> ajout de la fonction "Production" à $groups + if [[ $(echo $ligne | grep "Production") == "" ]] ; then + groupadd production + fi + + # On regarde si les groups ont été créé + # tail /etc/group + # echo $metier +done < $file \ No newline at end of file diff --git a/sisr1/tp04_scripts_admin/createLogins.sh b/sisr1/tp04_scripts_admin/createLogins.sh new file mode 100644 index 0000000..821789b --- /dev/null +++ b/sisr1/tp04_scripts_admin/createLogins.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +fichier_a_lire='./Users.csv' +fichier_a_ecrire='./logins.csv' + +# Suppression du fichier +rm $fichier_a_ecrire 2> /dev/null # Redirection des erreurs +# Création du fichier login.csv +touch $fichier_a_ecrire + +while read ligne +do + aecrire="" + # A chaque itération, stocker le prénom dans $prenom + prenom=$(echo $ligne | cut -d "," -f1) + # A chaque itération, stocker le nom dans $nom + nom=$(echo $ligne | cut -d "," -f2) + # A chaque itération, stocker le métier dans $metier + group=$(echo $ligne | cut -d "," -f5) + login=? + password=$(tr -dc A-Za-z0-9 > $fichier_a_ecrire +done < $fichier_a_lire + diff --git a/sisr1/tp04_scripts_admin/gitpush.sh b/sisr1/tp04_scripts_admin/gitpush.sh new file mode 100644 index 0000000..522d06d --- /dev/null +++ b/sisr1/tp04_scripts_admin/gitpush.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +if [ -z "$1" ] ; then + read -p "Erreur: Ecrivez un message " message +else + message="$1" +fi + +# Ajout des fichiers modifiers +git add . + +# Commit avec le message +git commit -m "$message" + +# Push vers le dépot +git push -u https://anthony.boillot@gitea.lyc-lecastel.fr/anthony.boillot/siotp.git \ No newline at end of file diff --git a/sisr1/tp04_scripts_admin/logins.csv b/sisr1/tp04_scripts_admin/logins.csv new file mode 100644 index 0000000..975a9c2 --- /dev/null +++ b/sisr1/tp04_scripts_admin/logins.csv @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +