Having problems with rc.local

jim ruxton cinetron at passport.ca
Thu Sep 15 06:01:37 UTC 2005


On Wed, 2005-09-14 at 14:09 -0700, Rick Stevens wrote:
> jim ruxton wrote:
> > On Wed, 2005-09-14 at 09:24 -0700, Rick Stevens wrote:
> > 
> >>jim ruxton wrote:
> >>[snip]
> >>
> >>>>I think I missed which OS this was.  If it's FC4 or a 2.6.11 kernel,
> >>>>there are issues with udev not enumerating correctly and requiring a
> >>>>status change on the port (unplug, plug will do it).  Supposedly fixed
> >>>>in 2.6.12-1.1447, but I won't swear to it.
> >>>
> >>>
> >>>Well I thought I was getting somewhere. I decided to use the script that
> >>>is started when the camera is turned on to start my script. When the
> >>>camera is switched on or plugged in the script /etc/hotplug/usb/usbcam
> >>>is started. If I start my script normally in this script all looks good.
> >>>ie. 
> >>> /home/jim/capture/camera_start_script.sh & but it is run by root.
> >>>
> >>>but if I try to start it as a user ie.
> >>>
> >>>su - jim -c /home/jim/capture/camera_start_script.sh &
> >>>
> >>>then for some reason 3 copies of the script get executed. I can't figure
> >>>out what is going on here, any ideas? I only need 1 copy to run, in fact
> >>>three copies running messes me up?? Thanks for any suggestions.
> >>
> >>Oops, disregard my last posting (mouse button stuck).
> >>
> >>We'd need to see the script itself, Jim.
> > 
> > Thanks Rick,
> > Here is the script that starts the camera
> > ie.  /home/jim/capture/camera_start_script.sh:
> > 
> > #!/bin/sh
> > #
> > # This script starts camera
> > capture start &
> > cd /home/jim/capture
> > python pythoncapture.py &
> > 
> > and here is the usbcam script that starts when camera is turned on or
> > plugged in:
> > 
> > #!/bin/bash
> > # $Id: usbcam.console,v 1.4 2002/09/12 16:50:18 hun Exp $
> > #
> > # /etc/hotplug/usb/usbcam
> > #
> > # Sets up newly plugged in USB camera so that the user who owns
> > # the console according to pam_console can access it from user space
> > #
> > # Note that for this script to work, you'll need all of the following:
> > # a) a line in the file /etc/hotplug/usermap that corresponds to the
> > #    camera you are using. You can get the correct lines for all cameras
> > #    supported by libgphoto2 by running "print-usb-usermap".
> > # b) a setup using pam_console creates the respective lock files
> > #    containing the name of the respective user. You can check for that
> > #    by executing "echo `cat /var/{run,lock}/console.lock`" and
> > #    verifying the appropriate user is mentioned somewhere there.
> > # c) a Linux kernel supporting hotplug and usbdevfs
> > # d) the hotplug package (http://linux-hotplug.sourceforge.net/)
> > #
> > # In the usermap file, the first field "usb module" should be named
> > # "usbcam" like this script.
> > #
> > 
> > if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
> > then
> >     # New code, using lock files instead of copying /dev/console
> > permissions
> >     # This also works with non-gdm logins (e.g. on a virtual terminal)
> >     # Idea and code from Nalin Dahyabhai <nalin at redhat.com>
> >     if [ -f /var/run/console/console.lock ]
> >     then
> >         CONSOLEOWNER=`cat /var/run/console/console.lock`
> >     elif [ -f /var/run/console.lock ]
> >     then
> >         CONSOLEOWNER=`cat /var/run/console.lock`
> >     elif [ -f /var/lock/console.lock ]
> >     then
> >         CONSOLEOWNER=`cat /var/lock/console.lock`
> >     else
> >         CONSOLEOWNER=
> >     fi
> >     if [ -n "$CONSOLEOWNER" ]
> >     then
> >         chmod 0000 "${DEVICE}"
> >         chown "$CONSOLEOWNER" "${DEVICE}"
> >         chown "$USER" "${DEVICE}"
> >         chmod 0600 "${DEVICE}"
> >     fi
> > fi
> > killall -9 capture python
> > su - jim -c /home/jim/capture/camera_start_script.sh &
> > 
> > I put the killall in there just to try and be sure there are no other
> > copies running but doesn't help. Any thoughts. Also for some reason my
> > last 2 emails haven't been going to the install list. Not sure what is
> > up with that.
> 
> Well, hmmm.  First off, I'd change the "camera_start_script.sh" script
> as follows:
> 
> 	#!/bin/sh
> 	#
> 	# This script starts camera
> 	nohup capture start &
> 	cd /home/jim/capture
> 	nohup python pythoncapture.py &
> 
> It's entirely possible that "capture" and "pythoncapture.py" want a
> console.  If so, and you run them from /etc/rc or the hotplug system,
> then there's no console for those programs set up and they won't run.
> "nohup" redirects stdout and stderr to ~$HOME/nohup.out and makes the
> program being run think there's a console attached.  Give that a whirl
> and see if it works for you.
I tried putting the above script directly in the usbcam script but it
still didn't make a difference. When I use 
su - jim -c "pythoncapture.py" &  
 I still get 3 versions of the python program running. Only 1 if it runs
as root. Very strange. I tried another short python test program and got
the same thing. When I start the camera using
 su - jim -c "python pythoncapture.py" & in /var/log/messages I get
this:
Sep 15 01:30:16 localhost su(pam_unix)[23477]: session opened for user
jim by (uid=0)
Sep 15 01:30:16 localhost su(pam_unix)[23495]: session opened for user
jim by (uid=0)
Sep 15 01:30:17 localhost su(pam_unix)[23516]: session opened for user
jim by (uid=0)

Anymore thoughts on this? Thanks.
Jim
> ----------------------------------------------------------------------
> - Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
> - VitalStream, Inc.                       http://www.vitalstream.com -
> -                                                                    -
> -     If Bill Gates got a dime for every time Windows crashes...     -
> -              ...oh, wait.  He does.  THAT explains it!             -
> ----------------------------------------------------------------------
> 




More information about the Redhat-install-list mailing list