Skip to content

Commit dc5dee6

Browse files
committed
added basic install hook script
Signed-off-by: Zen <[email protected]>
1 parent 302cd08 commit dc5dee6

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

hooks/51-ugrd.install

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# this file is installed by sys-kernel/ugrd
4+
5+
ver=${1}
6+
img=${2}
7+
initrd=${img%/*}/initrd
8+
9+
# familiar helpers, we intentionally don't use Gentoo functions.sh
10+
die() {
11+
echo -e " ${NOCOLOR-\e[1;31m*\e[0m }${*}" >&2
12+
exit 1
13+
}
14+
15+
einfo() {
16+
echo -e " ${NOCOLOR-\e[1;32m*\e[0m }${*}" >&2
17+
}
18+
19+
ewarn() {
20+
echo -e " ${NOCOLOR-\e[1;33m*\e[0m }${*}" >&2
21+
}
22+
23+
main() {
24+
# re-define for subst to work
25+
[[ -n ${NOCOLOR+yes} ]] && NOCOLOR=
26+
27+
# do nothing if somehow ugrd is not installed
28+
[[ -x $(command -v ugrd) ]] || { ewarn "ugrd is not installed" && exit 0 ; }
29+
30+
[[ ${EUID} -eq 0 ]] || die "Please run this script as root"
31+
32+
ugrd --kver "${ver}" "${initrd}" || die "Failed to generate initramfs"
33+
}
34+
35+
main

0 commit comments

Comments
 (0)