Forward pour l'intranet (executé en tant que root par www-data)
This commit is contained in:
parent
96a8ceca8d
commit
1262b47fb3
1 changed files with 30 additions and 0 deletions
30
utils/forward.py
Executable file
30
utils/forward.py
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash /usr/scripts/python.sh
|
||||||
|
# -*- coding: utf8 -*-
|
||||||
|
# Script utilisé par l'intranet et autres pour ecrire le .forward dans le home
|
||||||
|
# Executé avec un sudo
|
||||||
|
# detraz@crans.org
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def getforward(user):
|
||||||
|
try:
|
||||||
|
mailredirect = open('/home/%s/.forward'%user).readlines()[0]
|
||||||
|
except IOError:
|
||||||
|
mailredirect = "Inconnu"
|
||||||
|
print mailredirect
|
||||||
|
return
|
||||||
|
|
||||||
|
def writeforward(user,txt):
|
||||||
|
open('/home/%s/.forward'%user,'w').write(txt)
|
||||||
|
return
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
for arg in sys.argv:
|
||||||
|
if "--name" in arg:
|
||||||
|
name=arg.split("=")[1]
|
||||||
|
if "--mail" in arg:
|
||||||
|
mail=arg.split("=")[1]
|
||||||
|
if "--read" in sys.argv:
|
||||||
|
getforward(name)
|
||||||
|
elif "--write" in sys.argv:
|
||||||
|
writeforward(name,mail)
|
Loading…
Add table
Add a link
Reference in a new issue