5 Commits
v15 ... v35

Author SHA1 Message Date
Raphanaud
f84127bcc7 script 2021-09-29 08:40:23 +02:00
root
8fecc58b97 30-web/ 2021-09-24 15:37:41 +02:00
Noe Raphanaud
22590a8a8d 25-fog 2021-09-22 11:24:30 +02:00
root
e546c95c3d 15-nagios 2021-09-20 17:52:40 +02:00
root
24f3037c52 20-postfix/ 2021-09-20 17:30:22 +02:00
19 changed files with 661 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ define contact {
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
email supervisionraphanaud@gmail.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

View File

@@ -3,6 +3,7 @@ define host {
host_name srv
alias srv
address 192.168.0.26
parents localhost
}
define service{
use generic-service

View File

@@ -0,0 +1,49 @@
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
# TLS parameters
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_security_level=may
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = nagios.sio.lan
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, nagios, localhost.localdomain, , localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4

View File

@@ -0,0 +1 @@
[smtp.gmail.com]:587 supervisionraphanaud@gmail.com:Azertyuiop1+

163
sio2/sisr/25-fog/config.sh Executable file
View File

@@ -0,0 +1,163 @@
#!/bin/bash
#
# FOG is a computer imaging solution.
# Copyright (C) 2007 Chuck Syperski & Jian Zhang
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ -z $repo ]] && repo="php"
[[ -z $packageQuery ]] && packageQuery="dpkg -l \$x | grep '^ii'"
if [[ $linuxReleaseName == +(*[Bb][Ii][Aa][Nn]*) ]]; then
sysvrcconf="sysv-rc-conf"
case $OSVersion in
8)
php_ver="5"
;;
9)
php_ver="7.0"
x="*php5*"
;;
10)
php_ver="7.3"
x="*php5* *php7.0*"
;;
11)
php_ver="7.4"
x="*php5* *php7.0*"
;;
esac
old_php=$(eval $packageQuery 2>/dev/null | awk '{print $2}' | tr '\n' ' ')
if [[ -n "$old_php" ]]; then
dots "Removing old PHP version before installing the new one"
DEBIAN_FRONTEND=noninteractive apt-get purge -yq ${old_php} >/dev/null 2>&1
[[ $? -ne 0 ]] && echo "Failed" || echo "Done"
apt-get clean -yq >/dev/null 2>&1
fi
elif [[ $linuxReleaseName == +(*[Uu][Bb][Uu][Nn][Tt][Uu]*|*[Mm][Ii][Nn][Tt]*) ]]; then
DEBIAN_FRONTEND=noninteractive apt-get purge -yq sysv-rc-conf >/dev/null 2>&1
case $OSVersion in
20)
php_ver="7.4"
;;
19)
php_ver="7.3"
;;
18)
php_ver="7.2"
;;
*)
sysvrcconf="sysv-rc-conf"
php_ver="7.1"
x="*php5* *php-5*"
eval $packageQuery >>$workingdir/error_logs/fog_error_${version}.log 2>&1
if [[ $? -ne 0 ]]; then
if [[ $autoaccept != yes ]]; then
echo " *** Detected a potential need to reinstall apache and php files."
echo " *** This will remove the /etc/php* and /etc/apache2* directories"
echo " *** and remove/purge the apache and php files from this system."
echo " *** If you're okay with this please type Y, anything else will"
echo " *** continue the installation, but may mean you will need to"
echo " *** remove the files later and make proper changes as "
echo " *** necessary. (Y/N): "
read dummy
else
dummy="y"
fi
case $dummy in
[Yy])
dots "Removing apache and php files"
rm -rf /etc/php* /etc/apache2*
echo "Done"
dots "Stopping web services"
if [[ $systemctl == yes ]]; then
systemctl is-active --quiet apache2 && systemctl stop apache2 >/dev/null 2>&1 || true
fi
[[ ! $? -eq 0 ]] && echo "Failed" || echo "Done"
dots "Removing the apache and php packages"
DEBIAN_FRONTEND=noninteractive apt-get purge -yq 'apache2*' 'php5*' 'php7*' 'libapache*' >/dev/null 2>&1
[[ ! $? -eq 0 ]] && echo "Failed" || echo "Done"
apt-get clean -yq >/dev/null 2>&1
;;
esac
fi
esac
else
[[ -z $php_ver ]] && php_ver=5
fi
[[ -z $php_verAdds ]] && php_verAdds="-${php_ver}"
[[ $php_ver == 5 ]] && php_verAdds="-5.6"
[[ $php_ver != 5 ]] && phpcmd="php" || phpcmd="php5"
[[ -z $phpfpm ]] && phpfpm="php${php_ver}-fpm"
[[ -z $phpldap ]] && phpldap="php${php_ver}-ldap"
[[ -z $phpcmd ]] && phpcmd="php"
case $linuxReleaseName in
*[Uu][Bb][Uu][Nn][Tt][Uu]*|*[Bb][Ii][Aa][Nn]*|*[Mm][Ii][Nn][Tt]*)
if [[ -z $packages ]]; then
x="mysql-server"
eval $packageQuery >>$workingdir/error_logs/fog_error_${version}.log 2>&1
[[ $? -eq 0 ]] && db_packages="mysql-client mysql-server" || db_packages="mariadb-client mariadb-server"
packages="apache2 build-essential cpp curl g++ gawk gcc genisoimage git gzip htmldoc isc-dhcp-server isolinux lftp libapache2-mod-fastcgi libapache2-mod-php${php_ver} libc6 libcurl3 liblzma-dev m4 ${db_packages} net-tools nfs-kernel-server openssh-server $phpfpm php-php-gettext php${php_ver} php${php_ver}-cli php${php_ver}-curl php${php_ver}-gd php${php_ver}-json $phpldap php${php_ver}-mysql php${php_ver}-mysqlnd ${sysvrcconf} tar tftpd-hpa tftp-hpa vsftpd wget xinetd zlib1g"
else
# make sure we update all the php version numbers with those specified above
packages=${packages//php[0-9]\.[0-9]/php${php_ver}}
fi
[[ -z $packageinstaller ]] && packageinstaller="apt-get -yq install -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
[[ -z $packagelist ]] && packagelist="apt-cache pkgnames | grep"
[[ -z $packageupdater ]] && packageupdater="apt-get -yq upgrade -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
[[ -z $packmanUpdate ]] && packmanUpdate="apt-get update"
[[ -z $dhcpname ]] && dhcpname="isc-dhcp-server"
[[ -z $olddhcpname ]] && olddhcpname="dhcp3-server"
;;
esac
[[ -z $langPackages ]] && langPackages="language-pack-it language-pack-en language-pack-es language-pack-zh-hans"
[[ $php_ver != 5 ]] && packages="$packages php${php_ver}-mbstring"
if [[ -z $webdirdest ]]; then
if [[ -z $docroot ]]; then
docroot="/var/www/html/"
webdirdest="${docroot}fog/"
elif [[ "$docroot" != *'fog'* ]]; then
webdirdest="${docroot}fog/"
else
webdirdest="${docroot}/"
fi
if [[ $docroot == /var/www/html/ && ! -d $docroot ]]; then
docroot="/var/www/"
webdirdest="${docroot}fog/"
fi
fi
[[ -z $webredirect ]] && webredirect="$docroot/index.php"
[[ -z $apacheuser ]] && apacheuser="www-data"
[[ -z $apachelogdir ]] && apachelogdir="/var/log/apache2"
[[ -z $apacheerrlog ]] && apacheerrlog="$apachelogdir/error.log"
[[ -z $apacheacclog ]] && apacheacclog="$apachelogdir/access.log"
[[ -z $etcconf ]] && etcconf="/etc/apache2/sites-available/001-fog.conf"
[[ $php_ver != 5 ]] && phpini="/etc/$phpcmd/$php_ver/fpm/php.ini" || phpini="/etc/$phpcmd/fpm/php.ini"
[[ -z $storageLocation ]] && storageLocation="/images"
[[ -z $storageLocationCapture ]] && storageLocationCapture="${storageLocation}/dev"
[[ -z $dhcpconfig ]] && dhcpconfig="/etc/dhcp3/dhcpd.conf"
[[ -z $dhcpconfigother ]] && dhcpconfigother="/etc/dhcp/dhcpd.conf"
[[ -z $tftpdirdst ]] && tftpdirdst="/tftpboot"
[[ -z $tftpconfig ]] && tftpconfig="/etc/xinetd.d/tftp"
[[ -z $tftpconfigupstartconf ]] && tftpconfigupstartconf="/etc/init/tftpd-hpa.conf"
[[ -z $tftpconfigupstartdefaults ]] && tftpconfigupstartdefaults="/etc/default/tftpd-hpa"
[[ -z $ftpconfig ]] && ftpconfig="/etc/vsftpd.conf"
[[ -z $snapindir ]] && snapindir="/opt/fog/snapins"
[[ -z $jsontest ]] && jsontest="php${php_ver}-json php${php_ver}-common"
if [[ -z $dhcpd ]]; then
if [[ -e /etc/init.d/$dhcpname ]]; then
dhcpd=$dhcpname
elif [[ -e /etc/init.d/$olddhcpname ]]; then
dhcpd=$olddhcpname
fi
fi

View File

@@ -0,0 +1,137 @@
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
#ServerName wordpress
DocumentRoot /var/www/html/
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/apache2/server.crt
SSLCertificateKeyFile /etc/apache2/server.key
#SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
#SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt
# Certificate Authority (CA):
# Set the CA certificate verification path where to find CA
# certificates for client authentication or alternatively one
# huge file containing all of them (file must be PEM encoded)
# Note: Inside SSLCACertificatePath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCACertificatePath /etc/ssl/certs/
#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt
# Certificate Revocation Lists (CRL):
# Set the CA revocation path where to find CA CRLs for client
# authentication or alternatively one huge file containing all
# of them (file must be PEM encoded)
# Note: Inside SSLCARevocationPath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCARevocationPath /etc/apache2/ssl.crl/
#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl
# Client Authentication (Type):
# Client certificate verification type and depth. Types are
# none, optional, require and optional_no_ca. Depth is a
# number which specifies how deeply to verify the certificate
# issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth 10
# SSL Engine Options:
# Set various options for the SSL engine.
# o FakeBasicAuth:
# Translate the client X.509 into a Basic Authorisation. This means that
# the standard Auth/DBMAuth methods can be used for access control. The
# user name is the `one line' version of the client's X.509 certificate.
# Note that no password is obtained from the user. Every entry in the user
# file needs this password: `xxj31ZMTZzkVA'.
# o ExportCertData:
# This exports two additional environment variables: SSL_CLIENT_CERT and
# SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
# server (always existing) and the client (only existing when client
# authentication is used). This can be used to import the certificates
# into CGI scripts.
# o StdEnvVars:
# This exports the standard SSL/TLS related `SSL_*' environment variables.
# Per default this exportation is switched off for performance reasons,
# because the extraction step is an expensive operation and is usually
# useless for serving static content. So one usually enables the
# exportation for CGI and SSI requests only.
# o OptRenegotiate:
# This enables optimized SSL connection renegotiation handling when SSL
# directives are used in per-directory context.
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
# SSL Protocol Adjustments:
# The safe and default but still SSL/TLS standard compliant shutdown
# approach is that mod_ssl sends the close notify alert but doesn't wait for
# the close notify alert from client. When you need a different shutdown
# approach you can use one of the following variables:
# o ssl-unclean-shutdown:
# This forces an unclean shutdown when the connection is closed, i.e. no
# SSL close notify alert is send or allowed to received. This violates
# the SSL/TLS standard but is needed for some brain-dead browsers. Use
# this when you receive I/O errors because of the standard approach where
# mod_ssl sends the close notify alert.
# o ssl-accurate-shutdown:
# This forces an accurate shutdown when the connection is closed, i.e. a
# SSL close notify alert is send and mod_ssl waits for the close notify
# alert of the client. This is 100% SSL/TLS standard compliant, but in
# practice often causes hanging connections with brain-dead browsers. Use
# this only for browsers where you know that their SSL implementation
# works correctly.
# Notice: Most problems of broken clients are also related to the HTTP
# keep-alive facility, so you usually additionally want to disable
# keep-alive for those clients, too. Use variable "nokeepalive" for this.
# Similarly, one has to force some clients to use HTTP/1.0 to workaround
# their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
# "force-response-1.0" for this.
# BrowserMatch "MSIE [2-6]" \
# nokeepalive ssl-unclean-shutdown \
# downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

View File

@@ -0,0 +1,23 @@
#<VirtualHost *:80>
# ServerName wordpress
# redirect permanent / https://192.168.0.34/wordpress
# DocumentRoot /var/www/wordpress
# <Directory /var/www/wordpress/>
# AllowOverride All
# </Directory>
#</VirtualHost>
<VirtualHost *:80>
ServerName wordpress
DocumentRoot /var/www/html/
<Directory /var/www/html/>
AllowOverride all
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.wordpress.log
CustomLog /var/log/apache2/access.wordpress.log combined
redirect permanent / https://192.168.0.34/
</VirtualHost>

View File

@@ -0,0 +1,98 @@
<?php
/**
* La configuration de base de votre installation WordPress.
*
* Ce fichier est utilisé par le script de création de wp-config.php pendant
* le processus dinstallation. Vous navez pas à utiliser le site web, vous
* pouvez simplement renommer ce fichier en « wp-config.php » et remplir les
* valeurs.
*
* Ce fichier contient les réglages de configuration suivants :
*
* Réglages MySQL
* Préfixe de table
* Clés secrètes
* Langue utilisée
* ABSPATH
*
* @link https://fr.wordpress.org/support/article/editing-wp-config-php/.
*
* @package WordPress
*/
// ** Réglages MySQL - Votre hébergeur doit vous fournir ces informations. ** //
/** Nom de la base de données de WordPress. */
define( 'DB_NAME', 'wordpress' );
/** Utilisateur de la base de données MySQL. */
define( 'DB_USER', 'wordpress_user' );
/** Mot de passe de la base de données MySQL. */
define( 'DB_PASSWORD', 'qdrhh45' );
/** Adresse de lhébergement MySQL. */
define( 'DB_HOST', 'localhost' );
/** Jeu de caractères à utiliser par la base de données lors de la création des tables. */
define( 'DB_CHARSET', 'utf8' );
/**
* Type de collation de la base de données.
* Ny touchez que si vous savez ce que vous faites.
*/
define( 'DB_COLLATE', '' );
/**#@+
* Clés uniques dauthentification et salage.
*
* Remplacez les valeurs par défaut par des phrases uniques !
* Vous pouvez générer des phrases aléatoires en utilisant
* {@link https://api.wordpress.org/secret-key/1.1/salt/ le service de clés secrètes de WordPress.org}.
* Vous pouvez modifier ces phrases à nimporte quel moment, afin dinvalider tous les cookies existants.
* Cela forcera également tous les utilisateurs à se reconnecter.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', 'mettez une phrase unique ici' );
define( 'SECURE_AUTH_KEY', 'mettez une phrase unique ici' );
define( 'LOGGED_IN_KEY', 'mettez une phrase unique ici' );
define( 'NONCE_KEY', 'mettez une phrase unique ici' );
define( 'AUTH_SALT', 'mettez une phrase unique ici' );
define( 'SECURE_AUTH_SALT', 'mettez une phrase unique ici' );
define( 'LOGGED_IN_SALT', 'mettez une phrase unique ici' );
define( 'NONCE_SALT', 'mettez une phrase unique ici' );
/**#@-*/
/**
* Préfixe de base de données pour les tables de WordPress.
*
* Vous pouvez installer plusieurs WordPress sur une seule base de données
* si vous leur donnez chacune un préfixe unique.
* Nutilisez que des chiffres, des lettres non-accentuées, et des caractères soulignés !
*/
$table_prefix = 'wp_';
/**
* Pour les développeurs : le mode déboguage de WordPress.
*
* En passant la valeur suivante à "true", vous activez laffichage des
* notifications derreurs pendant vos essais.
* Il est fortement recommandé que les développeurs dextensions et
* de thèmes se servent de WP_DEBUG dans leur environnement de
* développement.
*
* Pour plus dinformation sur les autres constantes qui peuvent être utilisées
* pour le déboguage, rendez-vous sur le Codex.
*
* @link https://fr.wordpress.org/support/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
/* Cest tout, ne touchez pas à ce qui suit ! Bonne publication. */
/** Chemin absolu vers le dossier de WordPress. */
if ( ! defined( 'ABSPATH' ) )
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
/** Réglage des variables de WordPress et de ses fichiers inclus. */
require_once( ABSPATH . 'wp-settings.php' );

View File

@@ -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

View File

@@ -0,0 +1,15 @@
#!/bin/bash
set -o errexit
set -o nounset
if [[ $# != 1 ]]; then
echo "usage : $0 <fichier>"
exit 1
fi
fich="$1"
while read ligne
do
echo "${ligne}"
done < "${fich}"
exit 0

View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -o errexit
set -o nounset
if [[ $# != 1 ]]; then
echo "usage : $0 <fichier>"
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

View File

@@ -0,0 +1,22 @@
#!/bin/bash
set -o errexit
set -o nounset
if [[ $# != 1 ]]; then
echo "usage : $0 <fichier>"
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

View File

@@ -0,0 +1,28 @@
#!/bin/bash
#set -o errexit
set -o nounset
if [[ $# != 1 ]]; then
echo "usage : $0 <fichier>"
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

View File

@@ -0,0 +1,31 @@
#!/bin/bash
#set -o errexit
set -o nounset
PATH=${PATH}:/usr/sbin
if [[ $# != 1 ]]; then
echo "usage : $0 <fichier>"
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

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,28 @@
#!/bin/bash
#set -o errexit
set -o nounset
if [ $# != 1 ]
then
echo "usage : $0 <fichier>"
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

View File

@@ -0,0 +1,4 @@
lucien
claudine
robert
marcelle

View File

@@ -0,0 +1,4 @@
lucien:Lucien Dubois
claudine:Claudine Duparc
robert:Robert Macaire
marcelle:Marcelle Desforets

View File

@@ -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