Almost done

This commit is contained in:
Iwan Clement
2020-06-13 17:01:31 +02:00
parent 60b4ec8f0a
commit 89ecf0ff97
3 changed files with 32 additions and 54 deletions

View File

@@ -1,9 +1,22 @@
#!/usr/bin/python3
import yaml
MG_URL="https://api.mailgun.net/v3/routes"
MG_APIKEY="api:key-6e4b01ba0681141a509c1c462fca40f4"
HEADER="curl -s --user "+MG_APIKEY+" -X PUT \""+MG_URL
#print (HEADER)
f = open('rules.yaml')
EXE = open('ModifyRules.sh','w')
dohicky = yaml.safe_load(f)
EXE.writelines("#!/bin/bash\n")
for i in dohicky:
print(i)
CHAINE=HEADER+"/"+i['id']+ "\" -F priority="+str(i['priority'])
if len(i['description'])>0:
CHAINE=CHAINE+ " -F description='"+str(i['description'])+"'"
CHAINE=CHAINE+ " -F expression='"+str(i['expression'])+"'"
for j in i['actions']:
CHAINE=CHAINE+ " -F action='"+str(j)+"'"
#print(CHAINE)
EXE.writelines(CHAINE+"\n")
#print(dohicky)
f.close()
f.close()
EXE.close()

View File

@@ -1,51 +1,17 @@
#!/bin/bash
# https://documentation.mailgun.com/en/latest/api-routes.html
MG_USER=
MG_URL="https://api.mailgun.net/v3/routes"
MG_APIKEY="api:key-6e4b01ba0681141a509c1c462fca40f4"
MG_ORDER="GET /routes"
declare -A MyRules
"5ce42a14bf802e0001684668,2,Tout ce qui arrive sur le domaine pour mg.iwanclement.eu,match_recipient(".*@mg.iade-lyon.eu")
5cd48c308b3cd70001f79bfb
5cd48b47a4764a00013cee72
5db1e61d11c830a64e8e2dba
5ce18c92629574000195c8de
5ca2330d6295740001322814
5c726e2f8b3cd70001237ee5
5c570e59bf802e00012989e9
5baa01368ecd8700013c5010
5b6d4d826295740001913849
5b6d4c278b3cd70001ebdfda
5c5499376295740001fe1e27
5c5343c345d85900018ceee6
5c5eb3376295740001546abf
5c534e78bf802e00013232e5
5bbe45dc6295740001b26ffd
5b9b758aa4764a000133bfbe
5bae76a745d8590001287978
5b8d79f98b3cd700019d5205
5b799e80a4764a000192cf3b
5c726e7e8ecd870001264998
5c726b408ecd870001264739
5c726b19bf802e000162d921
5c419a518b3cd70001c5ddea
5b8a5bcd8b3cd700017130ed
5ce18d97bf802e00019eaace
5ce18cf4a4764a0001d95b58
5baf5ac78b3cd70001ebae82
5b6cbd328b3cd70001eb4eb2
for i in "${MyRules[@]}"; do echo "$i"; done
for i in "${MyRules[*]}"; do echo "$i"; done
curl -s --user $MG_APIKEY -X PUT \
"$MG_URL/5ce18c92629574000195c8de" \
-F priority=2 \
-F description='Tout ce qui arrive sur le domaine pour mg.iwanclement.eu' \
-F expression='match_recipient(".*@mg.iade-lyon.eu")' \
-F action='forward("iwan.pubclement@gmx.fr")' \
-F action='forward("iwan.pubclement@mail.fr")' \
-F action='stop()'
exit 0

View File

@@ -1,10 +1,17 @@
---
- id: 5ce42a14bf802e0001684668
actions:
- store()
- forward("gwladys.clement@gmail.com")
- stop()
description: Suppression UDEMY
expression: match_recipient("iwan*.udemy@mg.*.space")
description: Tout pour Gwladys sur space
expression: match_recipient("gwladys.*@mg.*.space")
priority: 0
- id: 5c726e2f8b3cd70001237ee5
actions:
- forward("ophelie.clement@gmail.com")
- stop()
description: Tout pour Ophelie sur space
expression: match_recipient("ophelie.*@mg.*.space")
priority: 0
- id: 5cd48c308b3cd70001f79bfb
actions:
@@ -29,25 +36,18 @@
priority: 1
- id: 5ce18c92629574000195c8de
actions:
- forward("iwan.pubclement@gmx.fr")
- forward("nadineclement@mail.fr")
- stop()
description: Tout ce qui arrive sur le domaine pour mg.iwanclement.eu
description: Tout ce qui arrive sur le domaine pour mg.iade-lyon.eu
expression: match_recipient(".*@mg.iade-lyon.eu")
priority: 2
- id: 5ca2330d6295740001322814
actions:
- forward("iwan.pubclement@mail.fr, nadinepub.clement@free.fr")
- forward("iwan.pubclement@mail.fr, nadineclement@mail.fr")
- stop()
description: LIDL
expression: match_recipient("iwanpub.lidl@mg.*.space")
priority: 2
- id: 5c726e2f8b3cd70001237ee5
actions:
- forward("nadineclement@mail.fr")
- stop()
description: Tout pour Nadine Clement
expression: match_recipient(".*@mg.iade-lyon.eu")
priority: 2
- id: 5c570e59bf802e00012989e9
actions:
- forward("iwanpro.clement@free.fr")
@@ -197,10 +197,9 @@
priority: 8
- id: 5b6cbd328b3cd70001eb4eb2
actions:
- forward("iwan.pubclement@gmx.fr")
- forward("iwan.pubclement@mail.fr")
- stop()
description: On ramasse tout
expression: catch_all()
id:
priority: 10
...