Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2785 - (hide annotations) (download)
Wed Feb 17 10:22:09 2016 UTC (8 years, 2 months ago) by niro
File size: 2815 byte(s)
-use bootserver as boot image server variable, and controlserver only for mcored
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     symlink_pxe_clients()
57     {
58     local i
59     local ids
60     local serial
61     local config
62    
63     # remove all symlinks but keep file based configs
64 niro 2688 find ${TFTP_DIRECTORY} -name 01-\* -type l | xargs --no-run-if-empty rm
65 niro 2674
66     ids=$(mysqldo "select serial from client_serials where enabled='1' and location <> '';")
67     for serial in ${ids}
68     do
69     evaluate_table_xml client_serials "where serial='${serial}'"
70     if [[ -n ${client_serials_mac} ]]
71     then
72     config="${TFTP_DIRECTORY}/01-${client_serials_mac//:/-}"
73     # do not update if an individual config file exist
74 niro 2688 if [[ -f ${config} ]]
75 niro 2674 then
76     echo "A config file named '${config}' already exist"
77     else
78     # 01- is the prefix identifier of the pxe/tftpd server for mac adresses
79     ln -snf lpxelinux-default-"${client_serials_location}" "${config}"
80     fi
81     fi
82     done
83     }
84    
85     case $1 in
86     create-config) create_pxe_config ;;
87     symlink-clients) symlink_pxe_clients ;;
88     *) echo "Unknown command, user either 'create-config' or 'symlink-clients'"; exit 1 ;;
89     esac