summaryrefslogtreecommitdiff
path: root/src/backend/f_generic.sh
blob: ce413feee12b7feb5ac63d9e1ab4f71e08fb71c9 (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
#!/usr/bin/env bash

checkifroot () {
	if [[ "$(whoami)" != root ]] ; then
		eerror "I won't do that, unless you're root!"
		exit 1
	fi
}

checkkerncfg () {
	if [[ $(zgrep 'CONFIG_OVERLAY_FS=' /proc/config.gz) && $(zgrep "CONFIG_SQUASHFS=" /proc/config.gz) &&  $(zgrep "CONFIG_BLK_DEV_LOOP=" /proc/config.gz) ]] ; then
		einfo "Kernel config OK, moving on"
	else
		eerror "I won't do that with the current kernel"
		eerror "I want a kernel with OVERLAYFS && SQUASHFS && LOOP DEVICES enabled"
		exit 1
	fi
}

checkiflive () {
	if [[ -L /dev/mapper/live-base ]] ; then
		eerror "I won't do that on a live system"
		exit 1
	fi
}

checkjailsum () {
	if [[ -f "$jailx64" && -f "$jailx64sum" ]] ; then
		if [[ "$(md5sum -c "$jailx64sum")" ]] ; then
			einfo "Jail integrity OK, moving on"
		else
			eerror "I won't do that with a corrupted jail"
			exit 1
		fi
	else
		eerror "I won't do that with a missing jail"
		exit 1
	fi
}

dkmsmodbuild () {
	checkifroot
	if [[ -x /usr/sbin/dkms ]] ; then
		for i in $(dkms status | cut -d " " -f1,2 | sed -e 's/,//g' | sed -e 's/ /\//g' | sed -e 's/://g') ; do
			dkms install $i
		done
	fi
}