updated on Wed Jan 25 08:34:36 UTC 2012
[aur-mirror.git] / droidcam / droidcam.rc
blob5ee1f72f6a1be942e8d9fb6fc15b802fc8ddee37
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 VIDEODEV="videodev"
7 DROIDCAM_V4L="droidcam_v4l"
8 DRIVER_LOCATION="/lib/modules/`uname -r`/kernel/drivers/media/video"
9 BUILD_SCRIPT="/usr/share/droidcam/build_tmp"
10 [[ -z $WIDTH ]] && WIDTH=320
11 [[ -z $HEIGHT ]] && HEIGHT=240
13 load() {
14 # check if module exists
15 c=$(find "${DRIVER_LOCATION}" -type f -regex ".*/${DROIDCAM_V4L}.ko" | wc -l)
16 [[ $c -eq 0 ]] && setup
17 stat_busy "Loading Droidcam kernel module"
19 # trivial loading
20 /sbin/modprobe ${VIDEODEV} &>/dev/null
21 /sbin/insmod ${DRIVER_LOCATION}/${DROIDCAM_V4L}.ko width=${WIDTH} height=${HEIGHT}
22 modprobe ${DROIDCAM_V4L} &>/dev/null
24 # check
25 if ! grep -q "^${DROIDCAM_V4L}" /proc/modules; then
26 stat_fail
27 return 1
29 add_daemon droidcam_v4l
30 stat_done
33 unload() {
34 stat_busy "Unloading Droidcam kernel module"
35 # trivial unload
36 if grep -q "^${DROIDCAM_V4L}" /proc/modules; then
37 modprobe -r ${DROIDCAM_V4L} &>/dev/null
39 # check
40 if grep -q "^${DROIDCAM_V4L}" /proc/modules; then
41 stat_fail
42 return 1
44 rm_daemon droidcam_v4l
45 stat_done
48 remove() {
49 stat_busy "Removing Droidcam kernel module"
50 find "${DRIVER_LOCATION}" -type f -regex ".*/${DROIDCAM_V4L}.ko" -delete
51 stat_done
54 setup() {
55 remove
56 stat_busy "Compiling Droidcam kernel module"
57 LOG="/tmp/droidcam-install.log"
58 if ! $BUILD_SCRIPT > $LOG 2>&1; then
59 echo "ERROR: Look at $LOG to find out what went wrong"
61 depmod -A
62 stat_done
65 case "$1" in
66 start)
67 load
69 stop)
70 unload
72 restart)
73 unload
74 load
76 setup)
77 setup
79 remove)
80 remove
83 echo "usage: $0 {start|stop|restart|setup|remove}"
84 esac
86 # End of file
87 # vim: set ts=2 sw=2 noet: