sambadomain = domainname.split('.')[0].upper()
print('Samba domain: ' + sambadomain)
setup.set('setup', 'sambadomain', sambadomain)
"""

# servername
ititle = title + ': Servername'
while True:
    rc, servername = dialog.inputbox('Enter the hostname of the main server:',
                                     title=ititle,
                                     height=16,
                                     width=64,
                                     init=setup.get('setup', 'servername'))
    if rc == 'cancel':
        sys.exit(1)
    if isValidHostname(servername):
        break

print('Server hostname: ' + servername)
setup.set('setup', 'servername', servername)
setup.set('setup', 'hostname', servername)
netbiosname = servername.upper()
print('Netbios name: ' + netbiosname)
setup.set('setup', 'netbiosname', netbiosname)

# domainname
ititle = title + ': Domainname'
while True:
    rc, domainname = dialog.inputbox(
        'Note that the first part of the domain name is used automatically as samba domain (maximal 15 characters using a-z and "-"). Use a prepending "linuxmuster" if your domain has more characters. Enter the internet domain name:',
        title=ititle,
Example #2
0
# realm
setup.set('setup', 'realm', domainname.upper())
# sambadomain
setup.set('setup', 'sambadomain', domainname.split('.')[0].upper())
# basedn
basedn = ''
for item in domainname.split('.'):
    basedn = basedn + 'DC=' + item + ','
setup.set('setup', 'basedn', basedn[:-1])

# servername
msg = '* Servername '
printScript(msg, '', False, False, True)
try:
    servername = setup.get('setup', 'hostname')
    if not isValidHostname(servername):
        printScript(' ' + servername + ' is not valid!', '', True, True, False, len(msg))
        sys.exit(1)
    printScript(' ' + servername, '', True, True, False, len(msg))
except:
    printScript(' not set!', '', True, True, False, len(msg))
    sys.exit(1)
setup.set('setup', 'servername', servername)

# derive values from servername
# netbiosname
setup.set('setup', 'netbiosname', servername.upper())

# serverip
msg = '* Server-IP '
printScript(msg, '', False, False, True)
Example #3
0
from functions import isValidHostIpv4
from functions import sambaTool

cmd = ''
ip = ''
hostname = ''

# get arguments
cmd, ip, hostname = sys.argv[1:]

# check arguments
if cmd not in ['add', 'delete']:
    sys.exit(1)
if not isValidHostIpv4(ip):
    sys.exit(1)
if not isValidHostname(hostname):
    sys.exit(1)

# no action for pxclient
if hostname.lower() == 'pxeclient':
    sys.exit(0)

# check if it is a dynamic ip device
if not isDynamicIpDevice(hostname):
    sys.exit(0)

# test if there are already valid dns records for this host
try:
    ip_resolved = socket.gethostbyname(hostname)
except:
    ip_resolved = ''
Example #4
0
if basedn == '' or basedn == None:
    try:
        for i in domainname.split('.'):
            basedn = basedn + 'DC=' + i + ','
        setup.set('setup', 'basedn', basedn[:-1])
    except:
        printScript(' failed to set!', '', True, True, False, len(msg))
        sys.exit(1)
printScript(' ' + basedn, '', True, True, False, len(msg))

# servername
msg = '* Servername '
printScript(msg, '', False, False, True)
try:
    servername = setup.get('setup', 'servername')
    if not isValidHostname(servername):
        printScript(' ' + servername + ' is not valid!', '', True, True, False, len(msg))
        sys.exit(1)
    printScript(' ' + servername, '', True, True, False, len(msg))
except:
    printScript(' not set!', '', True, True, False, len(msg))
    sys.exit(1)

# samba netbios name
msg = '* netbiosname '
printScript(msg, '', False, False, True)
try:
    netbiosname = setup.get('setup', 'netbiosname')
except:
    netbiosname = ''
if not isValidHostname(netbiosname):