forked from allwincnc/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_lkm.sh
executable file
·113 lines (69 loc) · 2.01 KB
/
install_lkm.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
#!/bin/bash
source tools.sh
# var list
NAME="ARISC kernel module"
CUR_DIR=$(pwd)
DST_DIR="${HOME}/arisc_lkm_tmp"
SRC_DIR="./armbian/lkm"
ALL_FILES=("Makefile" "arisc_admin.c")
# greetings
log ""
log "--- Installing **${NAME}** -------"
# check a folder
if [[ ! -d "${SRC_DIR}" ]]; then
log "!!ERROR!!: Can't find the **${SRC_DIR}** folder [**${0}:${LINENO}**]."
exit 1
fi
# create TMP folder
if [[ ! -d "${DST_DIR}" ]]; then
mkdir "${DST_DIR}"
fi
# check/copy files
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
cp -f "${SRC_DIR}/${file}" "${DST_DIR}/${file}"
if [[ ! -f "${DST_DIR}/${file}" ]]; then
log "!!ERROR!!: Can't create the **${DST_DIR}/${file}** file [**${0}:${LINENO}**]."
exit 1
fi
done
# build the module
cd "${DST_DIR}"
make remove
make -C "${DST_DIR}" all
cd "${CUR_DIR}"
if [[ ! -f "${DST_DIR}/arisc_admin.ko" ]]; then
log "!!ERROR!!: Failed to build the kernel module [**${0}:${LINENO}**]."
exit 1
fi
# install the module
cd "${DST_DIR}"
make -C "${DST_DIR}" install
cd "${CUR_DIR}"
if [[ ! -f "/lib/modules/$(uname -r)/kernel/drivers/arisc/arisc_admin.ko" || \
! -f "/etc/modules-load.d/arisc.conf" ]]; then
log "!!ERROR!!: Failed to install the kernel module [**${0}:${LINENO}**]."
exit 1
fi
# check the module
if [[ ! $(cat /proc/devices | grep arisc) ]]; then
log "!!ERROR!!: Can't find the kernel module device [**${0}:${LINENO}**]."
exit 1
fi
if [[ ! $(ls /sys/class | grep arisc) ]]; then
log "!!ERROR!!: Can't find the kernel module class [**${0}:${LINENO}**]."
exit 1
fi
if [[ ! $(ls /dev | grep arisc) ]]; then
log "!!ERROR!!: Can't find the kernel module device file [**${0}:${LINENO}**]."
exit 1
fi
# remove TMP folder
if [[ -d "${DST_DIR}" ]]; then
rm -fr "${DST_DIR}"
fi
log "--- **${NAME}** ++successfully installed++ -------"
log ""