From f84127bcc7d260cbfaea925403756e890d6e2328 Mon Sep 17 00:00:00 2001 From: Raphanaud Date: Wed, 29 Sep 2021 08:40:23 +0200 Subject: [PATCH] script --- sio2/sisr/script/bash/script/crsamba1 | 10 +++++++ sio2/sisr/script/bash/script/crsamba2 | 15 +++++++++++ sio2/sisr/script/bash/script/crsamba3 | 19 +++++++++++++ sio2/sisr/script/bash/script/crsamba4 | 22 +++++++++++++++ sio2/sisr/script/bash/script/crsamba5 | 28 +++++++++++++++++++ sio2/sisr/script/bash/script/crsamba7 | 31 ++++++++++++++++++++++ sio2/sisr/script/bash/script/fichier.pwd | 1 + sio2/sisr/script/bash/script/rmsamba | 28 +++++++++++++++++++ sio2/sisr/script/bash/script/user.txt | 4 +++ sio2/sisr/script/bash/script/user2.txt | 4 +++ sio2/sisr/script/bash/script/user2.txt.pwd | 26 ++++++++++++++++++ 11 files changed, 188 insertions(+) create mode 100755 sio2/sisr/script/bash/script/crsamba1 create mode 100755 sio2/sisr/script/bash/script/crsamba2 create mode 100755 sio2/sisr/script/bash/script/crsamba3 create mode 100755 sio2/sisr/script/bash/script/crsamba4 create mode 100755 sio2/sisr/script/bash/script/crsamba5 create mode 100755 sio2/sisr/script/bash/script/crsamba7 create mode 100644 sio2/sisr/script/bash/script/fichier.pwd create mode 100755 sio2/sisr/script/bash/script/rmsamba create mode 100644 sio2/sisr/script/bash/script/user.txt create mode 100644 sio2/sisr/script/bash/script/user2.txt create mode 100644 sio2/sisr/script/bash/script/user2.txt.pwd diff --git a/sio2/sisr/script/bash/script/crsamba1 b/sio2/sisr/script/bash/script/crsamba1 new file mode 100755 index 0000000..5250ac8 --- /dev/null +++ b/sio2/sisr/script/bash/script/crsamba1 @@ -0,0 +1,10 @@ +#!/bin/bash +set -o errexit +set -o nounset +fich='user.txt' +while read ligne +do + echo "${ligne}" +done < "${fich}" +exit 0 + diff --git a/sio2/sisr/script/bash/script/crsamba2 b/sio2/sisr/script/bash/script/crsamba2 new file mode 100755 index 0000000..9c74828 --- /dev/null +++ b/sio2/sisr/script/bash/script/crsamba2 @@ -0,0 +1,15 @@ +#!/bin/bash +set -o errexit +set -o nounset +if [[ $# != 1 ]]; then + echo "usage : $0 " + exit 1 +fi +fich="$1" +while read ligne +do + echo "${ligne}" +done < "${fich}" +exit 0 + + diff --git a/sio2/sisr/script/bash/script/crsamba3 b/sio2/sisr/script/bash/script/crsamba3 new file mode 100755 index 0000000..53333c6 --- /dev/null +++ b/sio2/sisr/script/bash/script/crsamba3 @@ -0,0 +1,19 @@ +#!/bin/bash +set -o errexit +set -o nounset +if [[ $# != 1 ]]; then + echo "usage : $0 " + exit 1 +fi +fich="$1" +if ! [[ -r "${fich}" ]]; then + echo "$0 : erreur ouverture fichier ${fich}" + exit 2 +fi +while read ligne +do + echo "${ligne}" +done < "${fich}" +exit 0 + + diff --git a/sio2/sisr/script/bash/script/crsamba4 b/sio2/sisr/script/bash/script/crsamba4 new file mode 100755 index 0000000..0c40eb2 --- /dev/null +++ b/sio2/sisr/script/bash/script/crsamba4 @@ -0,0 +1,22 @@ +#!/bin/bash +set -o errexit +set -o nounset +if [[ $# != 1 ]]; then + echo "usage : $0 " + exit 1 +fi +fich="$1" +if ! [[ -r "${fich}" ]]; then + echo "$0 : erreur ouverture fichier ${fich}" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}" |cut -f1 -d':') + nom=$(echo "${ligne}" |cut -f2 -d':') + echo "$login" + echo "$nom" +done < "${fich}" +exit 0 + + diff --git a/sio2/sisr/script/bash/script/crsamba5 b/sio2/sisr/script/bash/script/crsamba5 new file mode 100755 index 0000000..3e5c58b --- /dev/null +++ b/sio2/sisr/script/bash/script/crsamba5 @@ -0,0 +1,28 @@ +#!/bin/bash +#set -o errexit +set -o nounset +if [[ $# != 1 ]]; then + echo "usage : $0 " + exit 1 +fi +fich="$1" +if ! [[ -r "${fich}" ]]; then + echo "$0 : erreur ouverture fichier ${fich}" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}" |cut -f1 -d':') + nom=$(echo "${ligne}" |cut -f2 -d':') + getent passwd "${login}" >> /dev/null + if [[ $? != 0 ]] ; then + useradd -m -d /home/${login} -c "${nom}" -s /bin/bash ${login} + + else + echo "utilisateur ${login} existant" + fi +done < "${fich}" + +exit 0 + + diff --git a/sio2/sisr/script/bash/script/crsamba7 b/sio2/sisr/script/bash/script/crsamba7 new file mode 100755 index 0000000..054a261 --- /dev/null +++ b/sio2/sisr/script/bash/script/crsamba7 @@ -0,0 +1,31 @@ +#!/bin/bash +#set -o errexit +set -o nounset +PATH=${PATH}:/usr/sbin +if [[ $# != 1 ]]; then + echo "usage : $0 " + exit 1 +fi +fich="$1" +if ! [[ -r "${fich}" ]]; then + echo "$0 : erreur ouverture fichier ${fich}" + exit 2 +fi +while read ligne +do + login=$(echo "${ligne}" |cut -f1 -d':') + nom=$(echo "${ligne}" |cut -f2 -d':') + getent passwd "${login}" >> /dev/null + if [[ $? != 0 ]] ; then + useradd -m -d /home/${login} -c "${nom}" -s /bin/bash ${login} + pw=$(pwgen 4 1) + echo "${login}:${pw}"|chpasswd + echo "${login}:${pw}" >> "${fich}.pwd" + else + echo "$0 : utilisateur ${login} existant" + fi +done < "${fich}" + +exit 0 + + diff --git a/sio2/sisr/script/bash/script/fichier.pwd b/sio2/sisr/script/bash/script/fichier.pwd new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/sio2/sisr/script/bash/script/fichier.pwd @@ -0,0 +1 @@ + diff --git a/sio2/sisr/script/bash/script/rmsamba b/sio2/sisr/script/bash/script/rmsamba new file mode 100755 index 0000000..132496c --- /dev/null +++ b/sio2/sisr/script/bash/script/rmsamba @@ -0,0 +1,28 @@ +#!/bin/bash +#set -o errexit +set -o nounset +if [ $# != 1 ] +then + echo "usage : $0 " + exit 1 +fi +fich="$1" +if ! [[ -r "${fich}" ]]; then + echo "$0 : erreur ouverture fichier ${fich}" + exit 2 +fi +while read -r ligne +do + login=$(echo "${ligne}" |cut -f1 -d':') + + echo "${login}" + getent passwd "${login}" >> /dev/null + if [[ $? = 0 ]] + then + userdel -r "${login}" + fi +done < "${fich}" + +exit 0 + + diff --git a/sio2/sisr/script/bash/script/user.txt b/sio2/sisr/script/bash/script/user.txt new file mode 100644 index 0000000..ddaebca --- /dev/null +++ b/sio2/sisr/script/bash/script/user.txt @@ -0,0 +1,4 @@ +lucien +claudine +robert +marcelle diff --git a/sio2/sisr/script/bash/script/user2.txt b/sio2/sisr/script/bash/script/user2.txt new file mode 100644 index 0000000..67b8d2a --- /dev/null +++ b/sio2/sisr/script/bash/script/user2.txt @@ -0,0 +1,4 @@ +lucien:Lucien Dubois +claudine:Claudine Duparc +robert:Robert Macaire +marcelle:Marcelle Desforets diff --git a/sio2/sisr/script/bash/script/user2.txt.pwd b/sio2/sisr/script/bash/script/user2.txt.pwd new file mode 100644 index 0000000..09e3533 --- /dev/null +++ b/sio2/sisr/script/bash/script/user2.txt.pwd @@ -0,0 +1,26 @@ +: +: +: +: +: +: +: +: +: +: +: +: +lucien:1XfC +claudine:PT2M +robert:K4PJ +marcelle:i4WH +claudine:7Giq +robert:VO4u +marcelle:3b8S +claudine:7qzL +robert:NvV6 +marcelle:7QnY +lucien:e5Hz +claudine:j9Un +robert:ZnJ6 +marcelle:B7nR