-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_boot_menuentries
executable file
·65 lines (52 loc) · 1.33 KB
/
list_boot_menuentries
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#! /usr/bin/bash
################################################################################
# Copyright: [email protected]
# Version: 1.0
# Date: 2023-35-29
# Description:
################################################################################
####Imports of other module files####
source /usr/local/zbash/bin/lib/environments.sh
source /usr/local/zbash/bin/lib/errno.sh
source /usr/local/zbash/bin/lib/printer.sh
####Definition of global parameters####
gUnitTestEnabled=false
####Definition of functions####
function list_almalinux() {
print_green_t "almalinux:"
grubby --info=ALL | grep ^kernel
}
function list_centos() {
print_green_t "centos:"
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg | awk '{print $3}'
}
function list_ubuntu() {
print_green_t "ubuntu:"
grub-mkconfig | \
grep -iE "menuentry 'Ubuntu, with Linux" | \
awk '{print i++ " : "$1, $2, $3, $4, $5, $6, $7}' | \
grep menuentry
}
function list_boot_menuentries_main() {
case ${OS_ID} in
'almalinux')
list_almalinux
;;
'centos')
list_centos
;;
'ubuntu')
list_ubuntu
;;
*)
print_red_t "Unsupported os: ${OS_ID}"
exit ${EDOM}
;;
esac
}
list_boot_menuentries_main
####Unit test section####
if ${gUnitTestEnabled}; then
print_bold_green_t "====Unit test begin===="
print_bold_green_t "====Unit test end===="
fi