From 47bc28d554b0c474b06cdd291d6e7b8c942af359 Mon Sep 17 00:00:00 2001
From: Jan Ulrich Hasecke <jan.ulrich@hasecke.com>
Date: Thu, 21 Nov 2019 13:57:41 +0100
Subject: [PATCH] Skript läuft, Parameter für Paket, Domain, Projekt-ID und Einbindung von pass

---
 source/referenz/hsadmin/createall.py |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/source/referenz/hsadmin/createall.py b/source/referenz/hsadmin/createall.py
index 55a6ac4..5ae6e60 100644
--- a/source/referenz/hsadmin/createall.py
+++ b/source/referenz/hsadmin/createall.py
@@ -2,11 +2,18 @@
 import string
 import sys
 from hs.admin.api import API
+from subprocess import check_output
+
+paketadmin = sys.argv[1]
+domainname = sys.argv[2]
+projektid = sys.argv[3]
+
+pw = check_output(["pass", "hostsharing/"+paketadmin]).decode("utf-8").strip("\n")
 
 api = API(cas=dict(
     uri='https://login.hostsharing.net/cas/v1/tickets',
     service='https://config.hostsharing.net:443/hsar/backend'),
-    credentials=dict(username='xyz00', password='Y2kbZb)d*GQF%q1~m?7d8,]+'),
+    credentials=dict(username=paketadmin, password=pw),
     backends=[
         'https://config.hostsharing.net:443/hsar/xmlrpc/hsadmin',
         'https://config2.hostsharing.net:443/hsar/xmlrpc/hsadmin'])
@@ -19,16 +26,16 @@
 
 pw_dadmin = pwGen()
 pw_dbuser = pwGen()
+dadmin = paketadmin+'-'+domainname.replace("-", "_")
+dbuser = paketadmin+'_'+projektid
+dbname = paketadmin+'_'+projektid
 
-domainname = sys.argv[1]
-dbname = domainname.replace(".", "_")
-
-api.user.add(set={'name': 'xyz00-'+domainname, 'password': pw_dadmin, 'shell': '/bin/bash'})
-api.domain.add(set={'name': domainname, 'user': 'xyz00-'+domainname})
-api.mysqluser.add(set={'name': 'xyz00_'+dbname, 'password': pw_dbuser})
-api.mysqldb.add(set={'name': 'xyz00_'+dbname, 'owner': 'xyz00_'+dbname})
+api.user.add(set={'name': dadmin, 'password': pw_dadmin, 'shell': '/bin/bash'})
+api.domain.add(set={'name': domainname, 'user': dadmin})
+api.mysqluser.add(set={'name': dbuser, 'password': pw_dbuser})
+api.mysqldb.add(set={'name': dbname, 'owner': dbuser})
 
 print("Domainname:" +domainname)
-print("Domain-Admin: xyz00-"+domainname + "Passwort:" +pw_dadmin)
-print("Datenbank-Nutzer: " +dbname + "Passwort:" +pw_dbuser)
-print("Datenbank: " +dbname)
\ No newline at end of file
+print("Domain-Admin: " + dadmin + " mit dem Passwort:" +pw_dadmin)
+print("Datenbank-Nutzer: " +dbuser + " Passwort:" +pw_dbuser)
+print("Datenbankname: " +dbname)
\ No newline at end of file

--
Gitblit v1.9.0-SNAPSHOT