grub/efi boot: load unicode font for nice looking boot splash
[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 if [ -r "${TFTPD_DATA_DIR_}"/grub/fonts/unicode.pf2 ] ; then
49   echo "${TFTPD_DATA_DIR_}/grub/fonts/unicode.pf2 exists already, nothing to do."
50 elif [ -r /usr/share/grub/unicode.pf2 ] ; then
51   echo "Installing /usr/share/grub/unicode.pf2 for TFTP usage"
52   mkdir -p "${TFTPD_DATA_DIR_}"/grub/fonts/
53   cp /usr/share/grub/unicode.pf2 "${TFTPD_DATA_DIR_}"/grub/fonts/
54 else
55   echo "WARN: No unicode.pf2 for usage with PXE boot found."
56 fi
57
58 echo "Setting up GRUB configuration for PXE/UEFI usage"
59 mkdir -p "${TFTPD_DATA_DIR_}/grub/"
60 cat > "${TFTPD_DATA_DIR_}/grub/grub.cfg" << EOT
61 # GRUB PXE configuration file
62
63 # adjust according to your needs
64 #set timeout=300
65
66 insmod png
67 set gfxmode=auto
68 insmod gfxterm
69 terminal_output gfxterm
70
71 loadfont unicode
72
73 set menu_color_normal=white/black
74 set menu_color_highlight=black/yellow
75
76 # this needs some tuning, so not enabled by default
77 # set theme=/boot/grub/grml-theme/theme.txt
78 # export theme
79
80 EOT
81
82 # theme support requires e.g. icons/submenu.png within the theme directory,
83 # which we don't ship though, so not enabled by default
84 #mkdir -p "${TFTPD_DATA_DIR_}"/grub/themes/boot/grub
85 #ln -s "${TFTPD_DATA_DIR_}"/boot/grub/grml-theme "${TFTPD_DATA_DIR_}"/grub/themes/boot/grub/
86
87 for file in "${TFTPD_DATA_DIR_}"/boot/grub/*_default.cfg "${TFTPD_DATA_DIR_}"/boot/grub/*_options.cfg ; do
88   filename="$(basename "${file}")"
89   echo "source boot/grub/${filename}" >> "${TFTPD_DATA_DIR_}/grub/grub.cfg"
90 done
91
92 cat >> "${TFTPD_DATA_DIR_}/grub/grub.cfg" << EOT
93
94 menuentry "Boot OS of first partition on first disk" {
95     set root=(hd0,1)
96     chainloader +1
97 }
98 EOT
99
100 (( ret_=ret_+ $? ))
101 return "$ret_"