Nouveau fichier : sisr1/tp04/auto_nat/README.md

Nouveau fichier : sisr1/tp04/auto_nat/nat.service
	Nouveau fichier : sisr1/tp04/scripts_and_files/Users.csv
	Nouveau fichier : sisr1/tp04/scripts_and_files/createLogins.sh
	Nouveau fichier : sisr1/tp04/scripts_and_files/createUsers.sh
	Nouveau fichier : sisr1/tp04/scripts_and_files/logins.csv
	Nouveau fichier : sisr1/tp04/scripts_and_files/remoteCreation.sh
This commit is contained in:
Guillaume Emorine 2024-03-04 09:44:13 +01:00
parent 4d1beb60d3
commit 52569f3a5f
7 changed files with 114 additions and 0 deletions

View File

@ -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 !

View File

@ -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

View File

@ -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,
1 Ermengarde Berthelmot eberthelmot0@webmd.com Female Accountant
2 Kassi Bunker kbunker1@xinhuanet.com Female Production
3 Moises McCallum mmccallum2@i2i.jp Male Production
4 Patrizio Lune plune3@upenn.edu Male Accountant
5 Blanch Everix beverix4@php.net Female Accountant
6 Stafani Kibbel skibbel5@marriott.com Female Production
7 Ignacius Mosdell imosdell6@cloudflare.com Male Management
8 Jeana Waller-Bridge jwallerbridge7@mapy.cz Female Management
9 Elroy Dressel edressel8@opera.com Male Production
10 Thea Strettell tstrettell9@nature.com Female Production
11 Solomon Insoll sinsolla@utexas.edu Male Accountant
12 Carri Feedome cfeedomeb@ask.com Female Accountant
13 Padraic Chetwind pchetwindc@last.fm Male Management
14 Solly D'Ugo sdugod@uiuc.edu Male Production
15 Konstanze MacCostigan kmaccostigane@seattletimes.com Female Accountant
16 Roxane Powlesland rpowleslandf@pcworld.com Female Management
17 Orelle Kennealy okennealyg@arstechnica.com Female Production
18 Sukey Soitoux ssoitouxh@shinystat.com Female Production
19 Nelli Syce nsycei@blogger.com Female Production
20 Clarisse Shillam cshillamj@dailymotion.com Female Production
21 Carin Gueny cguenyk@naver.com Female Management
22 Donny Riepel driepell@addtoany.com Male Production
23 Daniella Ralfe dralfem@wunderground.com Female Production
24 Lexy Clynmans lclynmansn@furl.net Female Production
25 Gardiner Adamthwaite gadamthwaiteo@spotify.com Male Production
26 Woodman Lippett wlippettp@purevolume.com Male Production
27 Nadya Munnion nmunnionq@flavors.me Female Production
28 Llewellyn Habershon lhabershonr@alibaba.com Male Production
29 Isaak Greatrex igreatrexs@seesaa.net Male Production
30 Darill Frostdyke dfrostdyket@cafepress.com Male Production

View File

@ -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

View File

@ -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

View File

@ -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
1 eberthelmot a0faa388 Ermengarde Berthelmot Accountant
2 kbunker cc9b1c09 Kassi Bunker Production
3 mmccallum 81f11471 Moises McCallum Production
4 plune 0a52910c Patrizio Lune Accountant
5 beverix f0736efe Blanch Everix Accountant
6 skibbel f890d6d1 Stafani Kibbel Production
7 imosdell a97cd2b8 Ignacius Mosdell Management
8 jwaller-bridge 9c43389e Jeana Waller-Bridge Management
9 edressel 8831e520 Elroy Dressel Production
10 tstrettell 0bd22c22 Thea Strettell Production
11 sinsoll 91c81969 Solomon Insoll Accountant
12 cfeedome be5d9acb Carri Feedome Accountant
13 pchetwind f60802f5 Padraic Chetwind Management
14 sd'ugo 8b6cd4c2 Solly D'Ugo Production
15 kmaccostigan 4114aff4 Konstanze MacCostigan Accountant
16 rpowlesland 05e19a95 Roxane Powlesland Management
17 okennealy 04f8d927 Orelle Kennealy Production
18 ssoitoux 9e931572 Sukey Soitoux Production
19 nsyce 29a54396 Nelli Syce Production
20 cshillam 8a394f6a Clarisse Shillam Production
21 cgueny 6d30f53a Carin Gueny Management
22 driepel 45db9a6b Donny Riepel Production
23 dralfe d14bcb76 Daniella Ralfe Production
24 lclynmans 98d3e926 Lexy Clynmans Production
25 gadamthwaite 4d6313a8 Gardiner Adamthwaite Production
26 wlippett 9423f972 Woodman Lippett Production
27 nmunnion 80f1c167 Nadya Munnion Production
28 lhabershon 67c2be97 Llewellyn Habershon Production
29 igreatrex 90715fb9 Isaak Greatrex Production
30 dfrostdyke 4abe7ab1 Darill Frostdyke Production

View File

@ -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