ports/159306: multimedia/webcamd: New rc script with $webcamd_device

Zhihao Yuan lichray at gmail.com
Sat Jul 30 07:40:09 UTC 2011


>Number:         159306
>Category:       ports
>Synopsis:       multimedia/webcamd: New rc script with $webcamd_device
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 30 07:40:08 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Zhihao Yuan
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
Northern Illinois University
>Environment:
System: FreeBSD compaq.yuetime 8.2-STABLE FreeBSD 8.2-STABLE #4 r224501: Fri Jul 29 22:28:38 CDT 2011 lichray at compaq.yuetime:/usr/obj/home/lichray/devel/freebsd-stable/sys/HOUKAGO amd64


	
>Description:
	
	The current rc script is just unusable. It requires your to pass
	the device name by hand.
>How-To-Repeat:
	
>Fix:

	
	I added a $webcamd_device variable, and changes pidfile accordingly.

	Note that the pid in the $pidfile is wrong, and I fixed it by hacking
	into the file content.

	I'm not pro at writing rc script. Please help me improve it, thx.

--- webcamd_rc_2.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/multimedia/webcamd.orig/Makefile /usr/ports/multimedia/webcamd/Makefile
--- /usr/ports/multimedia/webcamd.orig/Makefile	2011-07-16 16:35:48.000000000 -0500
+++ /usr/ports/multimedia/webcamd/Makefile	2011-07-30 01:41:36.768846639 -0500
@@ -7,7 +7,7 @@
 
 PORTNAME=	webcamd
 PORTVERSION=	3.0.0.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	multimedia
 MASTER_SITES=	http://www.selasky.org/hans_petter/distfiles/ \
 		http://hselasky.homeunix.org:8192/distfiles/
diff -ruN --exclude=CVS /usr/ports/multimedia/webcamd.orig/files/webcamd.in /usr/ports/multimedia/webcamd/files/webcamd.in
--- /usr/ports/multimedia/webcamd.orig/files/webcamd.in	2011-04-21 04:06:26.000000000 -0500
+++ /usr/ports/multimedia/webcamd/files/webcamd.in	2011-07-30 02:15:45.929261409 -0500
@@ -7,6 +7,7 @@
 # Add the following line to /etc/rc.conf[.local] to enable webcamd:
 #
 # webcamd_enable="YES"
+# webcamd_device="ugenX.X"
 #
 
 webcamd_enable=${webcamd_enable-"NO"}
@@ -20,20 +21,35 @@
 command_args="-B -U webcamd -G webcamd"
 
 start_precmd="${name}_prestart"
+start_postcmd="${name}_fixpidfile"
+stop_precmd="${name}_check_vars"
 
 webcamd_prestart()
 {
   if checkyesno hald_enable ; then
 	command_args="$command_args -H"
   fi
+  webcamd_check_vars
 }
 
-pidfile="/var/run/webcamd.*.0.pid"
+webcamd_check_vars()
+{
+	if [ $# -gt 1 ]; then
+		webcamd_device="$2"
+	elif [ "x${webcamd_device}" = "x" ]; then
+		warn "You should set webcamd_device before running this"
+		return 1
+	fi
+	command_args="$command_args -d ${webcamd_device} -i 0"
+	pidfile="/var/run/webcamd.${webcamd_device##ugen}.0.pid"
+}
+
+webcamd_fixpidfile()
+{
+	read pid < $pidfile
+	pid="$(expr $pid + 1)"
+	echo -n "$pid" > $pidfile
+}
 
 load_rc_config $name
-if [ $# -gt 1 ]; then
-	pidfile="webcamd.dummy"
-	command_args="$command_args -d $2 -i 0"
-	# Only run the rc command if the appropriate arguments are specified:	
-	run_rc_command $1
-fi
+run_rc_command $1
diff -ruN --exclude=CVS /usr/ports/multimedia/webcamd.orig/pkg-message /usr/ports/multimedia/webcamd/pkg-message
--- /usr/ports/multimedia/webcamd.orig/pkg-message	2010-03-25 08:56:58.000000000 -0500
+++ /usr/ports/multimedia/webcamd/pkg-message	2011-07-30 02:23:52.540727383 -0500
@@ -12,6 +12,13 @@
 
 2) Please restart devd as the configuration changed
 
-	# /etc/rc.d/devd restart
+       # /etc/rc.d/devd restart
+
+3) The rc.d script for webcamd is testing. You can try in by adding
+
+       webcamd_enable="YES"
+       webcamd_device="ugenX.X" # your webcam device
+
+to your /etc/rc.conf
 
 *********************************************************************
--- webcamd_rc_2.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list