Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2800 - (hide annotations) (download)
Wed Jun 22 11:56:21 2016 UTC (7 years, 10 months ago) by niro
File size: 3241 byte(s)
-honor individual boot cmdlines for every client
1 niro 2674 #!/bin/bash
2    
3     MCORE_LIBDIR="@@MCORE_LIBDIR@@"
4     source @@SYSCONFDIR@@/mcore/mcore.conf
5     source @@SYSCONFDIR@@/mcore/control.conf
6     source ${MCORE_LIBDIR}/include/common.global.class
7     source ${MCORE_LIBDIR}/include/daemon.global.class
8     source ${MCORE_LIBDIR}/include/mysqlfunctions.global.class
9    
10     TFTP_DIRECTORY="@@TFTP_DIRECTORY@@"
11    
12     create_pxe_config()
13     {
14     local locations
15     local loc
16     local client_locations_location
17     local client_locations_controlserver
18     local client_locations_pxe_default_entry
19     local client_locations_pxe_prompt
20     local client_locations_pxe_timeout
21     local client_locations_set_default
22    
23     # cleanup
24     find ${TFTP_DIRECTORY} -name lpxelinux-default-\* | xargs --no-run-if-empty rm
25     [[ -L ${TFTP_DIRECTORY}/default ]] && rm ${TFTP_DIRECTORY}/default
26    
27     locations=$(mysqldo "select location from client_locations where enabled='1';")
28     for loc in ${locations}
29     do
30     evaluate_table_xml client_locations "where location='${loc}'"
31    
32 niro 2785 # 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 niro 2674 sed \
39     -e "s:@@DEFAULTENTRY@@:${client_locations_pxe_default_entry}:g" \
40     -e "s:@@TIMEOUT@@:${client_locations_pxe_timeout}:g" \
41     -e "s:@@PROMPT@@:${client_locations_pxe_prompt}:g" \
42 niro 2785 -e "s:@@BOOTSERVER@@:${client_locations_bootserver}:g" \
43 niro 2674 -e "s:@@CONTROLSERVER@@:${client_locations_controlserver}:g" \
44 niro 2768 -e "s:@@LOCATION@@:${client_locations_location}:g" \
45 niro 2674 \
46     "${TFTP_DIRECTORY}"/lpxelinux-skeleton \
47     > "${TFTP_DIRECTORY}"/lpxelinux-default-"${client_locations_location}"
48    
49     if [[ ${client_locations_set_default} = 1 ]]
50     then
51     ln -snf lpxelinux-default-"${client_locations_location}" "${TFTP_DIRECTORY}"/default
52     fi
53     done
54     }
55    
56 niro 2800 update_pxe_clients()
57 niro 2674 {
58     local i
59     local ids
60     local serial
61     local config
62    
63 niro 2800 # remove all client symlinks and files
64     # 01- is the prefix identifier of the pxe/tftpd server for mac adresses
65     find ${TFTP_DIRECTORY} -name 01-\* -type l -o -name 01-\* -type f | xargs --no-run-if-empty rm
66 niro 2674
67     ids=$(mysqldo "select serial from client_serials where enabled='1' and location <> '';")
68     for serial in ${ids}
69     do
70     evaluate_table_xml client_serials "where serial='${serial}'"
71 niro 2800 evaluate_table_xml client_boot "where serial='${serial}'"
72 niro 2674 if [[ -n ${client_serials_mac} ]]
73     then
74 niro 2800 # 01- is the prefix identifier of the pxe/tftpd server for mac adresses
75 niro 2674 config="${TFTP_DIRECTORY}/01-${client_serials_mac//:/-}"
76 niro 2800 # do not symlink if an individual config is requested
77     if [[ -n ${client_boot_cmdline} ]] && [[ ${client_boot_cmdline} != NULL ]]
78 niro 2674 then
79 niro 2800 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 niro 2674 else
83     ln -snf lpxelinux-default-"${client_serials_location}" "${config}"
84     fi
85     fi
86     done
87     }
88    
89     case $1 in
90     create-config) create_pxe_config ;;
91 niro 2800 # keep symlink-clients for compat reasons atm
92     symlink-clients|update-clients) update_pxe_clients ;;
93     *) echo "Unknown command, user either 'create-config' or 'update|symlink-clients'"; exit 1 ;;
94 niro 2674 esac