-
Notifications
You must be signed in to change notification settings - Fork 174
/
install-dkms
executable file
·62 lines (51 loc) · 1.85 KB
/
install-dkms
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
#!/usr/bin/env bash
#
# Usage: ./install-dkms [640 480]
set -e
REPO_PATH="$(/usr/bin/dirname $([ -L $0 ] && /bin/readlink -f $0 || echo $0))"
source "${REPO_PATH}/install.common"
check_if_installed
generate_dkms_conf() {
local target="$*"
cat <<EOF > "${target}"
PACKAGE_NAME="${V4L2_LOOPBACK_DC}"
PACKAGE_VERSION="${V4L2_LOOPBACK_VERSION}"
CLEAN="make clean"
MAKE[0]="make all KVERSION=$kernelver"
BUILT_MODULE_NAME[0]="${V4L2_LOOPBACK_KM}"
DEST_MODULE_LOCATION[0]="/updates"
AUTOINSTALL="yes"
EOF
}
setup_dkms_module() {
# Copying module dir with name expected by dkms in /usr/src
if [ -d "/usr/src/${V4L2_LOOPBACK_DC}-${V4L2_LOOPBACK_VERSION}" ] || [ -L "/usr/src/${V4L2_LOOPBACK_DC}-${V4L2_LOOPBACK_VERSION}" ]; then
rm -Rf "/usr/src/${V4L2_LOOPBACK_DC}-${V4L2_LOOPBACK_VERSION}"
fi
cp -a "${REPO_PATH}/${V4L2_LOOPBACK_DIR}" "/usr/src/${V4L2_LOOPBACK_DC}-${V4L2_LOOPBACK_VERSION}"
chown root:root "/usr/src/${V4L2_LOOPBACK_DC}-${V4L2_LOOPBACK_VERSION}" -R
generate_dkms_conf "/usr/src/${V4L2_LOOPBACK_DC}-${V4L2_LOOPBACK_VERSION}/dkms.conf"
dkms build -m ${V4L2_LOOPBACK_DC} -v ${V4L2_LOOPBACK_VERSION}
dkms install -m ${V4L2_LOOPBACK_DC} -v ${V4L2_LOOPBACK_VERSION}
if [ -f /etc/redhat-release ]; then
dkms mkrpm -m ${V4L2_LOOPBACK_DC} -v ${V4L2_LOOPBACK_VERSION}
elif [ -f /etc/debian_version ]; then
dkms mkdeb -m ${V4L2_LOOPBACK_DC} -v ${V4L2_LOOPBACK_VERSION}
else
echo "unsupported distro"
exit 1
fi
}
copy_uninstall_script() {
echo "Adding uninstall script in '/opt/droidcam-uninstall'"
mkdir -p /opt || true
cp "${REPO_PATH}/uninstall-dkms" /opt/droidcam-uninstall
}
# Here we go
check_module_options "$1" "$2"
copy_uninstall_script
setup_dkms_module
register_video_module_at_boot_time
# Finally let's load the module
modprobe ${V4L2_LOOPBACK_DC}
echo 'Done'