Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/pxeconfig/mcore-pxeconfig.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2684 by niro, Fri Dec 11 09:55:07 2015 UTC revision 2800 by niro, Wed Jun 22 11:56:21 2016 UTC
# Line 29  create_pxe_config() Line 29  create_pxe_config()
29   do   do
30   evaluate_table_xml client_locations "where location='${loc}'"   evaluate_table_xml client_locations "where location='${loc}'"
31    
32     # fallback to honor old database versions in transition phase of the upgrade
33     if [[ -z ${client_locations_bootserver} ]] || [[ ${client_locations_bootserver} = NULL ]]
34     then
35     client_locations_bootserver="${client_locations_controlserver}"
36     fi
37    
38   sed \   sed \
39   -e "s:@@DEFAULTENTRY@@:${client_locations_pxe_default_entry}:g" \   -e "s:@@DEFAULTENTRY@@:${client_locations_pxe_default_entry}:g" \
40   -e "s:@@TIMEOUT@@:${client_locations_pxe_timeout}:g" \   -e "s:@@TIMEOUT@@:${client_locations_pxe_timeout}:g" \
41   -e "s:@@PROMPT@@:${client_locations_pxe_prompt}:g" \   -e "s:@@PROMPT@@:${client_locations_pxe_prompt}:g" \
42     -e "s:@@BOOTSERVER@@:${client_locations_bootserver}:g" \
43   -e "s:@@CONTROLSERVER@@:${client_locations_controlserver}:g" \   -e "s:@@CONTROLSERVER@@:${client_locations_controlserver}:g" \
44     -e "s:@@LOCATION@@:${client_locations_location}:g" \
45   \   \
46   "${TFTP_DIRECTORY}"/lpxelinux-skeleton \   "${TFTP_DIRECTORY}"/lpxelinux-skeleton \
47   > "${TFTP_DIRECTORY}"/lpxelinux-default-"${client_locations_location}"   > "${TFTP_DIRECTORY}"/lpxelinux-default-"${client_locations_location}"
# Line 45  create_pxe_config() Line 53  create_pxe_config()
53   done   done
54  }  }
55    
56  symlink_pxe_clients()  update_pxe_clients()
57  {  {
58   local i   local i
59   local ids   local ids
60   local serial   local serial
61   local config   local config
62    
63   # remove all symlinks but keep file based configs   # remove all client symlinks and files
64   for i in $(find ${TFTP_DIRECTORY} -name 01-\*)   # 01- is the prefix identifier of the pxe/tftpd server for mac adresses
65   do   find ${TFTP_DIRECTORY} -name 01-\* -type l -o -name 01-\* -type f | xargs --no-run-if-empty rm
  [[ -L ${TFTP_DIRECTORY}/${i} ]] && rm ${TFTP_DIRECTORY}/${i}  
  done  
66    
67   ids=$(mysqldo "select serial from client_serials where enabled='1' and location <> '';")   ids=$(mysqldo "select serial from client_serials where enabled='1' and location <> '';")
68   for serial in ${ids}   for serial in ${ids}
69   do   do
70   evaluate_table_xml client_serials "where serial='${serial}'"   evaluate_table_xml client_serials "where serial='${serial}'"
71     evaluate_table_xml client_boot "where serial='${serial}'"
72   if [[ -n ${client_serials_mac} ]]   if [[ -n ${client_serials_mac} ]]
73   then   then
74     # 01- is the prefix identifier of the pxe/tftpd server for mac adresses
75   config="${TFTP_DIRECTORY}/01-${client_serials_mac//:/-}"   config="${TFTP_DIRECTORY}/01-${client_serials_mac//:/-}"
76   # do not update if an individual config file exist   # do not symlink if an individual config is requested
77   if [[ -e ${config} ]]   if [[ -n ${client_boot_cmdline} ]] && [[ ${client_boot_cmdline} != NULL ]]
78   then   then
79   echo "A config file named '${config}' already exist"   echo "Using an individual configuration  for '${config}'"
80     sed -e "s:^\([[:space:]]append .*\):\1 ${client_boot_cmdline}:" \
81     ${TFTP_DIRECTORY}/lpxelinux-default-"${client_serials_location}" > "${config}"
82   else   else
  # 01- is the prefix identifier of the pxe/tftpd server for mac adresses  
83   ln -snf lpxelinux-default-"${client_serials_location}" "${config}"   ln -snf lpxelinux-default-"${client_serials_location}" "${config}"
84   fi   fi
85   fi   fi
# Line 79  symlink_pxe_clients() Line 88  symlink_pxe_clients()
88    
89  case $1 in  case $1 in
90   create-config) create_pxe_config ;;   create-config) create_pxe_config ;;
91   symlink-clients) symlink_pxe_clients ;;   # keep symlink-clients for compat reasons atm
92   *) echo "Unknown command, user either 'create-config' or 'symlink-clients'"; exit 1 ;;   symlink-clients|update-clients) update_pxe_clients ;;
93     *) echo "Unknown command, user either 'create-config' or 'update|symlink-clients'"; exit 1 ;;
94  esac  esac

Legend:
Removed from v.2684  
changed lines
  Added in v.2800