methods/in_common.rb
# Check tftpd config for Linux(turn on in xinetd config file /etc/xinetd.d/tftp)
Check tftpd config for Linux(turn on in xinetd config file /etc/xinetd.d/tftp)
Check tftpd config for Linux ( turn on in xinetd config file / etc / xinetd . d / tftp )
def check_tftpd_config(options)
  if options['host-os-name'].to_s.match(/Linux/)
    tmp_file   = "/tmp/tftp"
    pxelinux_file = "/usr/lib/PXELINUX/pxelinux.0"
    if !File.exist?(pxelinux_file)
      options = install_package(options,"pxelinux")
      options = install_package(options,"syslinux")
    end
    syslinux_file = "/usr/lib/syslinux/modules/bios/ldlinux.c32"
    pxelinux_dir  = options['tftpdir']
    pxelinux_tftp = pxelinux_dir+"/pxelinux.0"
    syslinux_tftp = pxelinux_dir+"/ldlinux.c32"
    if options['verbose'] == true
      handle_output(options,"Information:\tChecking PXE directory")
    end
    check_dir_exists(options,pxelinux_dir)
    check_dir_owner(options,pxelinux_dir,options['uid'])
    if !File.exist?(pxelinux_tftp)
      if !File.exist?(pxelinux_file)
        options = install_package(options,"pxelinux")
      end
      if File.exist?(pxelinux_file)
        message = "Information:\tCopying '#{pxelinux_file}' to '#{pxelinux_tftp}'"
        command = "cp #{pxelinux_file} #{pxelinux_tftp}"
        execute_command(options,message,command)
      else
        handle_output(options,"Warning:\tTFTP boot file pxelinux.0 does not exist")
      end
    end
    if !File.exist?(syslinux_tftp)
      if !File.exist?(syslinux_tftp)
        options = install_package(options,"syslinux")
      end
      if File.exist?(syslinux_file)
        message = "Information:\tCopying '#{syslinux_file}' to '#{syslinux_tftp}'"
        command = "cp #{syslinux_file} #{syslinux_tftp}"
        execute_command(options,message,command)
      else
        handle_output(options,"Warning:\tTFTP boot file ldlinux.c32 does not exist")
      end
    end
    if options['host-os-uname'].match(/Ubuntu|Debian/)
      check_apt_tftpd(options)
    else
      check_yum_tftpd(options)
    end
    check_dir_exists(options,options['tftpdir'])
    if options['host-os-uname'].match(/RedHat|CentOS/)
      if Integer(options['host-os-version']) > 6
        message = "Checking SELinux tftp permissions"
        command = "getsebool -a | grep tftp |grep home"
        output  = execute_command(options,message,command)
        if output.match(/off/)
          message = "Information:\ySetting SELinux tftp permissions"
          command = "setsebool -P tftp_home_dir 1"
          execute_command(options,message,command)
        end
        restart_firewalld(options)
      end
    end
  end
  restart_tftpd(options)
  return
end
def check_tftpd_config ( options ) if options [ 'host-os-name' ] . to_s . match ( / Linux / ) tmp_file = "/tmp/tftp" pxelinux_file = "/usr/lib/PXELINUX/pxelinux.0" if ! File . exist? ( pxelinux_file ) options = install_package ( options , "pxelinux" ) options = install_package ( options , "syslinux" ) end syslinux_file = "/usr/lib/syslinux/modules/bios/ldlinux.c32" pxelinux_dir = options [ 'tftpdir' ] pxelinux_tftp = pxelinux_dir + "/pxelinux.0" syslinux_tftp = pxelinux_dir + "/ldlinux.c32" if options [ 'verbose' ] == true handle_output ( options , "Information:\tChecking PXE directory" ) end check_dir_exists ( options , pxelinux_dir ) check_dir_owner ( options , pxelinux_dir , options [ 'uid' ] ) if ! File . exist? ( pxelinux_tftp ) if ! File . exist? ( pxelinux_file ) options = install_package ( options , "pxelinux" ) end if File . exist? ( pxelinux_file ) message = "Information:\tCopying '#{pxelinux_file}' to '#{pxelinux_tftp}'" command = "cp #{pxelinux_file} #{pxelinux_tftp}" execute_command ( options , message , command ) else handle_output ( options , "Warning:\tTFTP boot file pxelinux.0 does not exist" ) end end if ! File . exist? ( syslinux_tftp ) if ! File . exist? ( syslinux_tftp ) options = install_package ( options , "syslinux" ) end if File . exist? ( syslinux_file ) message = "Information:\tCopying '#{syslinux_file}' to '#{syslinux_tftp}'" command = "cp #{syslinux_file} #{syslinux_tftp}" execute_command ( options , message , command ) else handle_output ( options , "Warning:\tTFTP boot file ldlinux.c32 does not exist" ) end end if options [ 'host-os-uname' ] . match ( / Ubuntu|Debian / ) check_apt_tftpd ( options ) else check_yum_tftpd ( options ) end check_dir_exists ( options , options [ 'tftpdir' ] ) if options [ 'host-os-uname' ] . match ( / RedHat|CentOS / ) if Integer ( options [ 'host-os-version' ] ) > 6 message = "Checking SELinux tftp permissions" command = "getsebool -a | grep tftp |grep home" output = execute_command ( options , message , command ) if output . match ( / off / ) message = "Information:\ySetting SELinux tftp permissions" command = "setsebool -P tftp_home_dir 1" execute_command ( options , message , command ) end restart_firewalld ( options ) end end end restart_tftpd ( options ) return end
Check tftpd config for Linux(turn on in xinetd config file /etc/xinetd.d/tftp)
Check tftpd config for Linux ( turn on in xinetd config file / etc / xinetd . d / tftp )
options
<not_specific>