# get our IP and Ports try: host = socket.gethostbyname(socket.gethostname()) log.l.LogIt('RS0004', 'I', 'IP: %s', (host)) except socket.error, why: log.l.LogIt('RS0005', 'F', 'hostname: %s', (str(why))) print "hostname:", why sys.exit(1) srvport = socket.getservbyname('aprsrv', 'tcp') cmdport = socket.getservbyname('aprcmd', 'tcp') log.l.LogIt('RS0006', 'I', 'server on port %s ...', (srvport)) log.l.LogIt('RS0007', 'I', 'command on port %s ...', (cmdport)) #------------------------------------------------ srvgl.cmd_ip = cmdiptbl.read() for i in srvgl.cmd_ip: log.l.LogIt('RS0008', 'I', 'cmd ip %s', (i)) #------------------------------------------------ if len(sys.argv) == 1: pid = os.fork() if pid: sys.exit(0) #------------------------------------------------ # check for new bnmgetconf command and/or DAS mode def poll(): sys.stdout.flush() #---------------------------
log.l = log.PathFmtLogFile(progname, 'n', routercfg.Keep, routercfg.MaxSize, routercfg.MaxAge, routercfg.TraceLevel) log.l.LogIt('CTL001', 'I', 'start %s', (ver.getVersion())) #------------------------------------------------ # Handle signals def sig_end(signum, frame): log.l.LogIt('CTL002', 'I', 'signal %d termination', (signum)) sys.exit(1) signal.signal(signal.SIGINT, sig_end) signal.signal(signal.SIGTERM, sig_end) signal.signal(signal.SIGHUP, signal.SIG_IGN) #------------------------------------------------ cmd_ip = cmdiptbl.read() name = os.uname()[1] cmdobj = None poweroff = 0 reboot = 0 #------------------------------------------------ "Get information from /sbin/ifconfig" hwaddr = '' interface = '' inetaddr = '' hw_l = '' in_l = '' try: