@@ -110,6 +110,10 @@ def printError(msg):
110110 sys .stderr .write ("\n " )
111111 sys .stderr .flush ()
112112
113+ def printMsg (msg ):
114+ sys .stdout .write (msg + "\n " )
115+ sys .stdout .flush ()
116+
113117def checkRpm (pkgName ):
114118 chkPkg = bash ("rpm -q %s" % pkgName )
115119 writeProgressBar ("Checking %s" % pkgName , None )
@@ -154,10 +158,17 @@ def bashWithResult(cmd):
154158def configurePxeStuff ():
155159 stuff = ['tftp' , 'xinetd' , 'dhcpd' ]
156160 cmds = ['chkconfig --level 345 %s on' % i for i in stuff ]
157- cmds .append ('service xinetd restart' )
161+ cmds .append ('/etc/init.d/ xinetd restart' )
158162
159163 for cmd in cmds :
160164 if not bashWithResult (cmd ): return False
165+
166+ chkIptable = bash ('chkconfig --list iptables' )
167+ if 'on' in chkIptable .getStdout ():
168+ printMsg ("Detected iptables is running, need to open tftp port 69" )
169+ if not bashWithResult ('iptables -I INPUT 1 -p udp --dport 69 -j ACCEPT' ): return False
170+ if not bashWithResult ('/etc/init.d/iptables save' ): return False
171+
161172 return True
162173
163174def getTftpRootDir (tftpRootDirList ):
@@ -200,10 +211,8 @@ if __name__ == "__main__":
200211
201212 tftpRootDir = tftpRootDirList [0 ].strip ()
202213 exitIfFail (preparePING (tftpRootDir ))
203- print ""
204- writeProgressBar ("Setup BareMetal PXE server successfully" )
205- print ""
206- writeProgressBar ("TFTP root directory is: %s\n " % tftpRootDir )
207- print ""
214+ printMsg ("" )
215+ printMsg ("Setup BareMetal PXE server successfully" )
216+ printMsg ("TFTP root directory is: %s\n " % tftpRootDir )
208217 sys .exit (0 )
209218
0 commit comments