From 368a32a31cffbf4c67b71b33d6ad76b2716be78e Mon Sep 17 00:00:00 2001 From: "aboulai.bayo" Date: Mon, 17 Feb 2025 11:55:35 +0100 Subject: [PATCH] ajout d'un script creatgroups --- sisr1/tp04_scripts_admin/Users.csv | 30 ++++++++++++++++++++++++ sisr1/tp04_scripts_admin/createGroups.sh | 14 +++++++++++ 2 files changed, 44 insertions(+) create mode 100644 sisr1/tp04_scripts_admin/Users.csv create mode 100644 sisr1/tp04_scripts_admin/createGroups.sh 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..b6fce44 --- /dev/null +++ b/sisr1/tp04_scripts_admin/createGroups.sh @@ -0,0 +1,14 @@ +#!/bin/bash +fichier=Users.csv + +while read ligne # définit la variable "ligne" comme le contenu de la ligne du fichier en cours de lecture +do + echo $ligne #on peut alors utiliser sa valeur dans l'instruction, exemple ici avec echo + #autres commandes + metier=$(echo $ligne | cut -d "," -f5 ) #A chaque utilisateur itération,stocker le méttier + #$metier + grep $metier /etc/group #Identifier les groupes + if [[ $(echo $user_line | grep $metier /etc/group) == ""]] ; then + groupadd $metier + fi +done < $fichier \ No newline at end of file