premier ajout
This commit is contained in:
parent
17ca140ec3
commit
b89810764c
14
sio1/sisr1/40-scriptBash/crsamba1.sh
Executable file
14
sio1/sisr1/40-scriptBash/crsamba1.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -u
|
||||
|
||||
#Variable chemin
|
||||
|
||||
fichier=/root/users.txt
|
||||
|
||||
#Code
|
||||
|
||||
while read ligne
|
||||
do
|
||||
echo $ligne
|
||||
done < $fichier
|
19
sio1/sisr1/40-scriptBash/crsamba2.sh
Executable file
19
sio1/sisr1/40-scriptBash/crsamba2.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -u
|
||||
|
||||
#Code
|
||||
|
||||
if [[ $# -ne 1 ]] ; then
|
||||
echo "usage : $0 <fichier>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
fichier=$1
|
||||
|
||||
while read ligne
|
||||
do
|
||||
echo $ligne
|
||||
done < $fichier
|
23
sio1/sisr1/40-scriptBash/crsamba3.sh
Executable file
23
sio1/sisr1/40-scriptBash/crsamba3.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -u
|
||||
|
||||
#Code
|
||||
|
||||
if [[ $# -ne 1 ]] ; then
|
||||
echo "usage : $0 <fichier>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
fichier=$1
|
||||
if [[ ! -r "$fichier" ]] ; then
|
||||
echo "$0 : erreur ouverture $fichier"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
while read ligne
|
||||
do
|
||||
echo $ligne
|
||||
done < $fichier
|
26
sio1/sisr1/40-scriptBash/crsamba4.sh
Executable file
26
sio1/sisr1/40-scriptBash/crsamba4.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -u
|
||||
|
||||
#Code
|
||||
|
||||
#Message aide de syntaxe
|
||||
if [[ $# -ne 1 ]] ; then
|
||||
echo "usage : $0 <fichier>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Affichage erreur ouverture
|
||||
fichier=$1
|
||||
if [[ ! -r "$fichier" ]] ; then
|
||||
echo "$0 : erreur ouverture $fichier"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
while read ligne
|
||||
do
|
||||
Login=$(echo $ligne |cut -d: -f1)
|
||||
Nomcpl=$(echo $ligne |cut -d: -f2)
|
||||
echo "$Login: $Nomcpl"
|
||||
done < $fichier
|
34
sio1/sisr1/40-scriptBash/crsamba5.sh
Executable file
34
sio1/sisr1/40-scriptBash/crsamba5.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
#set -e
|
||||
set -u
|
||||
|
||||
#Code
|
||||
|
||||
#Message aide de syntaxe
|
||||
if [[ $# -ne 1 ]] ; then
|
||||
echo "usage : $0 <fichier>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Affichage erreur ouverture
|
||||
fichier=$1
|
||||
if [[ ! -r "$fichier" ]] ; then
|
||||
echo "$0 : erreur ouverture $fichier"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
while read ligne
|
||||
do
|
||||
Login=$(echo "$ligne" |cut -d: -f1)
|
||||
Nomcpl=$(echo "$ligne" |cut -d: -f2)
|
||||
echo "${Login}: ${Nomcpl}"
|
||||
getent passwd "${Login}" >> /dev/null
|
||||
if [[ $? -ne 0 ]] ; then
|
||||
sudo useradd -c "${Nomcpl}" --create-home --home-dir "/home/${Login}" --shell /bin/bash "${Login}"
|
||||
else
|
||||
echo "$0 : Utilisateur ${Login} est déjà existant "
|
||||
fi
|
||||
|
||||
done < "$fichier"
|
||||
|
34
sio1/sisr1/40-scriptBash/crsamba6.sh
Executable file
34
sio1/sisr1/40-scriptBash/crsamba6.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
#set -e
|
||||
set -u
|
||||
|
||||
#Code
|
||||
|
||||
#Message aide de syntaxe
|
||||
if [[ $# -ne 1 ]] ; then
|
||||
echo "usage : $0 <fichier>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Affichage erreur ouverture
|
||||
fichier=$1
|
||||
if [[ ! -r "$fichier" ]] ; then
|
||||
echo "$0 : erreur ouverture $fichier"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
while read ligne
|
||||
do
|
||||
Login=$(echo "$ligne" |cut -d: -f1)
|
||||
Nomcpl=$(echo "$ligne" |cut -d: -f2)
|
||||
echo "${Login}: ${Nomcpl}"
|
||||
getent passwd "${Login}" >> /dev/null
|
||||
if [[ $? -eq 0 ]] ; then
|
||||
sudo rm "${Login}"
|
||||
else
|
||||
echo "$0 : Utilisateur ${Login} est déjà existant "
|
||||
fi
|
||||
|
||||
done < "$fichier"
|
||||
|
1
sio1/sisr1/40-scriptBash/siotp
Submodule
1
sio1/sisr1/40-scriptBash/siotp
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 17ca140ec356eee09ce5a8db4963688940c6cba9
|
4
sio1/sisr1/40-scriptBash/users.txt
Normal file
4
sio1/sisr1/40-scriptBash/users.txt
Normal file
@ -0,0 +1,4 @@
|
||||
lucien:lucien Leblanc
|
||||
claudine:claudine Aymar
|
||||
robert:robert Duroy
|
||||
marcelle:marcelle Marais
|
Loading…
x
Reference in New Issue
Block a user