Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5691bc4e42 | ||
|
cdf2c8db14 | ||
|
9c37b351ec | ||
|
a28bbb33b1 | ||
|
835ab8ab74 | ||
|
7cc40880fc | ||
80d8be6df5 | |||
|
6fbf265e6e | ||
|
f84127bcc7 |
10
sio2/sisr/35-script/bash/script/crsamba1
Executable file
10
sio2/sisr/35-script/bash/script/crsamba1
Executable 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
|
||||
|
15
sio2/sisr/35-script/bash/script/crsamba2
Executable file
15
sio2/sisr/35-script/bash/script/crsamba2
Executable 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
|
||||
|
||||
|
19
sio2/sisr/35-script/bash/script/crsamba3
Executable file
19
sio2/sisr/35-script/bash/script/crsamba3
Executable 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
|
||||
|
||||
|
22
sio2/sisr/35-script/bash/script/crsamba4
Executable file
22
sio2/sisr/35-script/bash/script/crsamba4
Executable 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
|
||||
|
||||
|
28
sio2/sisr/35-script/bash/script/crsamba5
Executable file
28
sio2/sisr/35-script/bash/script/crsamba5
Executable 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
|
||||
|
||||
|
31
sio2/sisr/35-script/bash/script/crsamba7
Executable file
31
sio2/sisr/35-script/bash/script/crsamba7
Executable 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
|
||||
|
||||
|
1
sio2/sisr/35-script/bash/script/fichier.pwd
Normal file
1
sio2/sisr/35-script/bash/script/fichier.pwd
Normal file
@@ -0,0 +1 @@
|
||||
|
17
sio2/sisr/35-script/bash/script/restoration
Executable file
17
sio2/sisr/35-script/bash/script/restoration
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
DAT=$(date "+%u")
|
||||
DEST=/home/sv/d/"${DAT}"
|
||||
HOST=root@192.168.0.29
|
||||
ssh "${HOST}" apt install -y rsync apache2 mariadb-server php
|
||||
ssh "${HOST}" "mysql CREATE DATABASES wordpress;" #a refaire
|
||||
ssh "${HOST}" "mysql -u wordpress_user -pqdrhh45 wordpress < "${DEST}"/wordpress.sql" #a refaire
|
||||
scp -r "${DEST}"/wordpress "${HOST}":/var/www/html/
|
||||
scp "${DEST}"/default-ssl.conf "${HOST}":/etc/apache2/sites-available/
|
||||
scp "${DEST}"/wordpress.conf "${HOST}":/etc/apache2/sites-available/
|
||||
scp "${DEST}"/server.key "${HOST}":/etc/apache2/
|
||||
scp "${DEST}"/server.crt "${HOST}":/etc/apache2/
|
||||
#rsync -az "${DEST}"/wordpress "${HOST}":/var/www/html/
|
||||
#rsync -az "${DEST}"/default-ssl.conf "${HOST}":/etc/apache2/sites-available/
|
||||
#rsync -az "${DEST}"/wordpress.conf "${HOST}":/etc/apache2/sites-available/
|
||||
#rsync -az "${DEST}"/server.key "${HOST}":/etc/apache2/
|
||||
#rsync -az "${DEST}"/server.crt "${HOST}":/etc/apache2/
|
28
sio2/sisr/35-script/bash/script/rmsamba
Executable file
28
sio2/sisr/35-script/bash/script/rmsamba
Executable 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
|
||||
|
||||
|
15
sio2/sisr/35-script/bash/script/sauv
Executable file
15
sio2/sisr/35-script/bash/script/sauv
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
DAT=$(date "+%u")
|
||||
DEST=/home/sv
|
||||
DEST2="${DEST}/d/${DAT}"
|
||||
[ -d "${DEST}/d" ] || mkdir -p "${DEST}/d"
|
||||
[ -d "${DEST}/d/${DAT}" ] || mkdir -p "${DEST}/d/${DAT}"
|
||||
HOST=sauv@192.168.0.34
|
||||
ssh "${HOST}" "mysqldump -u wordpress_user -pqdrhh45 wordpress|gzip -" >"${DEST2}"/wordpress.sql.gz
|
||||
|
||||
rsync -av -e ssh "${HOST}":/var/www/html/wordpress "${DEST2}"
|
||||
rsync -av -e ssh "${HOST}":/etc/apache2/sites-available/default-ssl.conf "${DEST2}"/default-ssl.conf
|
||||
rsync -av -e ssh "${HOST}":/etc/apache2/sites-available/wordpress.conf "${DEST2}"/wordpress.conf
|
||||
rsync -av -e ssh "${HOST}":/etc/apache2/server.key "${DEST2}"/server.key
|
||||
rsync -av -e ssh "${HOST}":/etc/apache2/server.crt "${DEST2}"/server.crt
|
||||
|
4
sio2/sisr/35-script/bash/script/user.txt
Normal file
4
sio2/sisr/35-script/bash/script/user.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
lucien
|
||||
claudine
|
||||
robert
|
||||
marcelle
|
4
sio2/sisr/35-script/bash/script/user2.txt
Normal file
4
sio2/sisr/35-script/bash/script/user2.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
lucien:Lucien Dubois
|
||||
claudine:Claudine Duparc
|
||||
robert:Robert Macaire
|
||||
marcelle:Marcelle Desforets
|
26
sio2/sisr/35-script/bash/script/user2.txt.pwd
Normal file
26
sio2/sisr/35-script/bash/script/user2.txt.pwd
Normal 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
|
19
sio2/sisr/35-script/python/log.py
Normal file
19
sio2/sisr/35-script/python/log.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#/usr/bin/python3
|
||||
import re
|
||||
import sys
|
||||
group = {}
|
||||
regexp = '^(\S+) (\S+) (\S+) \[([^]]+)\] "(\w+) (\S+).*" (\d+) (\S+)'
|
||||
for line in sys.stdin:
|
||||
line = line.rstrip ( )
|
||||
match = re.match (regexp, line)
|
||||
if match:
|
||||
print (match.group(1)," ",match.group(8))
|
||||
ip = match.group(1)
|
||||
vol = match.group(8)
|
||||
if ip in group:
|
||||
group[ip] = group[ip] + vol
|
||||
else:
|
||||
group[ip] = vol
|
||||
for key in group.keys():
|
||||
print (key, " ", group[key])
|
||||
|
38
sio2/sisr/35-script/python/passusr.py
Normal file
38
sio2/sisr/35-script/python/passusr.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/python3
|
||||
import sys
|
||||
import subprocess
|
||||
import os
|
||||
nbarg = len(sys.argv)
|
||||
if nbarg != 2:
|
||||
print ("Nombre d'argument invalide")
|
||||
exit (1)
|
||||
filename = sys.argv[1]
|
||||
try:
|
||||
fh = open(filename, "r")
|
||||
except:
|
||||
print ("Fichier ", filename," inconnu")
|
||||
exit (2)
|
||||
else:
|
||||
line = fh.readline ()
|
||||
while line:
|
||||
nouvline = line.rstrip()
|
||||
login,nomlong = nouvline.split(':')
|
||||
cmd = "sudo useradd -m -d /home/"+login+" -c \'"+ nomlong+"\' -s /bin/bash "+ login
|
||||
res = os.system ("getent passwd "+login)
|
||||
if res != 0:
|
||||
passw = ["pwgen", "4","1"]
|
||||
os.system (cmd)
|
||||
mdp = subprocess.run(passw,capture_output=True)
|
||||
mdp2 = mdp.stdout.decode("utf-8")
|
||||
mdp3 = mdp2.rstrip()
|
||||
print (mdp3)
|
||||
ch3 = "echo "+login+":"+mdp3+"|sudo chpasswd"
|
||||
print (ch3)
|
||||
os.system (ch3)
|
||||
os.system ("sudo echo "+login+":"+mdp3+" >> "+filename+".pwd")
|
||||
else:
|
||||
print ("Utilisateur "+login+" déjà éxistant")
|
||||
os.system ("sudo userdel -r "+login)
|
||||
line = fh.readline()
|
||||
|
||||
fh.close()
|
2
sio2/sisr/35-script/python/user.txt
Normal file
2
sio2/sisr/35-script/python/user.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
adupont:Albert Dupont
|
||||
jduroy:Jeannette Duroy
|
4
sio2/sisr/35-script/python/user.txt.pwd
Normal file
4
sio2/sisr/35-script/python/user.txt.pwd
Normal file
@@ -0,0 +1,4 @@
|
||||
adupont:0PSg
|
||||
jduroy:2Sdc
|
||||
adupont:Ksw4
|
||||
jduroy:C0px
|
23
sio2/sisr/40-vlan/ipsec.conf
Normal file
23
sio2/sisr/40-vlan/ipsec.conf
Normal file
@@ -0,0 +1,23 @@
|
||||
config setup
|
||||
charondebug="all"
|
||||
uniqueids=yes
|
||||
strictcrlpolicy=no
|
||||
conn %default
|
||||
conn tunnel #
|
||||
left=10.0.0.2
|
||||
leftsubnet=192.168.2.0/24
|
||||
right=10.0.0.1
|
||||
rightsubnet=192.168.1.0/24
|
||||
ike=aes256-sha2_256-modp1024!
|
||||
esp=aes256-sha2_256!
|
||||
keyingtries=0
|
||||
ikelifetime=1h
|
||||
lifetime=8h
|
||||
dpddelay=30
|
||||
dpdtimeout=120
|
||||
dpdaction=restart
|
||||
authby=secret
|
||||
auto=start
|
||||
keyexchange=ikev2
|
||||
type=tunnel
|
||||
|
5
sio2/sisr/40-vlan/ipsec.secrets
Normal file
5
sio2/sisr/40-vlan/ipsec.secrets
Normal file
@@ -0,0 +1,5 @@
|
||||
# This file holds shared secrets or RSA private keys for authentication.
|
||||
|
||||
# RSA private key for this host, authenticating it to any other host
|
||||
# which knows the public part.
|
||||
10.0.0.2 10.0.0.1 : PSK 'root'
|
Reference in New Issue
Block a user