diff --git a/sio1/sisr1/18-bash/tpbash/crsamba b/sio1/sisr1/18-bash/tpbash/crsamba new file mode 100755 index 0000000..2734678 --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/crsamba @@ -0,0 +1,6 @@ +#!/bin/bash +fich=users.txt +while read ligne +do + echo $ligne +done < $fich diff --git a/sio1/sisr1/18-bash/tpbash/crsamba3 b/sio1/sisr1/18-bash/tpbash/crsamba3 new file mode 100755 index 0000000..8e01f1a --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/crsamba3 @@ -0,0 +1,22 @@ +#!/bin/bash + + +usage() { + echo "usage : $0 " + exit 1 +} + +if [[ $# != 1 ]] ; then + usage +fi + +fich=$1 +if [[ ! -r $fich ]] ; then + echo "i$0: erreur ouverture fichier $fich" + exit 2 +fi +while read ligne +do + echo $ligne +done < $fich + diff --git a/sio1/sisr1/18-bash/tpbash/crsamba4 b/sio1/sisr1/18-bash/tpbash/crsamba4 new file mode 100755 index 0000000..ddb68c2 --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/crsamba4 @@ -0,0 +1,25 @@ +#!/bin/bash + + +usage() { + echo "usage : $0 " + exit 1 +} + +if [[ $# != 1 ]] ; then + usage +fi + +fich=$1 +if [[ ! -r $fich ]] ; then + echo "i$0: erreur ouverture fichier $fich" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}"|cut -f1 -d:) + echo $login + nom=$(echo "${ligne}"|cut -f2 -d:) + echo $nom +done < $fich + diff --git a/sio1/sisr1/18-bash/tpbash/crsamba5 b/sio1/sisr1/18-bash/tpbash/crsamba5 new file mode 100755 index 0000000..b03802b --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/crsamba5 @@ -0,0 +1,34 @@ +#!/bin/bash + + +usage() { + echo "usage : $0 " + exit 1 +} + +if [[ $# != 1 ]] ; then + usage +fi + +fich=$1 +if [[ ! -r $fich ]] ; then + echo "i$0: erreur ouverture fichier $fich" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}"|cut -f1 -d:) + #echo $login + nom=$(echo "${ligne}"|cut -f2 -d:) + #echo $nom + if ! getent passwd "${nom}" > /dev/null 2 >&1 + then + sudo useradd -m -c "${nom}" -s /bin/bash "${login}" + mdp=$(pwgen 6 1) + echo "${login}:${mdp}"|sudo chpasswd + echo "${login}:${mdp}">>${fich}.pw + + else + echo "${nom}" existe déja + fi +done < $fich diff --git a/sio1/sisr1/18-bash/tpbash/crsamba6 b/sio1/sisr1/18-bash/tpbash/crsamba6 new file mode 100755 index 0000000..9728ee0 --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/crsamba6 @@ -0,0 +1,29 @@ +#!/bin/bash + + +usage() { + echo "usage : $0 " + exit 1 +} + +if [[ $# != 1 ]] ; then + usage +fi + +fich=$1 +if [[ ! -r $fich ]] ; then + echo "i$0: erreur ouverture fichier $fich" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}"|cut -f1 -d:) + #echo $login + nom=$(echo "${ligne}"|cut -f2 -d:) + #echo $nom + if getent passwd "${login}" > /dev/null 2 >&1 + then + sudo userdel -r -f "${login}" + fi + #echo $ligne +done < $fich diff --git a/sio1/sisr1/18-bash/tpbash/crsamba7 b/sio1/sisr1/18-bash/tpbash/crsamba7 new file mode 100755 index 0000000..9728ee0 --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/crsamba7 @@ -0,0 +1,29 @@ +#!/bin/bash + + +usage() { + echo "usage : $0 " + exit 1 +} + +if [[ $# != 1 ]] ; then + usage +fi + +fich=$1 +if [[ ! -r $fich ]] ; then + echo "i$0: erreur ouverture fichier $fich" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}"|cut -f1 -d:) + #echo $login + nom=$(echo "${ligne}"|cut -f2 -d:) + #echo $nom + if getent passwd "${login}" > /dev/null 2 >&1 + then + sudo userdel -r -f "${login}" + fi + #echo $ligne +done < $fich diff --git a/sio1/sisr1/18-bash/tpbash/sio@192.168.0.100 b/sio1/sisr1/18-bash/tpbash/sio@192.168.0.100 new file mode 100755 index 0000000..b03802b --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/sio@192.168.0.100 @@ -0,0 +1,34 @@ +#!/bin/bash + + +usage() { + echo "usage : $0 " + exit 1 +} + +if [[ $# != 1 ]] ; then + usage +fi + +fich=$1 +if [[ ! -r $fich ]] ; then + echo "i$0: erreur ouverture fichier $fich" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}"|cut -f1 -d:) + #echo $login + nom=$(echo "${ligne}"|cut -f2 -d:) + #echo $nom + if ! getent passwd "${nom}" > /dev/null 2 >&1 + then + sudo useradd -m -c "${nom}" -s /bin/bash "${login}" + mdp=$(pwgen 6 1) + echo "${login}:${mdp}"|sudo chpasswd + echo "${login}:${mdp}">>${fich}.pw + + else + echo "${nom}" existe déja + fi +done < $fich diff --git a/sio1/sisr1/18-bash/tpbash/users.txt b/sio1/sisr1/18-bash/tpbash/users.txt new file mode 100644 index 0000000..c70f134 --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/users.txt @@ -0,0 +1,4 @@ +laymar:Lucien Aymar +cperier:Claudine Perier +rdubois:Robert Dubois +mlefebvre:Marcelle Lefebvre diff --git a/sio1/sisr1/18-bash/tpbash/users.txt.pw b/sio1/sisr1/18-bash/tpbash/users.txt.pw new file mode 100644 index 0000000..7ca4527 --- /dev/null +++ b/sio1/sisr1/18-bash/tpbash/users.txt.pw @@ -0,0 +1,12 @@ +laymar:uomeM8 +cperier:za2Iez +rdubois:an6ahJ +mlefebvre:Aque8E +laymar:Eimai2 +cperier:Iesoo9 +rdubois:loo6Ac +mlefebvre:guCh0s +laymar:reY9ze +cperier:eR7iel +rdubois:Bee7Ee +mlefebvre:Ook3fe