Added wgetauto tool.

This commit is contained in:
Christian P. MOMON 2019-01-29 15:22:20 +01:00
parent 38df50b10b
commit 86ab18711d
2 changed files with 54 additions and 0 deletions

2
wgetauto/readme Normal file
View File

@ -0,0 +1,2 @@
Example of cron line:
25 15 * * 2 /home/cpm/Libreàvous/wgetauto 6300 /home/cpm/Libreàvous/ >> /home/cpm/Libreàvous/cronlog 2&>1

52
wgetauto/wgetauto Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
help()
{
echo "Usage: wgetauto [ -h | duration targetdirectory ]"
}
capture()
{
local duration="$1"
local targetDirectory="$2"
duration="$1"
targetDirectory="$2"
currentDate="$(date '+%Y-%m-%d-%Hh%M')"
echo "Capture launching…"
wget https://icecast.libre-a-toi.org:8444/voixdulat_ogg -o log -O "$targetDirectory/output-$currentDate" &
echo "Capture launched."
wgetpid="$!"
echo "wget PID=$wgetpid"
echo "$(ps auxwww|grep $wgetpid | grep -v grep)"
sleep "$duration"
echo "Kill attempting…"
kill -9 "$wgetpid"
echo "Kill done."
}
#
case $# in
1)
if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
help
else
capture "$1" "."
fi
;;
2) capture "$1" "$2"
;;
*) echo "Invalid parameter count."
help
;;
esac