forked from hetzneronline/installimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimageinfo.functions.sh
More file actions
137 lines (112 loc) · 3.11 KB
/
imageinfo.functions.sh
File metadata and controls
137 lines (112 loc) · 3.11 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env bash
#
# imageinfo functions
#
# (c) 2019-2024, Hetzner Online GmbH
#
debian_buster_image() {
[[ "${IAM,,}" == 'debian' ]] || return 1
( ((IMG_VERSION >= 100)) && ((IMG_VERSION <= 109)) ) || ( ((IMG_VERSION >= 1010)) && ((IMG_VERSION < 1100)) )
}
debian_bullseye_image() {
[[ "${IAM,,}" == 'debian' ]] || return 1
((IMG_VERSION >= 1100)) && ((IMG_VERSION <= 1200))
}
debian_bookworm_image() {
[[ "${IAM,,}" == 'debian' ]] || return 1
((IMG_VERSION >= 1200)) && ((IMG_VERSION <= 1300))
}
other_image() {
local image="$1"
while read other_image; do
[[ "${image##*/}" == "$other_image" ]] && return 0
done < <(other_images)
return 1
}
old_image() {
local image="$1"
image="$(readlink -f "$image")"
[[ -e "$image" ]] || return 1
[[ "${image%/*}" == "$(readlink -f "$OLDIMAGESPATH")" ]]
}
rhel_based_image() {
[[ "$IAM" == 'centos' ]] ||
[[ "$IAM" == 'rockylinux' ]] ||
[[ "$IAM" == 'almalinux' ]] ||
[[ "$IAM" == 'rhel' ]]
}
rhel_9_based_image() {
if rhel_based_image; then
if ((IMG_VERSION >= 90 && IMG_VERSION < 100)) || ((IMG_VERSION >= 900 && IMG_VERSION < 1000)); then
return 0
fi
fi
return 1
}
rhel_8_based_image() {
if rhel_based_image; then
if ((IMG_VERSION >= 80 && IMG_VERSION < 90)) || ((IMG_VERSION >= 810 && IMG_VERSION < 900)); then
return 0
fi
fi
return 1
}
rhel_10_based_image() {
if rhel_based_image; then
if ((IMG_VERSION >= 1000 && IMG_VERSION < 1100)); then
return 0
fi
fi
return 1
}
uses_network_manager() {
[[ "$IAM" == 'centos' ]] && ((IMG_VERSION >= 80)) && ((IMG_VERSION != 610)) && ! is_cpanel_install && return
[[ "$IAM" == 'rockylinux' ]] && return
[[ "$IAM" == 'rhel' ]] && return
[[ "$IAM" == 'almalinux' ]] && ! is_cpanel_install && return
return 1
}
debian_based_image() {
[[ "$IAM" == 'debian' ]] || [[ "$IAM" == 'ubuntu' ]]
}
hwe_image() {
[[ "$IMAGE_FILE" =~ -hwe\. ]]
}
image_requires_xfs_version_check() {
[[ "$IAM" == 'ubuntu' ]] && ((IMG_VERSION <= 2004)) && return 0
[[ "$IAM" == 'debian' ]] && ((IMG_VERSION < 1100)) && return 0
return 1
}
image_i40e_driver_version() {
for f in i40e.ko i40e.ko.zst; do
if [[ "$(modinfo -F vermagic "$FOLD/hdd/lib/modules/"*"/kernel/drivers/net/ethernet/intel/i40e/$f" 2> /dev/null)" =~ ^([0-9]+\.[0-9]+)[^0-9] ]]; then
echo "${BASH_REMATCH[1]}"
return
fi
done
return 1
}
image_i40e_driver_version_ge() {
local other="$1"
[[ "$(echo -e "$(image_i40e_driver_version)\n$other" | sort -V | head -n 1)" == "$other" ]]
}
image_i40e_driver_exposes_port_name() {
image_i40e_driver_version_ge '6.7'
}
image_ice_driver_version() {
for f in ice.ko ice.ko.zst; do
if [[ "$(modinfo -F vermagic "$FOLD/hdd/lib/modules/"*"/kernel/drivers/net/ethernet/intel/ice/$f" 2> /dev/null)" =~ ^([0-9]+\.[0-9]+)[^0-9] ]]; then
echo "${BASH_REMATCH[1]}"
return
fi
done
return 1
}
image_ice_driver_version_ge() {
local other="$1"
[[ "$(echo -e "$(image_ice_driver_version)\n$other" | sort -V | head -n 1)" == "$other" ]]
}
image_ice_driver_exposes_port_name() {
image_ice_driver_version_ge '6.8'
}
# vim: ai:ts=2:sw=2:et