summaryrefslogtreecommitdiff
path: root/copy-modloop.in
blob: 8d57f5a34bf21b047b4bef8b3aff1ba52e80177d (plain)
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
#!/bin/sh

PREFIX=@PREFIX@
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"

usage() {
	cat <<-__EOF__
		usage: copy-modloop

		Copy kernel modules from modloop and unmount loopback device

		options:
		 -h  Show this help
	__EOF__
	exit $1
}

while getopts "h" opt; do
	case $opt in
		h) usage 0;;
		'?') usage "1" >&2;;
	esac
done
shift $(($OPTIND - 1))

set -e

if ! rc-service -q modloop status; then
	echo "modloop is not started"
	exit 1
fi

if [ -n "$DO_UMOUNT" ] && [ -z "$modloop_media" ]; then
	modloop_media=$(find_modloop_media)
fi

modulesdir=/lib/modules
if [ -L "$modulesdir" ]; then
	modulesdir=$(readlink "$modulesdir")
fi
cp -a "$modulesdir" /lib/modules.tmp
rc-service modloop stop
rm -r /lib/modules
mv /lib/modules.tmp /lib/modules

if [ -n "$DO_UMOUNT" ]; then
	umount "$modloop_media"
fi