Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
62052834f9 | |||
6a287b8ee7 | |||
20f4f4f183 | |||
bef3ed97e7 |
39
Sio2/SISR/30-python/creatusr2.py
Executable file
39
Sio2/SISR/30-python/creatusr2.py
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
#print "Nom du programme : ", sys.argv[0]
|
||||||
|
#print "Nombre d'arguments: ", len(sys.argv)
|
||||||
|
#print "Les arguments sont : " , str(sys.argv)
|
||||||
|
|
||||||
|
if len(sys.argv) !=2:
|
||||||
|
msg = "Usage : " + sys.argv[0] + " <fichier.txt>"
|
||||||
|
print (msg, file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
file = open(filename , "r")
|
||||||
|
|
||||||
|
except:
|
||||||
|
msg = "Erreur ouverture fichier " + filename
|
||||||
|
print (msg ,file=sys.stderr)
|
||||||
|
|
||||||
|
else:
|
||||||
|
line = file.readline ()
|
||||||
|
maligne = line.rstrip()
|
||||||
|
|
||||||
|
while maligne:
|
||||||
|
(login, complet) = maligne.split(":")
|
||||||
|
print (login)
|
||||||
|
print (complet)
|
||||||
|
commande = "useradd --create-home --home-dir /home"+ login + " --shell /bin/bash --comment \"" + complet + "\" " + login
|
||||||
|
print (commande)
|
||||||
|
print (" ")
|
||||||
|
line = file.readline()
|
||||||
|
maligne = line.rstrip()
|
||||||
|
#print (line)
|
||||||
|
file.close()
|
||||||
|
|
41
Sio2/SISR/30-python/creatusr3.py
Executable file
41
Sio2/SISR/30-python/creatusr3.py
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
#print "Nom du programme : ", sys.argv[0]
|
||||||
|
#print "Nombre d'arguments: ", len(sys.argv)
|
||||||
|
#print "Les arguments sont : " , str(sys.argv)
|
||||||
|
|
||||||
|
if len(sys.argv) !=2:
|
||||||
|
msg = "Usage : " + sys.argv[0] + " <fichier.txt>"
|
||||||
|
print (msg, file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
file = open(filename , "r")
|
||||||
|
|
||||||
|
except:
|
||||||
|
msg = "Erreur ouverture fichier " + filename
|
||||||
|
print (msg ,file=sys.stderr)
|
||||||
|
|
||||||
|
else:
|
||||||
|
line = file.readline ()
|
||||||
|
maligne = line.rstrip()
|
||||||
|
|
||||||
|
while maligne:
|
||||||
|
(login, complet) = maligne.split(":")
|
||||||
|
print (login)
|
||||||
|
print (complet)
|
||||||
|
cmd = ('getent passwd', login)
|
||||||
|
res=subprocess.run(cmd.split(),stdout=subprocess.PIPE)
|
||||||
|
commande = "useradd --create-home --home-dir /home"+ login + " --shell /bin/bash --comment \"" + complet + "\" " + login
|
||||||
|
print (commande)
|
||||||
|
print (" ")
|
||||||
|
line = file.readline()
|
||||||
|
maligne = line.rstrip()
|
||||||
|
#print (line)
|
||||||
|
file.close()
|
||||||
|
|
44
Sio2/SISR/30-python/creatusr4.py
Normal file
44
Sio2/SISR/30-python/creatusr4.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# ne marche pas
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import pwd
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
#print ("Nom du programme : ", sys.argv[0])
|
||||||
|
#print ("Nombre d'arguments: ", len(sys.argv))
|
||||||
|
#print ("Les arguments sont : " , str(sys.argv))
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
msg= ("Usage : " + sys.argv[0] + " <fichier.txt>")
|
||||||
|
print(msg ,file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
filename = sys.argv[1]
|
||||||
|
try:
|
||||||
|
file= open(filename , "r")
|
||||||
|
except:
|
||||||
|
msg = ("Erreur ouverture fichier " + filename)
|
||||||
|
print(msg ,file=sys.stderr)
|
||||||
|
|
||||||
|
else:
|
||||||
|
line = file.readline()
|
||||||
|
linee = line.rstrip()
|
||||||
|
while linee:
|
||||||
|
(login, complet) = linee.split(":")
|
||||||
|
|
||||||
|
cmd="getent passwd " + login
|
||||||
|
res= subprocess.run(cmd.split(),stdout=subprocess.PIPE)
|
||||||
|
res2= (res.stdout.decode("utf8"))
|
||||||
|
if not res2 :
|
||||||
|
commande = "useradd --create-home --home-dir /home/"+ login + " --shell /bin/bash --comment \"" + complet + "\" " + login
|
||||||
|
res3= os.system(commande)
|
||||||
|
|
||||||
|
else :
|
||||||
|
print("Utilisateur " + login + " existant" )
|
||||||
|
|
||||||
|
|
||||||
|
line = file.readline()
|
||||||
|
linee = line.rstrip()
|
||||||
|
file.close()
|
28
Sio2/SISR/30-python/log.py
Executable file
28
Sio2/SISR/30-python/log.py
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
volip = {}
|
||||||
|
cpthit = {}
|
||||||
|
regexp = "^(\S+) (\S+) (\S+) \[([^]]+)\] \"(\w+) (\S+).*\" (\d+) (\S+)"
|
||||||
|
|
||||||
|
for line in sys.stdin: # on lit sur l’entrée standard
|
||||||
|
line = line.rstrip () # on enleve le retour ligne
|
||||||
|
res = re.match (regexp, line)
|
||||||
|
if res:
|
||||||
|
(host, rfc931, user, date, request, url, status, byte) = res.groups()
|
||||||
|
host = res.group (1)
|
||||||
|
byte = int(res.group (8))
|
||||||
|
#print ('host : ', host, ' byte : ', byte)
|
||||||
|
if host not in volip:
|
||||||
|
volip[host] = byte
|
||||||
|
cpthit[host] = 1
|
||||||
|
else:
|
||||||
|
volip[host] = volip[host] + byte
|
||||||
|
cpthit[host] = cpthit[host] + 1
|
||||||
|
|
||||||
|
for addr in sorted(volip.keys()):
|
||||||
|
print ("VOLUME : ", addr, " : ", volip[addr],";;; HIT : ", cpthit[addr])
|
||||||
|
|
||||||
|
#for hit in sorted(cpthit.keys()):
|
||||||
|
# print (hit, " : ", cpthit[hit])
|
1816
Sio2/SISR/30-python/resul.txt
Normal file
1816
Sio2/SISR/30-python/resul.txt
Normal file
File diff suppressed because it is too large
Load Diff
4
Sio2/SISR/30-python/user.txt
Normal file
4
Sio2/SISR/30-python/user.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
lucien:Lucien Dubois
|
||||||
|
claudine:Claudine Dupont
|
||||||
|
robert:Robert Dupond
|
||||||
|
anthony:Anthony Arnoux
|
6
Sio2/SISR/40-ansible/hosts
Normal file
6
Sio2/SISR/40-ansible/hosts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[adm]
|
||||||
|
infra
|
||||||
|
|
||||||
|
[web]
|
||||||
|
web1
|
||||||
|
web2
|
1
Sio2/SISR/40-ansible/index.html
Normal file
1
Sio2/SISR/40-ansible/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
coucou les loulous
|
24
Sio2/SISR/40-ansible/rsyslog.yml
Normal file
24
Sio2/SISR/40-ansible/rsyslog.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- hosts: infra
|
||||||
|
tasks:
|
||||||
|
- name: decommente le chargement du module imudp dans rsyslog.conf
|
||||||
|
replace:
|
||||||
|
path: /etc/rsyslog.conf
|
||||||
|
regexp: '^#module\(load="imudp"\)'
|
||||||
|
replace: 'module(load="imudp")'
|
||||||
|
backup: true
|
||||||
|
notify: Restart Rsyslog
|
||||||
|
|
||||||
|
- name: decommente le chargement du module imudp dans rsyslog.conf
|
||||||
|
replace:
|
||||||
|
path: /etc/rsyslog.conf
|
||||||
|
regexp: '^#input\(type="imudp" port="514"\)'
|
||||||
|
replace: 'input(type="imudp" port="514")'
|
||||||
|
backup: true
|
||||||
|
notify: Restart Rsyslog
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: Restart Rsyslog
|
||||||
|
service:
|
||||||
|
name: rsyslog
|
||||||
|
state: restarted
|
23
Sio2/SISR/40-ansible/web.yml
Normal file
23
Sio2/SISR/40-ansible/web.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: 1. installe Apache
|
||||||
|
apt:
|
||||||
|
name: apache2
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: 2. installe PHP pour Apache
|
||||||
|
apt:
|
||||||
|
name: php
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: 3. installe php-mbstring
|
||||||
|
apt:
|
||||||
|
name: php-mbstring
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: 4. installe index.html
|
||||||
|
copy:
|
||||||
|
src: index.html
|
||||||
|
dest: /var/www/html/index.html
|
||||||
|
mode: 0664
|
Reference in New Issue
Block a user