#!/bin/bash # $1 = device number # $2 = product, e.g. 1e4e/110/201 # check if it is in envvars? #set > /tmp/x #ps -ef > /tmp/x2 echo "Invoked for $1"|logger -t $0 NUM=$1 #if something already hogs the device, most likely old half-dead daemon, KILL KILL KILL!!! /home/pi/scripts/webcam_server_kill.sh $NUM if [ "$2" == "-k" ]; then echo "Stopped self. Not starting."|logger -t $0 exit 0 fi #NUM=0 BASEPORT=5100 VIDEODEV=/dev/video$NUM VIDEOPORT=$(( $BASEPORT + $NUM )) WEBCAMCPU=3 MDIR=/usr/src/mjpg-streamer/mjpg-streamer-experimental if [ ! -c "$VIDEODEV" ]; then echo "Device '$VIDEODEV' not found, refusing to start server." exit 1 fi echo "Starting webcam server for cam '$NUM' on '$VIDEODEV'..."|logger -t $0 #bruteforce avoid the fucking kill script that the fucking systemd insists on running!!! sleep 3 cd $MDIR taskset -c $WEBCAMCPU $MDIR/mjpg_streamer -b -i "$MDIR/input_uvc.so -d $VIDEODEV" -o "$MDIR/output_http.so -w $MDIR/www -p $VIDEOPORT"