2006年 3月 3日 金曜日 16:35 30分 10ch test.mjp:x5v

*****************
#!/bin/sh
#created at 2006-02-28 Tue 23:59 by menat-cr.sh-1.1.7d.
#menat-cr.sh was executed on tampopo.karing.jp by apache for video server himawari.
#2006-03-03 Fri 16:35(13:59) - 17:05(16:50) 10ch test.mjp:x5v
#station: テレビ朝日
#program-title: 家政婦は見た!正義派弁護士おしどり夫婦に衝撃の秘密が…正当防衛,時効,指紋 二人の会話は謎だらけ…
#program-subtitle:
# 再放送 STEREO 文字多重
#市原悦子 蟹江敬三 高畑淳子 長門裕之 加藤武 寺田農

menat_user=yoshino
menat_host=192.168.45.7
vs_hn=himawari
exe_hn=tampopo.karing.jp
exe_time=200602282359

version=1.1.7d
exe_v=-1
LANG=C
org_id=1647;prs_id=1647;sr_id=0

auto_exe=0
cr_iepg=9
iepg_title="家政婦は見た!正義派弁護士おしどり夫婦に衝撃の秘密が…正当防衛,時効,指紋 二人の会話は謎だらけ…"
org_title="$iepg_title"
iepg_err=3;iepg_st=13:59;iepg_et=16:50
exe_end_ln=576
cr_end_ln=576

menat_h=/var/menat/himawari.karing.jp/menat
menat_h_t=$menat_h/tmp
ma_h=/var/menat/himawari.karing.jp/vfiles
ma_h_t=$ma_h/tmp

menat_sad=/var/menat/bin/menat-sad.sh
menat_cr=/var/menat/bin/menat-cr.sh
menat_bp=/var/menat/bin/menat-bp.sh
menat_mail=/var/menat/bin/menat-mail.sh
menat_progchk=/var/menat/bin/menat-progchk.sh
menat_midentify=/var/menat/bin/menat-midentify

menat_log=$menat_h_t/menat.log
menat_lock=$menat_h_t/lock.menat

name_f=/var/menat/himawari.karing.jp/vfiles/test.mjp
bfn=test.mjp
tm_f=$ma_h_t/$bfn

ch=10
pch=10ch
input_v=c
cap_dev=/dev/video0
normid=1
vcodec=mjpeg
acodec=pcm
cap_fps=29.971
amode=1
sz_v=":width=400:height=300"

opt1="x5v"
opt2=""
cmp_v="1"
cmp_lv=0
cmp_enc=mpeg4
mop1="-f mpeg4 -s 8";mop2="-e 1";mop3="-b 1600"
obp=0;cbp=0

time_s=200603031635 #TIME_START
time_epm=30
time_e=200603031705 #TIME_END
ma_file=$time_s.w.mtq

p_time_n=`date '+%Y-%m-%d %a %H:%M'`
time_nS=`date '+%Y%m%d%H%M%S'`
time_n=${time_nS%??}
time_eps=$(($time_epm*60))
cap_st_d="$p_time_n ${time_epm}分 $pch $bfn"

if [ "$1" = -c ];then

re_c=${2:-p_time_n}
ex_b=${0%.*.mtq};ex_bb=${ex_b##*/}
if [ `echo $2|grep -c '[$()\`]'` != 0 ];then
echo "invalid constant $2." >&2
echo "`id -un` tried to execute invalid constant $2." >>$menat_log
exit 1
elif [ "$ex_bb" != 200603031635 ];then
return 0
elif [ "$re_c" = iepg_dd ];then

if [ ${3:-0} = 1 ];then
dd_start=$(($cr_end_ln+1))
if [ $cmp_lv = 0 ];then
sed -n "$dd_start,\$"p $0|grep -v ^\$
else
dd_end=$(($cmp_lv-2))
sed -n "$dd_start,$dd_end"p $0
fi
elif [ ${3:-0} = 0 ]||[ ${3:-0} = 2 ];then

if [ ${cr_iepg:-0} -le 4 ];then
dd_end=4
else
dd_end=$cr_iepg
fi
sed -n "2,$dd_end"p $0

if [ ${3:-0} = 2 ];then
week_v_str="week=0 0"
echo "#org_id=$org_id:prs_id=$prs_id:sr_id=$sr_id; $week_v_str; iepg_err=$iepg_err; menat-cr.sh-1.1.7d"
fi
else
exit 1
fi

elif [ "$re_c" = cap_dd ];then
dd_start=$((9+$cr_end_ln+1))
dd_end=$((9+$cr_end_ln+3))
sed -n "$dd_start,$dd_end"p $0
elif [ "$re_c" = cmp_dd ];then

if [ ${cmp_lv:-0} -gt 0 ];then
sed -n "$cmp_lv,\$"p $0
fi
elif [ "$re_c" = cmp_dd_s ];then
exe_end_lv=$(($exe_end_ln+1))
sed -n "${exe_end_lv},\$"p $0
else
eval out_v='$'$re_c
echo $out_v
fi
exit 0
fi

if [ ! -f $menat_h/$ma_file ]&&[ ! -f $menat_h/$time_s.n.mtq ];then
echo >>$menat_log
echo "$cap_st_d:$opt1::removed just before capture." >>$menat_log
exit 0
fi

exe_tty=`tty 2>/dev/null`;tty_v=$?
exe_user=`id -un`
if [ $tty_v = 0 ];then
echo >>$menat_h_t/menat.log
echo "executed $ma_file from unexpected tty, $exe_tty." >>$menat_log
echo "executed $ma_file from unexpected tty, $exe_tty."
exit 1
elif [ $exe_user != menat ]&&[ $exe_user != root ];then
echo >>$menat_log
echo "executed $ma_file by unexpected user, $exe_user." >>$menat_log
exit 1
fi

if [ $time_n -lt 200603031632 ];then
echo >>$menat_log
echo "the time was not expired. $ma_file was not executed." >>$menat_log
exit 1

elif [ $time_n -ge 200603031705 ];then

echo >>$menat_log
if [ `grep -c ' menat_ends$' $menat_h/$ma_file` != 0 ];then
echo "retried to execute $ma_file, this job was discarded." >>$menat_log
exit 1
else
echo "the time was over. this job, $ma_file was discarded." >>$menat_log
time_out=1
if [ -f $menat_lock ];then
menat_lock_f=$menat_lock
elif [ -d $menat_lock ];then
menat_lock_f=$menat_lock/$bfn
else
mkdir $menat_lock
menat_lock_f=$menat_lock/$bfn
fi
echo "$p_time_n 30分 10ch $bfn:$opt1::time_out $ma_file" >>$menat_lock_f
fi
else

rm -f $menat_h_t/*.t.db*
rm -f $menat_h_t/db*prog*

if [ $time_n -gt 200603031635 ];then
time_n_s=`date '+%s'`
time_eps=$((1141373100-$time_n_s))
fi

echo >>$menat_log
echo "$cap_st_d:$opt1::start $time_s" >>$menat_log

if [ -f $menat_lock ];then
menat_lock_f=$menat_lock
elif [ -d $menat_lock ];then
menat_lock_f=$menat_lock/$bfn
else
mkdir $menat_lock
menat_lock_f=$menat_lock/$bfn
fi

echo "$cap_st_d:$opt1::start $time_s" >>$menat_lock_f
echo "test.mjp:400x300:mjpeg::29.971:pcm:30 200603031635.w.mtq" >>$menat_lock_f
echo "prs_id=`$menat_h/$ma_file -c prs_id`" >>$menat_lock_f &
if [ "$hw_cap" = 1 ];then
echo "hw_cap=1" >>$menat_lock_f
fi

if [ ! -f $ma_h/.htaccess ]&&[ -f $ma_h/.htaccess.off ];then
ln -fs $ma_h/.htaccess.off $ma_h/.htaccess;hta=$?
fi

men_r0_id=`ps auwx --width 512|grep "^menat .*mencoder "|grep -v " grep .*mencoder"`
if [ "$men_r0_id" ];then

men_r_id=`echo "$men_r0_id"|grep -v 'tv://'|tr -s " " " "|cut -d' ' -f2`
for t in $men_r_id ;do

/bin/kill -s STOP $t
echo "the process $t was stoped to capture $bfn." >>$menat_log
stv=1
done
fi

if [ -f $menat_h_t/end.lock.200603031635 ];then
echo $$ >>$menat_h_t/end.lock.200603031635
/bin/kill -s STOP $$
fi
touch $menat_h_t/end.lock.200603031705
fi


if [ "$time_out" != 1 ];then
v4lctl -c /dev/video0 setchannel 10
mencoder tv:// -tv driver=v4l2:device=$cap_dev:normid=$normid:amode=$amode:fps=$cap_fps:width=400:height=300 -ofps $cap_fps -ovc lavc -oac $acodec -lavcopts vcodec=$vcodec:autoaspect -o $tm_f -endpos $time_eps >/dev/null 2>&1;cap_v=$?
else
cap_v=125
fi

end_lock_id=`cat $menat_h_t/end.lock.200603031705 2>/dev/null`
mv -f $menat_h_t/end.lock.200603031705 $menat_h_t/end.lock;mv_v=$?
echo end.lock.200603031705 >>$menat_h_t/end.lock

if [ $mv_v != 0 ];then
rm -f $menat_h_t/end.lock.200603031705
fi

if [ "$end_lock_id" ];then

/bin/kill -s CONT $end_lock_id
echo "menat-cr.sh-1.1.7d: /bin/kill -s CONT $end_lock_id" >>$menat_log
for t in $end_lock_id ;do
ps awxu --width 512|grep " $t "|tr -s ' ' ' '|cut -d' ' -f11- >>$menat_log
done

nx_cap_on=1
if [ ${stv:-0} = 1 ];then
stv=0
echo "menat-cr.sh-1.1.7d: restart of $men_r_id was suspended for $end_lock_id." >>$menat_log
fi
else
nx_cap_on=0
fi

ep_YmdaHM=`date '+%Y-%m-%d %a %H:%M'`
time_re=`date '+%Y%m%d%H%M'`

rl_end_s=`date '+%s'`
rl_start_s=`date -d "$p_time_n" '+%s'`
rl_time_eps=$(($rl_end_s-$rl_start_s))

if [ "$stv" = 1 ];then

for t in $men_r_id ;do
/bin/kill -s CONT $t
echo "the process $t stopped to capture $bfn was re-started." >>$menat_log
echo "$men_r0_id"|grep " $t "|tr -s ' ' ' '|cut -d' ' -f11- >>$menat_log
done

fi

cmp_lock_ls=`ls -d $menat_h_t/lock.*`
echo "menat-cr.sh-1.1.7d:cmp_lock_ls=$cmp_lock_ls" >>$menat_log
if [ "$men_r_id" ];then

echo "menat-cr.sh-1.1.7d:test.mjp:stv=$stv:men_r_id=$men_r_id" >>$menat_log
for t2 in $cmp_lock_ls ;do

cmp_exe_v=`grep -c ^menat_cmp_id $t2`
echo "menat-cr.sh-1.1.7d:cmp_exe_v=\`grep -c ^menat_cmp_id $t2\`:$cmp_exe_v" >>$menat_log
if [ $t2 = $menat_lock_f ]||[ ${cmp_exe_v:-0} = 0 ];then

if [ -f $t2 ];then
cmp_w_ls="$cmp_w_ls $t2"
fi
continue
fi
echo "cap_time=$rl_time_eps:$bfn:$time_re" >>$t2

done
else
echo "menat-cr.sh-1.1.7d:test.mjp:stv=0:men_r_id=null" >>$menat_log
cmp_w_ls=$cmp_lock_ls
fi

if [ $nx_cap_on = 0 ];then

ex_stop_ls0=`ps auw --width 512|grep "^menat "|grep $cap_dev`
ex_stop_ls=`echo "$ex_stop_ls0"|tr -s ' ' ' '|cut -d' ' -f2,8|grep T|cut -d' ' -f1`
if [ "$ex_stop_ls" ];then

for t in $ex_stop_ls ;do
/bin/kill -s CONT $t
echo "the unknown stopped process $t was re-started." >>$menat_log
echo "$ex_stop_ls0"|grep " $t "|tr -s ' ' ' '|cut -d' ' -f11- >>$menat_log
done

fi
fi

if [ "$hta" = 0 ];then
rm -f $ma_h/.htaccess
fi

if [ "$time_out" != 1 ];then
echo >>$menat_h_t/menat.log
echo "$time_n - $time_re $time_e :: $pch:: $bfn:cap_v=$cap_v:end" >>$menat_log
echo "$time_n - $time_re $time_e :: $pch:: $bfn:cap_v=$cap_v:end" >>$menat_lock_f
fi

if [ "$time_out" = 1 ];then
cap_failed="capture_time_out "
ma_file_2=$time_s.t.mtq
elif [ $cap_v != 0 ];then
cap_failed="capture_failed "
ma_file_2=$time_s.f.mtq
else
ma_file_2=$time_s.s.mtq
fi
echo "$ep_YmdaHM capture of $bfn ${cap_failed}menat_ends" >>$menat_log

if [ -f $tm_f ];then

ma_ind=`ls -i "$tm_f"`;ma_ind=${ma_ind% *}
mf_ind=`ls -i "$menat_h/$ma_file"`;mf_ind=${mf_ind% *}
ma_user=`$menat_h/$ma_file -c menat_user`
ma_host=`$menat_h/$ma_file -c menat_host`

org_id=`$menat_h/$ma_file -c org_id`
prs_id=`$menat_h/$ma_file -c prs_id`
sr_id=`$menat_h/$ma_file -c sr_id`
ma_id="$org_id;$prs_id;$sr_id"

if [ -f $ma_h/$bfn ];then

while [ -f $ma_h/tmp$tn-$bfn ];do

if [ ! "$tn" ];then
tn=0
else
tn=$(($tn+1))
fi
done

name_f=$ma_h/tmp$tn-$bfn
mv -f $tm_f $ma_h/tmp$tn-$bfn
db_ma_sz=`du -m $ma_h/tmp$tn-$bfn 2>/dev/null |cut -f1`
echo "tmp$tn-$bfn:$ma_ind:$ma_file_2:$mf_ind:$ma_user:$ma_host:$ma_id:$db_ma_sz:$pch" >>$menat_h_t/ma_id.db
nc=1
else
mv -f $tm_f $ma_h
db_ma_sz=`du -m $ma_h/$bfn 2>/dev/null |cut -f1`
echo "$bfn:$ma_ind:$ma_file_2:$mf_ind:$ma_user:$ma_host:$ma_id:$db_ma_sz:$pch" >>$menat_h_t/ma_id.db

fi

echo "$bfn $ep_YmdaHM created for ${ma_user##*=}" >>$menat_h_t/ma_history
fi

f_sz=`du -m $name_f 2>/dev/null|cut -f1`
if [ "$f_sz" ];then
p_f_sz="${f_sz}MB:x5v:/dev/video0:cc_obp=0:cap_v=$cap_v"
else
p_f_sz="0MB(none):x5v:/dev/video0:cc_obp=0:cap_v=$cap_v"
fi

if [ "$time_out" = 1 ];then
ma_f_v="$bfn:::::: the time was over. this job was discarded."
else
ma_f_v=`$menat_midentify $name_f 2>&1`
fi

if [ -f "$menat_h/$ma_file" ];then

if [ "$nc" = 1 ];then
echo "#$bfn was changed to tmp$tn-$bfn." >>$menat_h/$ma_file
fi
echo "#$ma_f_v:$ma_file_2" >>$menat_h/$ma_file

time_s_Y=${time_s:0:4}
time_s_m=${time_s:4:2}
time_s_d=${time_s:6:2}

time_nS_Y=${time_nS:0:4}
time_nS_m=${time_nS:4:2}
time_nS_d=${time_nS:6:2}
time_nS_H=${time_nS:8:2}
time_nS_M=${time_nS:10:2}
time_nS_S=${time_nS:12:2}

if [ $time_s_Y = $time_nS_Y ]&&[ $time_s_m = $time_nS_m ]&&[ $time_s_d = $time_nS_d ];then
p_time_nS="$time_nS_H:$time_nS_M:$time_nS_S"
else
p_time_nS="$time_nS_Y-$time_nS_m-$time_nS_d $time_nS_H:$time_nS_M:$time_nS_S"
fi
echo "#options: none; $p_f_sz; $p_time_nS" >>$menat_h/$ma_file
echo "#$ep_YmdaHM $ma_file_2 ${cap_failed}menat_ends" >>$menat_h/$ma_file
echo >>$menat_h/$ma_file

else

mtq_sfE=`ls -d $menat_h_t/$time_s.[sfE]*.mtq 2>/dev/null`;ls_v=$?
if [ $ls_v = 0 ];then
for t in $mtq_sfE ;do
echo "#$ma_f_v $p_f_sz" >>$t
echo "#$ep_YmdaHM $ma_file_2 ${cap_failed}menat_ends" >>$t
echo >>$t
done
fi
fi

if [ `id -un` = menat ];then
chmod -f 664 $name_f >/dev/null 2>&1
fi


rm -f $menat_h_t/*.t.db*
rm -f $menat_h_t/db*prog*

if [ -f $name_f ];then

if [ "$opt1" ]&&[ ${cmp_v:-0} != 0 ];then
b_name_f=${name_f##*/};b_name_f=${b_name_f%.mjp}
echo tlong_m=$time_epm >$menat_h_t/lock.$b_name_f
echo cap_sol=400x300 >>$menat_h_t/lock.$b_name_f
mop3_v1=${mop3##*-b };echo vbitrate=${mop3_v1%%* } >>$menat_h_t/lock.$b_name_f
cap_mm_dd=`$menat_midentify $name_f`
echo "$cap_mm_dd:$ma_file_2" >>$menat_h_t/lock.$b_name_f
fi
fi

sad_n_time=$time_re
i=0
while [ $sad_n_time -lt $time_e ];do

i=$(($i+1))
if [ $i = 1 ];then

time_re_s=`date '+%s'`
ex_sleep=$((1141373100-$time_re_s))
if [ $cap_v != 0 ];then
echo "capture failed, go into sleep ${ex_sleep}s." >>$menat_log
else
echo "unexpected error occured, why cap_v is 0? go into sleep ${ex_sleep}s" >>$menat_log
fi
echo "ex_sleep=${ex_sleep}s" >>$menat_lock_f
fi

if [ -f $menat_h/$ma_file ];then
sleep 60s
sad_n_time=`date '+%Y%m%d%H%M'`
else
time_re_o=`date '+%s'`
sleep_out=$(($time_re_o-1141371300))
echo "sleep_out=${sleep_out}s" >>$menat_lock_f
break
fi
done

ed -s $menat_h/$ma_file >/dev/null 2>&1 <<EOF
/^exe_v=
s/_v=.*/_v=$cap_v/
w
q
EOF

echo "menat-cr.sh-1.1.7d: menat_sad started from $bfn." >>$menat_lock_f
echo "menat-cr.sh-1.1.7d: menat_sad started from $bfn." >>$menat_log
$menat_sad test.mjp:x5v menat-cr.sh-1.1.7d -l $ma_file
echo "menat-cr.sh-1.1.7d: menat_sad ended from $bfn." >>$menat_lock_f
echo "menat-cr.sh-1.1.7d: menat_sad ended from $bfn." >>$menat_log

if [ ! -f $menat_h_t/$ma_file_2 ];then

mail_fn_ls=`grep -H "^org_id=$org_id;prs_id=$prs_id;" $menat_h_t/*.mtq|grep -v ':0$'`
if [ "$mail_fn_ls" ];then

for t in $mail_fn_ls ;do
tt=${t%%:*}
ma_file_mail=${tt##*/}
break
done
else
ma_file_mail=$ma_file_2
fi
else
ma_file_mail=$ma_file_2
fi

echo "$menat_mail -vs himawari -a yoshino -v $cap_v -p 0 -i $ma_file_mail -n test.mjp" >>$menat_log
$menat_mail -vs himawari -a yoshino -v $cap_v -p 0 -i $ma_file_mail -n test.mjp

if [ -f $name_f ];then

if [ "$opt1" ]&&[ ${cmp_v:-0} != 0 ];then

bp_vv=`$menat_bp -N 1 -i $ma_file_2`;bp_v1=$?
/var/menat/bin/menat-cmp.sh -vs $vs_hn $name_f $mop1 $mop2 $mop3 -i $ma_file_2 &
echo >>$menat_log
echo "lock.$b_name_f was created at ${ep_YmdaHM}." >>$menat_log

elif [ "$obp" = 1 ]&&[ -x $menat_bp ];then
$menat_bp -a $menat_user -i $ma_file_2 $name_f;bp_v1=$?
fi
echo "menat-cr.sh-1.1.7d: bp=$bp_v1 and cmp ended." >>$menat_lock_f
else
$menat_bp -N 0 -i $ma_file_2
fi

if [ -f "$menat_lock_f" ]&&[ "$menat_lock_f" != /dev/null ];then

if [ "$time_out" = 1 ];then
echo "menat-cr.sh-1.1.7d: capture $bfn was time out at ${ep_YmdaHM}." >>$menat_log
else
echo "menat-cr.sh-1.1.7d: capture $bfn ended at ${ep_YmdaHM}." >>$menat_lock_f
fi

mv -f $menat_lock_f $menat_h_t/locK
on_cap=`ls $menat_lock 2>/dev/null`
if [ ! "$on_cap" ];then
echo "menat-cr.sh-1.1.7d: manat_lock_f was removed." >>$menat_log
rm -rf $menat_lock
else
echo "menat-cr.sh-1.1.7d: capture $bfn ended, and other capture is running." >>$menat_log
echo "now capturing, $on_cap." >>$menat_log
fi

else
echo "menat-cr.sh-1.1.7d: unknown error occured, capture $bfn ended." >>$menat_log
fi

for t in $cmp_w_ls ;do

if [ ! -f $t ];then
continue
fi
echo "cap_end_time=$time_re:$bfn" >>$t
done

for t in `ls $menat_h_t/end.lock.* 2>/dev/null` ;do

tt=${t##*/}
if [ ${tt##*.} -lt `date '+%Y%m%d%H%M'` ];then

echo "menat-cr.sh-1.1.7d: unknown error occured, maybe critical region was intruded." >>$menat_log
mv -f $t $menat_h_t/end.lock;mv_v=$?
if [ $mv_v = 0 ];then
echo "menat-cr.sh-1.1.7d: $tt was moved to end.lock." >>$menat_log
else
rm -f $t
echo "menat-cr.sh-1.1.7d: move of $tt was failed, $tt was removed." >>$menat_log
fi
fi
done
echo "menat-cr.sh-1.1.7d: capture $bfn ended at ${ep_YmdaHM}." >>$menat_log

exit 0 #maexe_file_end

#1647 2006-03-03 16:35 a menat menat_que_record
#2006-03-01 Wed 00:03 200603031635.n.mtq added in que.
#2006-03-03 Fri 16:35(13:59) - 17:05(16:50) 10ch test.mjp:x5v
#station: テレビ朝日
#program-title: 家政婦は見た!正義派弁護士おしどり夫婦に衝撃の秘密が…正当防衛,時効,指紋 二人の会話は謎だらけ…
#program-subtitle:
# 再放送 STEREO 文字多重
#市原悦子 蟹江敬三 高畑淳子 長門裕之 加藤武 寺田農
#org_id=1647:prs_id=1647:sr_id=0; week=0 0; iepg_err=3; menat-cr.sh-1.1.7d

*****************
2006年 3月 3日 金曜日 16:35 30分 10ch test.mjp:x5v この録画予約を取り消す

index.html  録画予約画面に戻る

menat-less.cgi-0.8.7-pre7 menat-0.5.9-5pe2 2006-02-28