summaryrefslogtreecommitdiff
path: root/src/boot/grub2/grub2-15_ostree
blob: dfff6e89bf6b77aa4c4715f90c1edbe0f350b0be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
# 
# Copyright (C) 2014 Colin Walters <walters@verbum.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2 of the licence or (at
# your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307, USA.

# Gracefully exit if ostree is not installed
if ! which ostree >/dev/null 2>/dev/null; then
    exit 0
fi

# Make sure we're in the right environment
if ! test -n "${GRUB_DEVICE}"; then
    echo "This script must be run as a child of grub2-mkconfig" 1>&2
    exit 1
fi

set -e

# Pick up stuff from grub's helper that we want to inject into our
# generated bootloader configuration.  Yes, this is pretty awful, but
# it's a lot better than reimplementing the config-generating bits of
# OSTree in shell script.

. /usr/share/grub/grub-mkconfig_lib

DEVICE=${GRUB_DEVICE_BOOT:-${GRUB_DEVICE}}

GRUB2_BOOT_DEVICE_ID="$(grub_get_device_id ${DEVICE})"
export GRUB2_BOOT_DEVICE_ID
GRUB2_PREPARE_ROOT_CACHE="$(prepare_grub_to_access_device ${DEVICE})"
export GRUB2_PREPARE_ROOT_CACHE

exec ostree admin instutil grub2-generate