initiales Commit

This commit is contained in:
root 2012-03-29 12:04:41 +02:00
commit 8e06f35c51
1 changed files with 75 additions and 0 deletions

75
Dump.sh Executable file
View File

@ -0,0 +1,75 @@
#!/bin/bash
NAME=$1
SERVER_IP=192.168.1.66
PORT=8080
USERNAME=admin
PASSWORD="123456"
CAMERAS="0 1 2 3 4 5 6 7 8"
SECONDS_PER_FILE=5
PIDFILE_BASE=/tmp/wget_script.$RANDOM.pids
if [ -z "$NAME" ]; then
NAME=0
fi
quit() {
echo "quitting..."
PIDS="$(cat ${PIDFILE_BASE}_A 2>/dev/null) $(cat ${PIDFILE_BASE}_B 2>/dev/null)"
kill $PIDS 2>&1 >> /dev/null || (sleep 10; kill -9 $PIDS 2>&1 >> /dev/null)
rm ${PIDFILE_BASE}_A ${PIDFILE_BASE}_B 2>&1 >> /dev/null
exit $0
}
trap 'quit 0' SIGINT SIGTERM EXIT
do_record() {
for i in $CAMERAS; do
echo "starting recording for camera $i" >&2
(wget --ignore-length --http-user=$USERNAME --http-passwd=$PASSWORD http://${SERVER_IP}:$PORT/cam/$i/stream.mjpeg -O dump_cam${i}.mjpeg -q 2>&1 >> /dev/null) &
WGET_PIDS="$WGET_PIDS $!"
done
echo "$WGET_PIDS" > ${PIDFILE_BASE}_${1}
exit 0
}
while true; do
echo "starting group A"
echo "do_record"
do_record A &
echo 123
exit 0
PIDS_A="$(do_record)"
if [ ! -z "$PIDS_B" ]; then echo "killing group B"; kill $PIDS_B; fi
sleep $SECONDS_PER_FILE
echo "starting group B"
PIDS_B="$(do_record)"
if [ ! -z "$PIDS_A" ]; then echo "killing group A"; kill $PIDS_A; fi
sleep $SECONDS_PER_FILE
done
quit 1
wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/0/stream.mjpeg -O dump_cam0_$1.mjpeg &
wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/1/stream.mjpeg -O dump_cam1_$1.mjpeg &
wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/2/stream.mjpeg -O dump_cam2_$1.mjpeg &
wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/3/stream.mjpeg -O dump_cam3_$1.mjpeg &
wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/4/stream.mjpeg -O dump_cam4_$1.mjpeg &
wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/5/stream.mjpeg -O dump_cam5_$1.mjpeg &
wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/6/stream.mjpeg -O dump_cam6_$1.mjpeg &
#wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/7/stream.mjpeg -O dump_cam7_$1.mjpeg &
#wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/8/stream.mjpeg -O dump_cam8_$1.mjpeg &
#wget --ignore-length --http-user=admin --http-passwd=123456 http://192.168.1.66:8080/cam/9/stream.mjpeg -O dump_cam9_$1.mjpeg &
sleep 60
echo "#####
####################"
su
killall -s wget
exit
echo "Today is $(date)"
echo "done download"