-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path52-ugrd.install
38 lines (27 loc) · 881 Bytes
/
52-ugrd.install
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
#!/usr/bin/env bash
# this file is installed by sys-kernel/ugrd
ver=${1}
img=${2}
initrd=${INSTALLKERNEL_STAGING_AREA:-$(dirname "${img}")}/initrd
# familiar helpers, we intentionally don't use Gentoo functions.sh
die() {
echo -e " ${NOCOLOR-\e[1;31m*\e[0m }${*}" >&2
exit 1
}
einfo() {
echo -e " ${NOCOLOR-\e[1;32m*\e[0m }${*}" >&2
}
ewarn() {
echo -e " ${NOCOLOR-\e[1;33m*\e[0m }${*}" >&2
}
main() {
# re-define for subst to work
[[ -n ${NOCOLOR+yes} ]] && NOCOLOR=
# Exit if ugrd is not the INSTALLKERNEL_INITRD_GENERATOR
[[ ${INSTALLKERNEL_INITRD_GENERATOR} == "ugrd" ]] || exit 0
# do nothing if somehow ugrd is not installed
[[ -x $(command -v ugrd) ]] || { ewarn "ugrd is not installed" && exit 0 ; }
[[ ${EUID} -eq 0 ]] || die "Please run this script as root"
ugrd --no-rotate --kver "${ver}" "${initrd}" || die "Failed to generate initramfs"
}
main