Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!pyobjects
- """
- http://ait.web.psi.ch/services/central_backup/nsr_install_lnx.html
- """
- LEGATO_LOCAL_CONF="/root/nsradmin76_x.txt"
- with Pkg.installed("Legato RPMs", pkgs=[ "lgtoclnt", "lgtoman" ]):
- Service.running("networker", enable=True )
- import os
- if not os.path.isfile( LEGATO_LOCAL_CONF + '.salt.done' ):
- # We never configured Legato before, we have to configure it
- assert os.path.isfile("/usr/sbin/nsradmin")
- import socket
- FQDN , aliaslist, lan_ip = socket.gethostbyname_ex(socket.gethostname())
- if "." not in FQDN:
- from dns import reversename, resolver
- rev_name = reversename.from_address( lan_ip[0] )
- reversed_dns = str(resolver.query(rev_name,"PTR")[0])
- FQDN = reversed_dns[:-1] # t3ui.psi.ch
- LEGATO_LOCAL_CONF_CONTENT = """. type: NSRLA
- update administrator:"isroot,host=""" + FQDN + """","isroot,host=localhost","user=root,host=localhost","user=administrator,host=bs1","user=admin7,host=bs1","user=admin2,host=bs1"
- . type: NSR System Port Ranges
- update administrator:"isroot,host=""" + FQDN + """","isroot,host=localhost","user=root,host=localhost","user=administrator,host=bs1","user=admin7,host=bs1","user=admin2,host=bs1"
- """
- with os.fdopen( os.open( LEGATO_LOCAL_CONF, os.O_WRONLY | os.O_CREAT, 0600), 'w') as LEGATO_LOCAL_CONF_FILE :
- LEGATO_LOCAL_CONF_FILE.write( LEGATO_LOCAL_CONF_CONTENT )
- Cmd.run("service networker stop" , shell='/bin/bash')
- Cmd.run("service networker start", shell='/bin/bash')
- with open( "/nsr/res/servers" , 'w' ) as file:
- file.write("bs1.psi.ch\n")
- Cmd.run("service networker stop" , shell='/bin/bash')
- Cmd.run("service networker start", shell='/bin/bash')
- Cmd.run("/usr/sbin/nsradmin -i " + LEGATO_LOCAL_CONF + " -p nsrexec ", shell='/bin/bash' )
- Cmd.run("""
- /usr/sbin/nsradmin -p nsrexec << EOF
- . type:NSR System Port Ranges
- update service ports:7937-7940
- yes
- update connection ports:10000-11000
- yes
- EOF""", shell='/bin/bash' )
- Cmd.run("service networker stop" , shell='/bin/bash')
- Cmd.run("service networker start", shell='/bin/bash')
- # a timestamp inside /root/nsradmin76_x.txt.salt.done
- import time
- open( LEGATO_LOCAL_CONF + '.salt.done', 'w' ).write( time.strftime("%d-%m-%Y - %H:%M:%S") + "\n" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement