fdfba5c45eddddafeca29f0189ea126886bb2252
[grml-terminalserver.git] / templates / grub-shim_config
1 # the following variables are available in the template:
2 #
3 # $INTERFACE_     (interface for the terminalserver)
4 # $IP_            (ip for the terminalserver to bind)
5 # $NETMASK_       (network mask)
6 # $GW_            (gateway)
7 # $NAMESERVERS_   (nameservers for the nodes)
8 # $IPRANGE_FROM_  (user configured iprange, first ip)
9 # $IPRANGE_TO_    (user configured iprange, last ip)
10 # $NETWORK_       (first ip in this subnet)
11 # $OPTIONS_       (options for grml-terminalserver)
12 # $BOOT_ARGS_     (boot arguments for the nodes)
13 #
14 # NOTE:
15 # templates are shellscript fragments and will be sourced from the
16 # terminalserver
17 #
18 # GLOBAL_README_END
19
20 if [ -r "${TFTPD_DATA_DIR_}"/shim.efi ] ; then
21   echo "${TFTPD_DATA_DIR_}/shim.efi exists already, nothing to do."
22 elif [ -r /usr/lib/shim/shimx64.efi.signed ] ; then
23   echo "Installing /usr/lib/shim/shimx64.efi.signed as shim.efi for TFTP usage"
24   cp /usr/lib/shim/shimx64.efi.signed "${TFTPD_DATA_DIR_}"/shim.efi
25 elif [ -r /usr/lib/shim/shimx64.efi ] ; then
26   echo "Installing /usr/lib/shim/shimx64.efi as shim.efi for TFTP usage"
27   cp /usr/lib/shim/shimx64.efi "${TFTPD_DATA_DIR_}"/shim.efi
28 else
29   echo "WARN: No shimx64.efi for usage with PXE boot found, not setting up UEFI boot via GRUB."
30   (( ret_=ret_+ $? ))
31   return "$ret_"
32 fi
33
34 if [ -r "${TFTPD_DATA_DIR_}"/grubx64.efi ] ; then
35   echo "${TFTPD_DATA_DIR_}/grubx64.efi exists already, nothing to do."
36 elif [ -r /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed ] ; then
37   echo "Installing /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed as grubx64.efi for TFTP usage"
38   cp /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed "${TFTPD_DATA_DIR_}"/grubx64.efi
39 elif [ -r /usr/lib/grub/x86_64-efi/monolithic/grubnetx64.efi ] ; then
40   echo "Installing /usr/lib/grub/x86_64-efi/monolithic/grubnetx64.efi as grubx64.efi for TFTP usage"
41   cp /usr/lib/grub/x86_64-efi/monolithic/grubnetx64.efi "${TFTPD_DATA_DIR_}"/grubx64.efi
42 else
43   echo "WARN: No grubnetx64.efi for usage with PXE boot found, not setting up UEFI boot via GRUB."
44   (( ret_=ret_+ $? ))
45   return "$ret_"
46 fi
47
48 echo "Setting up GRUB configuration for PXE/UEFI usage"
49 mkdir -p "${TFTPD_DATA_DIR_}/grub/"
50 cat > "${TFTPD_DATA_DIR_}/grub/grub.cfg" << EOT
51 # GRUB PXE configuration file
52
53 # adjust according to your needs
54 #set timeout=300
55
56 insmod png
57 set gfxmode=auto
58 insmod gfxterm
59 terminal_output gfxterm
60
61 set menu_color_normal=white/black
62 set menu_color_highlight=black/yellow
63
64 # this needs some tuning, so not enabled by default
65 # set theme=/boot/grub/grml-theme/theme.txt
66 # export theme
67
68 EOT
69
70 # theme support requires e.g. icons/submenu.png within the theme directory,
71 # which we don't ship though, so not enabled by default
72 #mkdir -p "${TFTPD_DATA_DIR_}"/grub/themes/boot/grub
73 #ln -s "${TFTPD_DATA_DIR_}"/boot/grub/grml-theme "${TFTPD_DATA_DIR_}"/grub/themes/boot/grub/
74
75 for file in "${TFTPD_DATA_DIR_}"/boot/grub/*_default.cfg "${TFTPD_DATA_DIR_}"/boot/grub/*_options.cfg ; do
76   filename="$(basename "${file}")"
77   echo "source boot/grub/${filename}" >> "${TFTPD_DATA_DIR_}/grub/grub.cfg"
78 done
79
80 cat >> "${TFTPD_DATA_DIR_}/grub/grub.cfg" << EOT
81
82 menuentry "Boot OS of first partition on first disk" {
83     set root=(hd0,1)
84     chainloader +1
85 }
86 EOT
87
88 (( ret_=ret_+ $? ))
89 return "$ret_"