#!/bin/sh

cd /home/user/REC

wday=`LANG=C date '+%u'`

if ( [ $wday -eq 6 -o $wday -eq 7 ] ); then 
        exit 0;
fi

URL=http://www.radiokaikan.jp/station/mp3

TODAY=`LANG=C date '+%Y-%m-%d-%H%M-RAD-STATION-%a'`
wday=`LANG=C date '+%a' | tr '[A-Z]' '[a-z]'`

wget   -q \
        --tries=13 \
        --retry-connrefused \
        --waitretry=4 \
        --timeout=10 \
        -O ${TODAY}.mp3 \
        ${URL}/${wday}-radio.mp3

gpg --options /home/user/.gnupg/opt.txt ${TODAY}.mp3
DB=/home/user/.gnupg/Sessionkeys.db
key=`gpg -o /dev/null --batch --show-session-key ${TODAY}.mp3.gpg 2>&1|
        perl -ne 'print $1 if (/gpg: session key:\s+.(\w+:\w+)/)'`
sleep 1;
sqlite3 $DB "insert into sKey values('${TODAY}.mp3.gpg', '$key');"

Update-crk.sh /home/user/REC/${TODAY}.mp3.gpg

FTP.sh ${TODAY}.mp3

rm -f ${TODAY}.mp3.gpg
exit 0;





