From 3300602f9c2689c4718828b97b1129820debc14e Mon Sep 17 00:00:00 2001 From: KONE Date: Mon, 27 Mar 2023 16:47:20 +0200 Subject: [PATCH] scripts tp crsamba --- sio1/sisr1/18-bash/tpbash/crsamba | 6 ++++ sio1/sisr1/18-bash/tpbash/crsamba3 | 22 +++++++++++++ sio1/sisr1/18-bash/tpbash/crsamba4 | 25 +++++++++++++++ sio1/sisr1/18-bash/tpbash/crsamba5 | 34 +++++++++++++++++++++ sio1/sisr1/18-bash/tpbash/crsamba6 | 29 ++++++++++++++++++ sio1/sisr1/18-bash/tpbash/crsamba7 | 29 ++++++++++++++++++ sio1/sisr1/18-bash/tpbash/sio@192.168.0.100 | 34 +++++++++++++++++++++ sio1/sisr1/18-bash/tpbash/users.txt | 4 +++ sio1/sisr1/18-bash/tpbash/users.txt.pw | 12 ++++++++ 9 files changed, 195 insertions(+) create mode 100755 sio1/sisr1/18-bash/tpbash/crsamba create mode 100755 sio1/sisr1/18-bash/tpbash/crsamba3 create mode 100755 sio1/sisr1/18-bash/tpbash/crsamba4 create mode 100755 sio1/sisr1/18-bash/tpbash/crsamba5 create mode 100755 sio1/sisr1/18-bash/tpbash/crsamba6 create mode 100755 sio1/sisr1/18-bash/tpbash/crsamba7 create mode 100755 sio1/sisr1/18-bash/tpbash/sio@192.168.0.100 create mode 100644 sio1/sisr1/18-bash/tpbash/users.txt create mode 100644 sio1/sisr1/18-bash/tpbash/users.txt.pw 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