diff --git a/sio1/sisr1/40-scriptBash/crsamba1.sh b/sio1/sisr1/40-scriptBash/crsamba1.sh new file mode 100755 index 0000000..e6204b5 --- /dev/null +++ b/sio1/sisr1/40-scriptBash/crsamba1.sh @@ -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 diff --git a/sio1/sisr1/40-scriptBash/crsamba2.sh b/sio1/sisr1/40-scriptBash/crsamba2.sh new file mode 100755 index 0000000..85fb0cc --- /dev/null +++ b/sio1/sisr1/40-scriptBash/crsamba2.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e +set -u + +#Code + +if [[ $# -ne 1 ]] ; then + echo "usage : $0 " + exit 1 +fi + + + +fichier=$1 + +while read ligne +do + echo $ligne +done < $fichier diff --git a/sio1/sisr1/40-scriptBash/crsamba3.sh b/sio1/sisr1/40-scriptBash/crsamba3.sh new file mode 100755 index 0000000..e4435bf --- /dev/null +++ b/sio1/sisr1/40-scriptBash/crsamba3.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e +set -u + +#Code + +if [[ $# -ne 1 ]] ; then + echo "usage : $0 " + 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 diff --git a/sio1/sisr1/40-scriptBash/crsamba4.sh b/sio1/sisr1/40-scriptBash/crsamba4.sh new file mode 100755 index 0000000..3c1ba4f --- /dev/null +++ b/sio1/sisr1/40-scriptBash/crsamba4.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -e +set -u + +#Code + +#Message aide de syntaxe +if [[ $# -ne 1 ]] ; then + echo "usage : $0 " + 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 diff --git a/sio1/sisr1/40-scriptBash/crsamba5.sh b/sio1/sisr1/40-scriptBash/crsamba5.sh new file mode 100755 index 0000000..1557b42 --- /dev/null +++ b/sio1/sisr1/40-scriptBash/crsamba5.sh @@ -0,0 +1,34 @@ +#!/bin/bash +#set -e +set -u + +#Code + +#Message aide de syntaxe +if [[ $# -ne 1 ]] ; then + echo "usage : $0 " + 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" + diff --git a/sio1/sisr1/40-scriptBash/crsamba6.sh b/sio1/sisr1/40-scriptBash/crsamba6.sh new file mode 100755 index 0000000..c77083f --- /dev/null +++ b/sio1/sisr1/40-scriptBash/crsamba6.sh @@ -0,0 +1,34 @@ +#!/bin/bash +#set -e +set -u + +#Code + +#Message aide de syntaxe +if [[ $# -ne 1 ]] ; then + echo "usage : $0 " + 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" + diff --git a/sio1/sisr1/40-scriptBash/siotp b/sio1/sisr1/40-scriptBash/siotp new file mode 160000 index 0000000..17ca140 --- /dev/null +++ b/sio1/sisr1/40-scriptBash/siotp @@ -0,0 +1 @@ +Subproject commit 17ca140ec356eee09ce5a8db4963688940c6cba9 diff --git a/sio1/sisr1/40-scriptBash/users.txt b/sio1/sisr1/40-scriptBash/users.txt new file mode 100644 index 0000000..5b52e46 --- /dev/null +++ b/sio1/sisr1/40-scriptBash/users.txt @@ -0,0 +1,4 @@ +lucien:lucien Leblanc +claudine:claudine Aymar +robert:robert Duroy +marcelle:marcelle Marais