xref: /openwifi/user_space/populate_kernel_image_module_reboot.sh (revision 6a4d7cea87e6493f6df109530a5a8275bc84916e)
1#!/bin/bash
2
3# Author: Xianjun Jiao
4# SPDX-FileCopyrightText: 2019 UGent
5# SPDX-License-Identifier: AGPL-3.0-or-later
6
7set -ex
8
9MACHINE_TYPE=`uname -m`
10
11mkdir -p kernel_modules
12rm -rf kernel_modules/*
13tar -zxvf kernel_modules.tar.gz
14
15if [ ${MACHINE_TYPE} == 'aarch64' ]; then
16    IMAGE_FILENAME=Image
17else
18    IMAGE_FILENAME=uImage
19fi
20
21rm -rf /lib/modules/$(uname -r)
22# setup kernel module directory
23# if [ -d "/lib/modules/$(uname -r)" ]; then
24#     echo "/lib/modules/$(uname -r) already exists."
25# else
26    # if [ ${MACHINE_TYPE} == 'aarch64' ]; then
27    #     ln -s /root/kernel_modules /lib/modules/$(uname -r)
28    # else
29    #     ln -s /root/kernel_modules /lib/modules/$(uname -r)
30    # fi
31    ln -s /root/kernel_modules /lib/modules/$(uname -r)
32# fi
33
34depmod
35# modprobe mac80211
36
37umount /mnt || /bin/true
38mount /dev/mmcblk0p1 /mnt
39if test -f "./kernel_modules/$IMAGE_FILENAME"; then
40    cp ./kernel_modules/$IMAGE_FILENAME /mnt/
41fi
42if test -f "./kernel_modules/BOOT.BIN"; then
43    cp ./kernel_modules/BOOT.BIN /mnt/
44fi
45cd /mnt/
46sync
47cd ~
48umount /mnt
49
50reboot now
51