forked from allwincnc/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_kernel.sh
executable file
·113 lines (72 loc) · 2.41 KB
/
install_kernel.sh
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
#!/bin/bash
source tools.sh
# var list
NAME="PREEMPT RT kernel"
SRC_DIR="./armbian/kernel"
SRC_ARCH=("armhf" "arm64")
DST_ARCH=("armv7" "aarch64")
ALL_FILES=("linux-headers-current-sunxi_21.05.0-trunk_armhf.deb" \
"linux-image-current-sunxi_21.05.0-trunk_armhf.deb" \
"linux-headers-current-sunxi64_21.05.0-trunk_arm64.deb" \
"linux-image-current-sunxi64_21.05.0-trunk_arm64.deb")
# greetings
log ""
log "--- Installing **${NAME}** -------"
# check folders/files
if [[ ! -d "${SRC_DIR}" ]]; then
log "!!ERROR!!: Can't find the **${SRC_DIR}** folder [**${0}:${LINENO}**]."
exit 1
fi
for file in ${ALL_FILES[*]}; do
if [[ ! -f "${SRC_DIR}/${file}" ]]; then
log "!!ERROR!!: Can't find the **${SRC_DIR}/${file}** file [**${0}:${LINENO}**]."
exit 1
fi
done
# check CPU arch
supported=""
for item in ${DST_ARCH[*]}; do
if [[ $(uname -m | grep "${item}") ]]; then
supported="1"
break
fi
done
if [[ ! $supported ]]; then
log "Supported CPU types: **${DST_ARCH[*]}**"
log "!!ERROR!!: Your CPU type (**$(uname -m)**) isn't supported [**${0}:${LINENO}**]."
exit 1
fi
# get packages data
PKG_ARCH=""
arch_cnt=${#DST_ARCH[@]}
for (( a=0; a < $arch_cnt; a++ )); do
if [[ $(uname -m | grep "${DST_ARCH[$a]}") ]]; then
PKG_ARCH="${SRC_ARCH[$a]}"
break
fi
done
ARCH_PKGS=$(ls $SRC_DIR | grep "$PKG_ARCH.deb")
MAIN_PKG=$SRC_DIR"/"$(echo "$ARCH_PKGS" | grep "image")
HEAD_PKG=$SRC_DIR"/"$(echo "$ARCH_PKGS" | grep "headers")
# installing packages
log "Installing packages ..."
log "Installing **$MAIN_PKG** ..."
if [[ -f $MAIN_PKG ]]; then
sudo apt install $MAIN_PKG -qq
fi
version=$(dpkg-deb -I "$MAIN_PKG" | grep "Source:" | grep -P -o "[0-9]+\.[0-9]+\.[0-9]+\-\w+\-\w+")
if [[ ! -f "/boot/vmlinuz-${version}" ]]; then
log "!!ERROR!!: Failed to install **${MAIN_PKG}** package [**${0}:${LINENO}**]."
exit 1
fi
log "Installing **$HEAD_PKG** ..."
if [[ -f $HEAD_PKG ]]; then
sudo apt install $HEAD_PKG -qq
fi
version=$(dpkg-deb -I "$HEAD_PKG" | grep "Source:" | grep -P -o "[0-9]+\.[0-9]+\.[0-9]+\-\w+\-\w+")
if [[ ! -d "/usr/src/linux-headers-${version}" ]]; then
log "WARNING: Failed to install **${HEAD_PKG}** package [**${0}:${LINENO}**]."
fi
log "@@NOTE@@: You must reboot the system to complete the installation"
log "--- **${NAME}** ++successfully installed++ -------"
log ""