updated maildb state

This commit is contained in:
Paul 2021-11-27 13:25:29 +01:00
parent e457e62182
commit de7b753440
4 changed files with 2 additions and 32 deletions

View File

@ -2,7 +2,6 @@
maildb: maildb:
enabled: true enabled: true
appdir: /usr/local/apps/maildb appdir: /usr/local/apps/maildb
datadir: /usr/local/data/maildb
configfile: /usr/local/apps/maildb/maildb.cfg configfile: /usr/local/apps/maildb/maildb.cfg
config: config:
file: /usr/local/apps/maildb/maildb.ini file: /usr/local/apps/maildb/maildb.ini

View File

@ -4,7 +4,6 @@ maildb-pkg:
pkg.latest: pkg.latest:
- pkgs: - pkgs:
- python3 - python3
- python3-mysqldb
- python3-psycopg2 - python3-psycopg2
maildb-user-vmail: maildb-user-vmail:
@ -20,14 +19,6 @@ maildb-apps-dir:
- mode: 0755 - mode: 0755
- makedirs: true - makedirs: true
maildb-data-dir:
file.directory:
- name: {{ maildb.datadir }}
- user: vmail
- group: vmail
- mode: 0755
- makedirs: true
maildb-script: maildb-script:
file.managed: file.managed:
- name: {{ maildb.appdir }}/maildb.py - name: {{ maildb.appdir }}/maildb.py
@ -38,15 +29,3 @@ maildb-script:
- require: - require:
- file: maildb-apps-dir - file: maildb-apps-dir
- file: maildb-data-dir - file: maildb-data-dir
maildb-config:
file.managed:
- name: {{ maildb.appdir }}/maildb.ini
- source: salt://maildb/maildb.ini.j2
- user: vmail
- group: vmail
- mode: 0755
- template: jinja
- require:
- file: maildb-apps-dir
- file: maildb-data-dir

View File

@ -1,6 +0,0 @@
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
{%- from "maildb/map.jinja" import maildb with context %}
[maildb]
{%- for param, value in maildb.db.items() %}
{{ param }}={{ value }}
{%- endfor %}

View File

@ -5,7 +5,6 @@ import sys
import configparser import configparser
from email.utils import parseaddr from email.utils import parseaddr
import email import email
#import MySQLdb
import psycopg2 import psycopg2
@ -23,10 +22,9 @@ def DBConfig(configfile):
return d_dbconfig return d_dbconfig
def ConnectMysqlDB(dbconfig): def ConnectDB(dbconfig):
connstr = f"host={dbconfig['host']} dbname={dbconfig['db']} user={dbconfig['user']} password={dbconfig['passwd']}" connstr = f"host={dbconfig['host']} dbname={dbconfig['db']} user={dbconfig['user']} password={dbconfig['passwd']}"
conn = psycopg2.connect(connstr) conn = psycopg2.connect(connstr)
#conn = MySQLdb.connect(**dbconfig)
return conn, conn.cursor() return conn, conn.cursor()
@ -85,7 +83,7 @@ def main():
recipient = maildata[1] recipient = maildata[1]
mailcontent = maildata[2] mailcontent = maildata[2]
conn, cursor = ConnectMysqlDB(d_dbconfig) conn, cursor = ConnectDB(d_dbconfig)
CreateDB(conn, cursor) CreateDB(conn, cursor)
InsertMail(conn, cursor, sender, recipient, mailcontent) InsertMail(conn, cursor, sender, recipient, mailcontent)