#!/usr/bin/python3.5 # -*- coding: utf-8 -*- """ Created on Wed Jun 29 19:34:29 2016 @author: Richard Wegers """ import os smb_conf= ( "[global]", "workgroup = training", "netbios name = tsam-fs01", "server string = Training CIFS Server", "server role = standalone server", "[Public]", "path = /srv/samba/Public/", "comment = Dataiablage", "browseable = yes", "writeable = yes", "guest ok = yes" ) # Hilfsfunktion, um Texte an eine Datei anzuhängen # file: Pfad der Datei # in_string: Inhalt, der angehängt werden soll als Dictionary def write2file(file, in_string, mode): mytxt="" with open(file, mode) as myfile: for i in in_string: mytxt=mytxt + str(i) +"\n" print(mytxt, file=myfile) os.system ("sudo -s") os.system ("apt-get install -y samba winbind libnss-winbind smbclient heimdal-clients ldb-tools") # winbind zum Beitreten einer Domain # libnss User Authorisierung # smbclient SMB-Client für Freigaben # heimdal Kerberos Implementierung os.system ("mkdir -p /srv/samba/Public") os.system ("chmod 1777 /srv/samba/Public") os.system ("mv /etc/samba/smb.conf /etc/samba/smb.conf.org") write2file ("/etc/samba/smb.conf", "smb_conf", "w") os.system ("testparm /etc/samba/smb.conf") os.system ("systemctl restart samba-ad-dc smbd nmbd winbind") os.system ("systemctl status samba-ad-dc smbd nmbd winbind")