From 52569f3a5f7cac1b71d28750e5cd2c5c24d0a160 Mon Sep 17 00:00:00 2001 From: Guillaume Emorine Date: Mon, 4 Mar 2024 09:44:13 +0100 Subject: [PATCH] =?UTF-8?q?=09Nouveau=20fichier=C2=A0:=20sisr1/tp04/auto?= =?UTF-8?q?=5Fnat/README.md=20=09Nouveau=20fichier=C2=A0:=20sisr1/tp04/aut?= =?UTF-8?q?o=5Fnat/nat.service=20=09Nouveau=20fichier=C2=A0:=20sisr1/tp04/?= =?UTF-8?q?scripts=5Fand=5Ffiles/Users.csv=20=09Nouveau=20fichier=C2=A0:?= =?UTF-8?q?=20sisr1/tp04/scripts=5Fand=5Ffiles/createLogins.sh=20=09Nouvea?= =?UTF-8?q?u=20fichier=C2=A0:=20sisr1/tp04/scripts=5Fand=5Ffiles/createUse?= =?UTF-8?q?rs.sh=20=09Nouveau=20fichier=C2=A0:=20sisr1/tp04/scripts=5Fand?= =?UTF-8?q?=5Ffiles/logins.csv=20=09Nouveau=20fichier=C2=A0:=20sisr1/tp04/?= =?UTF-8?q?scripts=5Fand=5Ffiles/remoteCreation.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sisr1/tp04/auto_nat/README.md | 2 ++ sisr1/tp04/auto_nat/nat.service | 9 ++++++ sisr1/tp04/scripts_and_files/Users.csv | 30 +++++++++++++++++++ sisr1/tp04/scripts_and_files/createLogins.sh | 17 +++++++++++ sisr1/tp04/scripts_and_files/createUsers.sh | 18 +++++++++++ sisr1/tp04/scripts_and_files/logins.csv | 30 +++++++++++++++++++ .../tp04/scripts_and_files/remoteCreation.sh | 8 +++++ 7 files changed, 114 insertions(+) create mode 100644 sisr1/tp04/auto_nat/README.md create mode 100644 sisr1/tp04/auto_nat/nat.service create mode 100644 sisr1/tp04/scripts_and_files/Users.csv create mode 100644 sisr1/tp04/scripts_and_files/createLogins.sh create mode 100644 sisr1/tp04/scripts_and_files/createUsers.sh create mode 100644 sisr1/tp04/scripts_and_files/logins.csv create mode 100644 sisr1/tp04/scripts_and_files/remoteCreation.sh diff --git a/sisr1/tp04/auto_nat/README.md b/sisr1/tp04/auto_nat/README.md new file mode 100644 index 0000000..d433438 --- /dev/null +++ b/sisr1/tp04/auto_nat/README.md @@ -0,0 +1,2 @@ +Copy to /etc/systemd/system . (Do not put the space or the dot, nor this text in parentheses or the text that's before the first forwards slash) +Anywhere else will NOT WORK ! \ No newline at end of file diff --git a/sisr1/tp04/auto_nat/nat.service b/sisr1/tp04/auto_nat/nat.service new file mode 100644 index 0000000..d3d2afd --- /dev/null +++ b/sisr1/tp04/auto_nat/nat.service @@ -0,0 +1,9 @@ +[Unit] +Description=Running nat.sh script on startup thanks to a systemd unit. + +[Service] +Type=oneshot +ExecStart=/bin/bash /root/nat.sh + +[Install] +WantedBy=multi-user.target diff --git a/sisr1/tp04/scripts_and_files/Users.csv b/sisr1/tp04/scripts_and_files/Users.csv new file mode 100644 index 0000000..9dfb324 --- /dev/null +++ b/sisr1/tp04/scripts_and_files/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_and_files/createLogins.sh b/sisr1/tp04/scripts_and_files/createLogins.sh new file mode 100644 index 0000000..197c424 --- /dev/null +++ b/sisr1/tp04/scripts_and_files/createLogins.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# +rm ./logins.csv +while read line +do + touch ./temptp4.txt + file='./temptp4.txt' + echo $line > $file + surname=$(cut -d "," -f 1 $file) + name=$(cut -d "," -f 2 $file) + group=$(cut -d "," -f 5 $file) + initials=$(cut -c 1 $file) + id=$(echo $initials$name | tr [:upper:] [:lower:]) + passwd=$(echo $RANDOM | md5sum | head -c 8) + echo $id","$passwd","$surname","$name","$group>> logins.csv + rm ./temptp4.txt +done < ./Users.csv diff --git a/sisr1/tp04/scripts_and_files/createUsers.sh b/sisr1/tp04/scripts_and_files/createUsers.sh new file mode 100644 index 0000000..6ddd41d --- /dev/null +++ b/sisr1/tp04/scripts_and_files/createUsers.sh @@ -0,0 +1,18 @@ +#!/bin/bash +while read line +do + touch ./temptp4.txt + file="./temptp4.txt" + echo $line > $file + user=$(cut -d "," -f 1 $file) + usergroup=$(cut -d "," -f 5 $file) + passwd=$(cut -d "," -f 2 $file) + if ! grep -q $usergroup /etc/group ; then + echo "tentative creation $usergroup" + groupadd "$usergroup" + fi + useradd --create-home --groups $usergroup --shell /bin/bash $user + (echo $passwd ; echo $passwd) | passwd $user + chown $user /home/$user + rm ./temptp4.txt +done < ./logins.csv diff --git a/sisr1/tp04/scripts_and_files/logins.csv b/sisr1/tp04/scripts_and_files/logins.csv new file mode 100644 index 0000000..0053371 --- /dev/null +++ b/sisr1/tp04/scripts_and_files/logins.csv @@ -0,0 +1,30 @@ +eberthelmot,a0faa388,Ermengarde,Berthelmot,Accountant +kbunker,cc9b1c09,Kassi,Bunker,Production +mmccallum,81f11471,Moises,McCallum,Production +plune,0a52910c,Patrizio,Lune,Accountant +beverix,f0736efe,Blanch,Everix,Accountant +skibbel,f890d6d1,Stafani,Kibbel,Production +imosdell,a97cd2b8,Ignacius,Mosdell,Management +jwaller-bridge,9c43389e,Jeana,Waller-Bridge,Management +edressel,8831e520,Elroy,Dressel,Production +tstrettell,0bd22c22,Thea,Strettell,Production +sinsoll,91c81969,Solomon,Insoll,Accountant +cfeedome,be5d9acb,Carri,Feedome,Accountant +pchetwind,f60802f5,Padraic,Chetwind,Management +sd'ugo,8b6cd4c2,Solly,D'Ugo,Production +kmaccostigan,4114aff4,Konstanze,MacCostigan,Accountant +rpowlesland,05e19a95,Roxane,Powlesland,Management +okennealy,04f8d927,Orelle,Kennealy,Production +ssoitoux,9e931572,Sukey,Soitoux,Production +nsyce,29a54396,Nelli,Syce,Production +cshillam,8a394f6a,Clarisse,Shillam,Production +cgueny,6d30f53a,Carin,Gueny,Management +driepel,45db9a6b,Donny,Riepel,Production +dralfe,d14bcb76,Daniella,Ralfe,Production +lclynmans,98d3e926,Lexy,Clynmans,Production +gadamthwaite,4d6313a8,Gardiner,Adamthwaite,Production +wlippett,9423f972,Woodman,Lippett,Production +nmunnion,80f1c167,Nadya,Munnion,Production +lhabershon,67c2be97,Llewellyn,Habershon,Production +igreatrex,90715fb9,Isaak,Greatrex,Production +dfrostdyke,4abe7ab1,Darill,Frostdyke,Production diff --git a/sisr1/tp04/scripts_and_files/remoteCreation.sh b/sisr1/tp04/scripts_and_files/remoteCreation.sh new file mode 100644 index 0000000..af7f04e --- /dev/null +++ b/sisr1/tp04/scripts_and_files/remoteCreation.sh @@ -0,0 +1,8 @@ +#!/bin/bash +scp ./createUsers.sh root@$1:/root +scp ./logins.csv root@$1:/root +ssh root@$1 "chmod -x /root/createUsers.sh" +ssh root@$1 "bash /root/createUsers.sh" +ssh root@$1 "rm /root/logins.csv" +ssh root@$1 "rm /root/createUsers.sh" +exit