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
		
			
				
	
	
		
			19 lines
		
	
	
		
			480 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			480 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
| #!/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
 |