#!/bin/sh #Create execute file for menat. # LANG=C version=1.2.1-pre2 cr_version=menat-cr.sh-$version user_h=/var/menat menat_sys_d=/etc/menat menat_bin=$user_h/bin exe_hn=`hostname` exe_hn=${exe_hn:-localhost} exe_hn2=${exe_hn%%.*} exe_YmdHM=`date '+%Y-%m-%d %a %H:%M'` exe_t12=`date '+%Y%m%d%H%M'` vs_ls=`cat $menat_sys_d/vs.list` cr_exe_user=`id -un` cr_exe_user=${cr_exe_user:-unknown} ############################################# ########## menat utility scripts ############ ############################################# menat_sad=$menat_bin/menat-sad.sh menat_cr=$menat_bin/menat-cr.sh menat_cmp=$menat_bin/menat-cmp.sh menat_midentify=$menat_bin/menat-midentify menat_bp=$menat_bin/menat-bp.sh menat_mail=$menat_bin/menat-mail.sh menat_progchk=$menat_bin/menat-progchk.sh ############################################# ############################################# n_ident() { if [ "$1" = 0 ];then dvn=0 dvn_v=0 else dvn=`expr "$1" + 0 2>&1`;dvn_v=$? fi if [ $dvn_v = 0 ];then ni_v=$1 while [ ${ni_v:0:1} = 0 ]&&[ ${#ni_v} != 1 ];do ni_v=${ni_v#0} if [ ${#ni_v} = 1 ];then break fi done echo $ni_v return 0 else echo ${2:-unknown} return $dvn_v fi } true_title() { new_title=${1#\[新\]};new_title=${new_title%\[新\]} new_title=${new_title#\(終\)};new_title=${new_title%\(終\)} re_title=${new_title#\[再\]};re_title=${re_title%\[再\]} echo $re_title return 0 } if [ -f $menat_sys_d/menat.conf ];then . $menat_sys_d/menat.conf fi if [ -f $menat_sys_d/capture.conf ];then . $menat_sys_d/capture.conf fi cap_vcodec=${cap_vcodec:-mjpeg} cap_acodec=${cap_acodec:-pcm} cap_fps=${cap_fps:-29.971} cap_dev=${cap_dev:-/dev/video0} cap_normid=${cap_normid:-1} cap_chanlist=${cap_chanlist:-japan-bcast} cap_amode=${cap_amode:-1} cap_outfmt=$cap_outfmt ma_ext=${ma_ext:-mjp} ############################################# ############################################# sz_v=":width=320:height=240" while [ "$1" ];do case $1 in "-t" ) shift mm=$1 dvn=`n_ident $1`;dvn_v=$? if [ $dvn_v = 0 ]&&[ ${#mm} = 12 ];then time_s=$1 else if [ ! "$1" ];then echo "time is not specified." >&2 else echo "$1 is invalid for time value." >&2 fi exit 1 fi shift ;; "-c" ) shift c_n=`n_ident "$1"`;dvn_v=$? if [ $dvn_v != 0 ];then c_n=0 fi if [ "$1" = v ]||[ "$1" = s ];then ma_ch=$1 elif [ $c_n -gt 0 ]&&[ $c_n -le 63 ];then ma_ch=$1 else if [ ! "$1" ];then echo "channel is not specified." >&2 else echo "$1 is invalid for channel value." >&2 fi exit 1 fi shift ;; "-e" ) shift dvn=`n_ident $1`;dvn_v=$? if [ $dvn_v = 0 ];then ma_time_epm=$1 tlong=$1 else if [ ! "$1" ];then echo "endpos is not specified." >&2 else echo "$1 is invalid for endpos value." >&2 fi exit 1 fi shift ;; "-o" ) shift if [ ! "$1" ];then echo "file name is not specified." >&2 exit 1 fi ma_name_f=$1 mf=${1##*/} bn_name_f=${mf%%:*} if [ ! "${1##*:*}" ];then opt0=${mf#*:} if [ "$opt0" ]&&[ "${opt0##*:*}" ];then opt1=$opt0 if [ "$opt1" = none ];then opt1="" elif [ ${#opt1} -gt 6 ]||[ ${#opt1} -lt 3 ];then echo "option 1 is must be 3-6 characters." >&2 exit 1 fi elif [ "$opt0" ]&&[ ! "${opt0##*:*}" ];then opt1=${opt0%%:*};opt2=${opt0##*:} if [ "$opt1" = none ];then opt1="" fi elif [ ! "${1#*:}" ];then opt1="" else echo "options are invalid.too many ':' is found." >&2 exit 1 fi ov1=${opt1:0:1} case "$ov1" in [xvwm] ) ov1_1=1 ;; [XVWM] ) ov1_1=1 ;hw_cap=1 ;; * ) ov1_1=0 ;; esac if [ $ov1_1 = 1 ]&&[ ${#opt1} = 3 -o ${#opt1} = 4 ];then if [ "$ov1" = x ]||[ "$ov1" = X ];then mpeg=mpeg4 elif [ "$ov1" = w ]||[ "$ov1" = W ];then mpeg=wmv2 elif [ "$ov1" = v ]||[ "$ov1" = V ];then mpeg=xvid else mpeg=mpeg2 fi mm2=${opt1:1:1} sz_v=":width=400:height=300";cmp_v=1 case "$mm2" in 0 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 7";obp="";mop2="";; 1 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 7";obp="";mop2="-e 1";; 2 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 7";obp="1";mop2="-e 2 ";; 3 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 7";obp="1";mop2="-e 3";; 4 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 8";obp="";mop2="";; 5 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 8";obp="";mop2="-e 1";; 6 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 8";obp="1";mop2="-e 2";; 7 ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 8";obp="1";mop2="-e 3";; 8 ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 7";obp="";mop2="";; 9 ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 7";obp="";mop2="-e 1";; a ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 7";obp="1";mop2="-e 2";; b ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 7";obp="1";mop2="-e 3";; c ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 8";obp="";mop2="";; d ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 8";obp="";mop2="-e 1";; e ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 8";obp="1";mop2="-e 2";; f ) sz_v=":width=640:height=480";mop1="-f $mpeg -s 8";obp="1";mop2="-e 3";; * ) sz_v=":width=400:height=300";mop1="-f $mpeg -s 7";obp="";mop2="";; esac cmp_enc=$mpeg mm3=${opt1:2:1} case "$mm3" in "e" ) mop3="-b 4800" ;; "s" ) mop3="-b 3600" ;; "u" ) mop3="-b 2400" ;; "v" ) mop3="-b 1600" ;; "d"|"h" ) mop3="-b 1200" ;; 0 ) mop3="-b 1000" ;; [1-9] ) br=$mm3"00" mop3="-b $br" ;; * ) mop3="" ;; esac mm4=${opt1:3:1} if [ "$mm4" ];then case $mm4 in [0-7] ) opt_cap_dev=/dev/video$mm4 ;; * ) opt_cap_dev=/dev/video0 ;; esac fi else ov1=${opt1:0:1} case "$ov1" in "-" ) mop1="" ; cmp_v=0 ;; "0" ) mop1="-f wmv2" ;cmp_enc=wmv2;cmp_v=1;; "1" ) mop1="-f wmv2 -s s1" ;cmp_enc=wmv2;cmp_v=1 ;; "2" ) mop1="-f wmv2 -s s2" ;cmp_enc=wmv2;cmp_v=1 ;; "3" ) mop1="-f wmv2 -s s3" ;cmp_enc=wmv2;cmp_v=1 ;; "4" ) mop1="-f wmv2 -s s4" ;cmp_enc=wmv2;cmp_v=1 ;; "5" ) mop1="-f wmv2 -s s5" ;cmp_enc=wmv2;cmp_v=1 ;; "6" ) mop1="-f wmv2 -s s6" ;cmp_enc=wmv2;cmp_v=1 ;; "7" ) mop1="-f wmv2 -s s7" ;cmp_enc=wmv2;cmp_v=1 ;; "8" ) mop1="-f wmv2 -s s8" ;cmp_enc=wmv2;cmp_v=1 ;; "z" ) mop1="-f mpeg4" ;cmp_enc=mpeg4; cmp_v=1 ;; "a" ) mop1="-f mpeg4 -s s1" ;cmp_enc=mpeg4; cmp_v=1 ;; "b" ) mop1="-f mpeg4 -s s2" ;cmp_enc=mpeg4; cmp_v=1 ;; "c" ) mop1="-f mpeg4 -s s3" ;cmp_enc=mpeg4; cmp_v=1 ;; "d" ) mop1="-f mpeg4 -s s4" ;cmp_enc=mpeg4; cmp_v=1 ;; "e" ) mop1="-f mpeg4 -s s5" ;cmp_enc=mpeg4; cmp_v=1 ;; "f" ) mop1="-f mpeg4 -s s6" ;cmp_enc=mpeg4; cmp_v=1 ;; "g" ) mop1="-f mpeg4 -s s7" ;cmp_enc=mpeg4; cmp_v=1 ;; "h" ) mop1="-f mpeg4 -s s8" ;cmp_enc=mpeg4; cmp_v=1 ;; "i" ) mop1="-f xvid" ;cmp_enc=xvid; cmp_v=1 ;; "j" ) mop1="-f xvid -s s1" ;cmp_enc=xvid; cmp_v=1 ;; "k" ) mop1="-f xvid -s s2" ;cmp_enc=xvid; cmp_v=1 ;; "l" ) mop1="-f xvid -s s3" ;cmp_enc=xvid; cmp_v=1 ;; "m" ) mop1="-f xvid -s s4" ;cmp_enc=xvid; cmp_v=1 ;; "n" ) mop1="-f xvid -s s5" ;cmp_enc=xvid; cmp_v=1 ;; "o" ) mop1="-f xvid -s s6" ;cmp_enc=xvid; cmp_v=1 ;; "p" ) mop1="-f xvid -s s7" ;cmp_enc=xvid; cmp_v=1 ;; "q" ) mop1="-f xvid -s s8" ;cmp_enc=xvid; cmp_v=1 ;; "Z" ) mop1="-f mpeg2" ;cmp_enc=mpeg2; cmp_v=1 ;; "A" ) mop1="-f mpeg2 -s s1" ;cmp_enc=mpeg2; cmp_v=1 ;; "B" ) mop1="-f mpeg2 -s s2" ;cmp_enc=mpeg2; cmp_v=1 ;; "C" ) mop1="-f mpeg2 -s s3" ;cmp_enc=mpeg2; cmp_v=1 ;; "D" ) mop1="-f mpeg2 -s s4" ;cmp_enc=mpeg2; cmp_v=1 ;; "E" ) mop1="-f mpeg2 -s s5" ;cmp_enc=mpeg2; cmp_v=1 ;; "F" ) mop1="-f mpeg2 -s s6" ;cmp_enc=mpeg2; cmp_v=1 ;; "G" ) mop1="-f mpeg2 -s s7" ;cmp_enc=mpeg2; cmp_v=1 ;; "H" ) mop1="-f mpeg2 -s s8" ;cmp_enc=mpeg2; cmp_v=1 ;; * ) mop1="" ;cmp_v=0 ;; esac ov2=${opt1:1:1} case "$ov2" in [0-9]|[a-f] ) mop2="-p $ov2";; * ) mop2="";; esac ov3=${opt1:2:1} case "$ov3" in "e" ) mop3="-b 4800" ;; "s" ) mop3="-b 3600" ;; "u" ) mop3="-b 2400" ;; "v" ) mop3="-b 1600" ;; "d"|"h" ) mop3="-b 1200" ;; 0 ) mop3="-b 1000" ;; [1-9] ) br=$ov3"00" mop3="-b $br" ;; * ) mop3="" ;; esac ov4=${opt1:3:1} case "$ov4" in "0" ) sz_v=":width=320:height=240";; "1" ) sz_v=":width=320:height=240 -vf lavcdeint";; "2" ) sz_v=":width=320:height=240 -vf pp=lb";; "3" ) sz_v=":width=320:height=240 -vf lavcdeint,pp=lb";; "4" ) sz_v=":width=400:height=300";; "5" ) sz_v=":width=400:height=300 -vf lavcdeint";; "6" ) sz_v=":width=400:height=300 -vf pp=lb";; "7" ) sz_v=":width=400:height=300 -vf lavcdeint,pp=lb";; "8" ) sz_v=":width=480:height=360";; "9" ) sz_v=":width=480:height=360 -vf lavcdeint";; "a" ) sz_v=":width=480:height=360 -vf pp=lb";; "b" ) sz_v=":width=480:height=360 -vf lavcdeint,pp=lb";; "c" ) sz_v=":width=640:height=480";; "d" ) sz_v=":width=640:height=480 -vf lavcdeint";; "e" ) sz_v=":width=640:height=480 -vf pp=lb";; "f" ) sz_v=":width=640:height=480 -vf lavcdeint,pp=lb";; "m" ) hw_cap=1; sz_v=":width=720:height=480";hw_dint=0;; "M" ) hw_cap=1; sz_v=":width=720:height=480";hw_dint=1;; "h" ) hw_cap=1; sz_v=":width=352:height=240";hw_dint=0;; "H" ) hw_cap=1; sz_v=":width=352:height=240";hw_dint=1;; "v" ) hw_cap=1; sz_v=":width=352:height=480";hw_dint=0;; "V" ) hw_cap=1; sz_v=":width=352:height=480";hw_dint=1;; "s" ) hw_cap=1; sz_v=":width=480:height=480";hw_dint=0;; "S" ) hw_cap=1; sz_v=":width=480:height=480";hw_dint=1;; "u" ) hw_cap=1; sz_v=":width=720:height=480";hw_dint=0;; "U" ) hw_cap=1; sz_v=":width=720:height=480";hw_dint=1;; * ) sz_v=":width=320:height=240";; esac ov5=${opt1:4:1} if [ "$ov5" ];then case "$ov5" in [1-9]|[a-f] ) mop2="$mop2 -p2 $ov5";; * ) mop2="$mop2";; esac fi ov6=${opt1:5:1} if [ "$ov6" ];then case "$ov6" in 0 ) cdn_1="0";cdn_0="0";obp="0";mop2="$mop2 -e 0";; 1 ) cdn_1="1";cdn_0="0";obp="0";mop2="$mop2 -e 0";; 2 ) cdn_1="0";cdn_0="1";obp="0";mop2="$mop2 -e 0";; 3 ) cdn_1="1";cdn_0="1";obp="0";mop2="$mop2 -e 0";; 4 ) cdn_1="0";cdn_0="0";obp="1";mop2="$mop2 -e 2";; 5 ) cdn_1="1";cdn_0="0";obp="1";mop2="$mop2 -e 2";; 6 ) cdn_1="0";cdn_0="1";obp="1";mop2="$mop2 -e 2";; 7 ) cdn_1="1";cdn_0="1";obp="1";mop2="$mop2 -e 2";; 8 ) cdn_1="0";cdn_0="0";obp="0";mop2="$mop2 -e 1";; 9 ) cdn_1="1";cdn_0="0";obp="0";mop2="$mop2 -e 1";; a ) cdn_1="0";cdn_0="1";obp="0";mop2="$mop2 -e 1";; b ) cdn_1="1";cdn_0="1";obp="0";mop2="$mop2 -e 1";; c ) cdn_1="0";cdn_0="0";obp="1";mop2="$mop2 -e 3";; d ) cdn_1="1";cdn_0="0";obp="1";mop2="$mop2 -e 3";; e ) cdn_1="0";cdn_0="1";obp="1";mop2="$mop2 -e 3";; f ) cdn_1="1";cdn_0="1";obp="1";mop2="$mop2 -e 3";; * ) cdn_1="0";cdn_0="0";obp="0";mop2="$mop2";; esac cap_dev_n=$(($cdn_1*2+$cdn_0)) opt_cap_dev=/dev/video$cap_dev_n fi fi fi shift ;; "-od" ) shift if [ -d "$1" ];then o_dir=$1 o_dir=${o_dir%/} elif [ ! "$1" ];then echo "output directory is not defined." >&2 exit 1 else echo "program file output directory,$1 is not found." >&2 exit 1 fi shift ;; "-vd" ) shift v_dir=$1 v_dir=${v_dir%/} shift ;; "-w" ) shift week=$1 shift ;; "-a" ) shift ma_user="menat_user=$1" ma_user_org=$1 ma_user_opt="-a $1" shift ;; "-h" ) shift ma_host="menat_host=$1" ma_host_opt="-h $1" shift ;; "-D" ) shift debug=1 ;; "-d2" ) shift debug=2 ;; "-vs" ) shift vs_hn=$1 shift ;; "-s" ) shift sil=1 auto_exe_v=1 ;; "-hw" ) shift f_hw_cap=1 hw_dev_n=$1 shift ;; "-I" ) shift ext_iepg=$1 shift ;; "-i" ) shift case "$1" in c|v|s ) input_v=$1 input_opt="-i $1" ;; * ) echo "menat-cr.sh-$version: $1 is invalid input value." >&2 exit 1 ;; esac shift ;; "-N" ) shift dvn=`n_ident $1`;dvn_v=$? if [ "$1" ]&&[ ! "${1##*:*}" ];then keep_sq=$1 keep_op_v=1 keep_org_id=${keep_sq%:*} keep_prs_id=${keep_sq#*:} elif [ $dvn_v = 0 ];then keep_sq=$1 else mx_f0_b=$1 fi shift ;; * ) if [ ! "$1" ];then echo "A value is not specified." >&2 else echo "$1 is not implemented." >&2 fi exit 1 ;; esac done vs_hn=${vs_hn:-$exe_hn2} if [ $vs_hn = test-cr ]&&[ ! "${vs_ls##*test-cr*}" ];then vs_hn=${exe_hn%%.*} menat_h=`pwd` menat_h_t=$menat_h/tmp ma_h=$menat_h/vfiles ma_h_t=$ma_h/tmp menat_iepg=$menat_h/iepg else for t in $vs_ls ;do menat_h=$user_h/$t/menat if [ ! -d $menat_h ];then echo "menat-cr.sh-$version: $menat_h is not found." >&2 exit 1 fi if [ ${t%%.*} != $vs_hn ];then continue fi vs_h=$user_h/$t vs_name=$t vs_hn=${t%%.*} menat_h_t=$menat_h/tmp ma_h=$vs_h/vfiles ma_h_t=$ma_h/tmp menat_iepg=$vs_h/iepg iepg_ch_ls=$menat_iepg/ch.list vs_hn_ok=0 break done fi if [ "$vs_hn_ok" != 0 ];then echo "menat-cr.sh-$version: $vs_hn or vs.list is invalid." >&2 exit 1 else if [ -w $menat_h_t/menat.log ];then menat_log=$menat_h_t/menat.log else menat_log=/dev/null fi fi if [ -f "$iepg_ch_ls" ];then ch_ls_ok=1 else ch_ls_ok=0 fi if [ "$sz_v" ]&&[ ! "${sz_v##*-vf *}" ];then cap_vf=${sz_v#*-vf } else cap_vf=none fi if [ ! "$time_s" ];then echo "Time value is not specified." >&2 exit 1 fi if [ ! "$ma_name_f" ];then ma_bfn_b=$time_s ma_bfn=$time_s.$ma_ext else ma_bfn=$bn_name_f ma_bfn_b0=${bn_name_f%.$ma_ext} if [ $ma_bfn_b0 = $ma_bfn ];then ma_bfn_b=$ma_bfn else ma_bfn_n=${ma_bfn_b0##*.} if [ $ma_bfn_n = $ma_bfn_b0 ];then ma_bfn_b=$ma_bfn_b0 else dvn=`n_ident $ma_bfn_n`;dvn_v=$? if [ $dvn_v = 0 ];then ma_bfn_b=${ma_bfn_b0%.*} else ma_bfn_b=$ma_bfn_b0 fi fi fi fi ma_name_f=$ma_h/$ma_bfn if [ ! "$ma_time_epm" ];then echo "time length value is not specified." >&2 exit 1 fi if [ ! "$ma_ch" ];then echo "channel value is not specified." >&2 exit 1 fi if [ "$o_dir" ];then menat_h=$o_dir menat_h_t=$menat_h/tmp fi if [ "$v_dir" ];then ma_h=$v_dir ma_h_t=$ma_h/tmp fi if [ ! "$ma_user" ];then ma_user="menat_user=$vs_hn" ma_user_org=$vs_hn ma_user_opt="-a $vs_hn" fi cmp_v=${cmp_v:-0} if [ "$hw_cap" = 1 ];then cr_hw_cap=" hw_cap=1" fi cr_menat_lock="\$menat_h_t/lock.menat" or_Ymd=${time_s:0:8} or_H=${time_s:8:2} or_M=${time_s:10:2} p_st_HM=$or_H:$or_M p_st_YmdaHM=`date -d "$or_Ymd $or_H:$or_M" '+%Y-%m-%d %a %H:%M'` ma_time_s_s=`date -d "$or_Ymd $or_H:$or_M" '+%s'` time_sE=`date -d "$or_Ymd $or_H:$or_M 3minute ago" '+%Y%m%d%H%M'` time_eps=$(($ma_time_epm*60)) ma_time_e=`date -d "${ma_time_epm}minute $or_Ymd $or_H:$or_M" '+%Y%m%d%H%M'` ma_time_e_s=`date -d "${ma_time_epm}minute $or_Ymd $or_H:$or_M" '+%s'` p_et_HM=`date -d "${ma_time_epm}minute $or_Ymd $or_H:$or_M" '+%H:%M'` if [ $or_Ymd != ${ma_time_e:0:8} ];then p_et_HM="翌 $p_et_HM" fi if [ "$mx_f0_b" ];then if [ -f $menat_h/$mx_f0_b ];then mx_f0=$menat_h/$mx_f0_b elif [ -f $menat_h_t/$mx_f0_b ];then mx_f0=$menat_h_t/$mx_f0_b else echo "$menat_cr: $mx_f0_b, such file is not found." >&2 exit 1 fi keep_org_id=1 auto_exe_old=`$mx_f0 -c auto_exe` auto_exe_old=${auto_exe_old:-0} elif [ "$keep_op_v" = 1 ];then keep_ap=`grep -Hc "^org_id=$keep_org_id;prs_id=$keep_prs_id;sr_id=" $menat_h_t/*mtq|grep ':1$'` if [ "$keep_ap" ];then for t in $keep_ap ;do mx_f0=${t%:*} mx_f0_b=${mx_f0##*/} break done else keep_ap2=`grep -Hc "^org_id=$keep_org_id;prs_id=$keep_prs_id;sr_id=" $menat_h/*mtq|grep ':1$'` if [ "$keep_ap2" ];then for t in $keep_ap2 ;do mx_f0=${t%:*} mx_f0_b=${mx_f0##*/} break done fi fi if [ ! "$mx_f0" ];then echo "$menat_cr: $keep_org_id:$keep_prs_id, such id does not exist." >&2 exit 1 fi fi ##### for ff in `ls -d $menat_h/*.mtq` ;do n=1 ma_nn=${ff##*/} if [ -d $ff ]||[ ${#ma_nn} != 12 ]||[ `id -un` = "apache" ];then continue fi dvn=`n_ident $ma_nn`;dvn_v=$? mm_t_e=`grep TIME_END $ff|cut -d"=" -f2|cut -d" " -f1` if [ $dvn_v != 0 ]||[ ! "$mm_t_e" ];then continue else if [ $time_s = $mm_t_e ]||[ $ma_time_e = $ma_nn ];then continue elif [ $time_s '>' $mm_t_e ]||[ $ma_time_e '<' $ma_nn ];then continue else echo This program is batting to other one. echo Next start is $ma_nn,the end time is $mm_t_e. echo "Are you continue? [y/n]" read pp case $pp in "YES"|"yes"|"y"|"Y" ) continue ;; * ) echo Aborted. exit 1 ;; esac fi fi done if [ ${cap_dev_n:-0} != 0 ];then cdn_rc=".$cap_dev_n" else cdn_rc="" fi menat_rc1=$vs_h/.menatrc$cdn_rc menat_rc2=/home/$ma_user_org/.menatrc$cdn_rc menat_rc3=$vs_h/.menatrc$cdn_rc.$time_s menat_rc4=/home/$ma_user_org/.menatrc$cdn_rc.$time_s if [ -f $menat_rc1 ];then . $menat_rc1 fi if [ -f $menat_rc2 ]||[ -f $menat_rc3 ]||[ -f $menat_rc4 ];then for t in $menat_rc2 $menat_rc3 $menat_rc4 ;do if [ -f $t ];then echo "$cr_version: found $t for $ma_user_org at $time_s." >>$menat_log hw_cap_u=`. $t;echo $hw_cap` cap_vcodec_u=`. $t;echo $cap_vcodec` cap_acodec_u=`. $t;echo $cap_acodec` cap_fps_u=`. $t;echo $cap_fps` cap_dev_u=`. $t;echo $cap_dev` cap_normid_u=`. $t;echo $cap_normid` cap_amode_u=`. $t;echo $cap_amode` cap_outfmt_u=`. $t;echo $cap_outfmt` else continue fi done hw_cap=${hw_cap_u:-$hw_cap} cap_vcodec=${cap_vcodec_u:-$cap_vcodec} cap_acodec=${cap_acodec_u:-$cap_acodec} cap_fps=${cap_fps_u:-$cap_fps} cap_dev=${cap_dev_u:-$cap_dev} cap_normid=${cap_normid_u:-$cap_normid} cap_amode=${cap_amode_u:-$cap_amode} cap_outfmt=${cap_outfmt_u:-$cap_outfmt} if [ "$ov4" ]&&[ ! "$hw_dint" ]&&[ "$hw_cap" = 1 ];then hw_cap=0 fi if [ "$hw_cap" = 1 ];then opt2=h mop2="$mop2 -h" fi if [ "$cap_vcodec_u" ];then echo "$cr_version: cap_vcodec was specified to ${cap_vcodec_u}." >>$menat_log if [ "$debug" ];then echo "cap_vcodec was specified to ${cap_vcodec_u}." fi fi if [ "$cap_acodec_u" ];then echo "$cr_version: cap_acodec was specified to ${cap_acodec_u}." >>$menat_log if [ "$debug" ];then echo "cap_acodec was specified to ${cap_acodec_u}." fi fi if [ "$cap_fps_u" ];then echo "$cr_version: cap_fps was specified to ${cap_fps_u}." >>$menat_log if [ "$debug" ];then echo "cap_fps was specified to ${cap_fps_u}." fi fi if [ "$opt_cap_dev" ];then cap_dev=$opt_cap_dev if [ "$cap_dev_u" ];then echo -n "$cr_version: cap_dev was specified to ${cap_dev_u} in config file, " >>$menat_log echo "but ignored for cmmand line option." >>$menat_log if [ "$debug" ];then echo "cap_dev was specified to ${cap_dev_u}." fi fi else if [ "$cap_dev_u" ];then echo "$cr_version: cap_dev was specified to ${cap_dev_u}." >>$menat_log if [ "$debug" ];then echo "cap_dev was specified to ${cap_dev_u}." fi fi fi if [ "$cap_normid_u" ];then echo "$cr_version: cap_normid was specified to ${cap_normid_u}." >>$menat_log if [ "$debug" ];then echo "cap_normid was specified to ${cap_normid_u}." fi fi if [ "$cap_amode_u" ];then echo "$cr_version: cap_amode was specified to ${cap_amode_u}." >>$menat_log if [ "$debug" ];then echo "cap_amode was specified to ${cap_amode_u}." fi fi if [ "$cap_outfmt_u" ];then outfmt_ls=`mencoder -tv outfmt=help 2>/dev/null|grep ^Ava` ofmt_v1=`echo "$outfmt_ls"|grep -c " $cap_outfmt_u "` ofmt_v2=`echo "$outfmt_ls"|grep -c " $cap_outfmt_u\$"` if [ $ofmt_v1 = 1 ]||[ $ofmt_v2 = 1 ];then echo "$cr_version: cap_outfmt was specified to ${cap_outfmt_u}." >>$menat_log if [ "$debug" ];then echo "cap_outfmt was specified to ${cap_outfmt_u}." fi else echo "$cr_version: ${cap_outfmt_u} is unsupported by v4l2." >>$menat_log echo "${cap_outfmt_u} is unsupported by v4l2." >&2 exit 1 fi fi fi if [ "$opt1" ];then r_opt1=":$opt1" if [ $opt1 = none ];then opt1="" fi else r_opt1=":none" fi sz_v0=${sz_v%% *} psz1=${sz_v0#*=};psz1=${psz1%%:*} psz2=${sz_v0##*=} psz=$psz1'x'$psz2 if [ "$hw_cap" = 1 ]||[ "$f_hw_cap" = 1 ];then hw_cap=1 cr_hw_cap=" hw_cap=1" if [ "$f_hw_cap" = 1 ];then case "$hw_dev_n" in [1-3] ) cap_dev=/dev/video$hw_dev_n ;; * ) cap_dev=/dev/video0 ;; esac fi if [ "$hw_dint" ];then hwc_rsl="--width $psz1 --height $psz2" fi else hw_cap=0 fi if [ "$obp" = 1 ];then if [ "$cmp_v" = 1 ];then cap_obp=2 cmp_obp=1 else cap_obp=1 cmp_obp=0 fi else cap_obp=0 cmp_obp=0 fi if [ ${cmp_v:-0} = 1 ];then if [ "${cmp_enc:0:3}" = wmv ];then cmp_bfn=${ma_bfn%.$ma_ext}.wmv else cmp_bfn=${ma_bfn%.$ma_ext}.mpg fi fi if [ "$debug" = 1 ]||[ "$debug" = 2 ];then echo " set time at $time_s. $ma_time_epm minutes. end time is set at $ma_time_e. file name is $ma_name_f channel is set to $ma_ch. opt1=$opt1 opt2=$opt2 cmp_bfn=$cmp_bfn mop1=\"$mop1\";mop2=\"$mop2\";mop3=\"$mop3\" vs_hn=$vs_hn vs_name=$vs_name cap_sol=$psz " fi if [ "$debug" = 1 ];then echo "debug mode 1 ended." exit 0 fi case "${cap_dev#/dev/video}" in [1-3] ) cap_dev_n=${cap_dev#/dev/video} ;; * ) cap_dev_n="" ;; esac t_n=$$ tmp_ma_file=$menat_h_t/.$time_s.${t_n}$cap_dev_n.mtq echo >>$menat_log echo "$cr_version: $time_s.n$cap_dev_n.mtq was created at $exe_YmdHM by `id -un`." >>$menat_log if [ ${week:-0} != 0 ];then case $week in w ) wd_v=7;wdp_v="wd_v=7";; d ) wd_v=1;wdp_v="wd_v=1";; p ) wd_v=1;pp_v=1;; * ) wd_v=1;; esac wv_t=${week#*=} week="week=$week" b0_name_f=${ma_bfn%.$ma_ext};b1_name_f=${b0_name_f%.*} if [ "$b0_name_f" = "$b1_name_f" ]||[ "$ma_bfn" = "$b0_name_f" ];then nw_f_name=$b0_name_f.01.$ma_ext else b2_name_f=${b0_name_f##*.};b2_n=${#b2_name_f} if [ "$b2_name_f" = -1 ];then nf_n=0 dvn_v=0 else nf_n=`expr "$b2_name_f" + 1`;dvn_v=$? fi if [ $dvn_v = 0 ];then while [ ${#nf_n} -lt $b2_n ];do nf_n=0$nf_n done nw_f_name=$b1_name_f.$nf_n.$ma_ext else nw_f_name=$b0_name_f.01.$ma_ext fi fi st_Ymd=${time_s:0:8};st_HM=${time_s:8:4} if [ "$pp_v" = 1 ];then wwv=`date -d "$st_Ymd" '+%w'` case $wwv in [0-4] ) wd_v=1;; 5 ) wd_v=3;; 6 ) wd_v=2;; esac fi nw_Ymd=`date -d "+${wd_v}day $st_Ymd" '+%Y%m%d'` nw_time_s=$nw_Ymd$st_HM week_ex=" if [ \"\$week\" ]&&[ \"\$week\" != 0 ];then i=0 while [ -f \$menat_h_t/cr_lock ];do cr_lock_ts=\`grep ^cr_lock_t= \$menat_h_t/cr_lock|tail -n1|cut -d'=' -f2\` if [ \$i -gt 18 ]||[ \`date '+%s'\` -gt \$((\${cr_lock_ts:-0}+180)) ];then break fi sleep 10s if [ \"\$cr_lock_ts_old\" ];then if [ \$cr_lock_ts_old = \$cr_lock_ts ];then i=\$((\$i+1)) else cr_lock_ts_old=\$cr_lock_ts i=0 fi else cr_lock_ts_old=\$cr_lock_ts i=\$((\$i+1)) fi done if [ ! -f \"\$menat_lock_f\" ];then menat_lock_f=/dev/null fi cp -f \$menat_lock_f \$menat_h_t/cr_lock echo cr_lock_id=\$ma_file_2 >>\$menat_h_t/cr_lock echo cr_lock_t=\`date '+%s'\` >>\$menat_h_t/cr_lock \$menat_cr -s -t $nw_time_s -e $ma_time_epm -c $ma_ch -o $nw_f_name$r_opt1 -w $wv_t $ma_user_opt $ma_host_opt -od $menat_h -vd $ma_h -vs $vs_hn -N \$ma_file $input_opt mv -f \$menat_h_t/cr_lock \$menat_h_t/cr_lock.pp fi" else week="week=0" fi if [ "$ma_ch" = v ];then v4lopt=setinput hwc_in=${hwc_iv_rc:-0} ma_ch=Composite1 men_v4l="${men_v4l}:input=${cr_v_input:-1}" ma_pch=$ma_ch v4l_ch=Composite1 elif [ "$ma_ch" = s ];then v4lopt=setinput hwc_in=${hwc_is_rc:-6} ma_ch=S-Video men_v4l="${men_v4l}:input=${cr_s_input:-2}" ma_pch=$ma_ch v4l_ch=S-Video else if [ ${input_v:-0} = v ];then v4lopt=setinput hwc_in=${hwc_iv_rc:-0} men_v4l="${men_v4l}:input=${cr_v_input:-1}" ma_pch=${ma_ch}v v4l_ch=Composite1 elif [ ${input_v:-0} = s ];then v4lopt=setinput hwc_in=${hwc_is_rc:-6} men_v4l="${men_v4l}:input=${cr_s_input:-2}" ma_pch=${ma_ch}s v4l_ch=S-Video else v4lopt=setchannel hwc_in=${hwc_ic_rc:-4} ma_pch=${ma_ch}ch v4l_ch=$ma_ch if [ "$cr_c_input" ];then men_v4l="${men_v4l}:input=$cr_c_input" fi fi fi if [ "$cap_outfmt" ];then men_v4l="${men_v4l}:outfmt=$cap_outfmt" fi if [ $hw_cap = 1 ];then cap_vf="ハードウェア" fi tm_f_bn=${ma_name_f##*/} tm_f=$ma_h_t/$tm_f_bn if [ `id -un` = menat ];then echo -n >$tmp_ma_file chmod -f 775 $tmp_ma_file else if [ `id -un` = root ];then /bin/su - menat -c "echo -n >$tmp_ma_file" /bin/su - menat -c "chmod -f 775 $tmp_ma_file" elif [ `groups|grep -c menat` != 0 ];then echo -n >$tmp_ma_file chgrp -f menat $tmp_ma_file chmod -f 775 $tmp_ma_file else echo -n >$tmp_ma_file chmod -f 777 $tmp_ma_file fi fi auto_exe_old=${auto_exe_old:-0} if [ ${auto_exe_v:-0} != 1 ];then auto_exe=0 p_auto_exe="" if [ $exe_hn = $vs_name ];then echo "#!/bin/sh #created at $exe_YmdHM by menat-cr.sh-$version. #menat-cr.sh was executed by $cr_exe_user on video server $vs_hn." >>$tmp_ma_file p_exe_hn='$vs_hn' else echo "#!/bin/sh #created at $exe_YmdHM by menat-cr.sh-$version. #menat-cr.sh was executed on $exe_hn by $cr_exe_user for video server $vs_hn." >>$tmp_ma_file p_exe_hn=$exe_hn fi else auto_exe=$(($auto_exe_old+1)) p_exe_hn='$vs_hn' p_auto_exe=" auto" if [ "$keep_sq" = 0 ];then auto_exe_user="menat-progchk.sh" else auto_exe_user="$cr_exe_user" fi echo "#!/bin/sh #created at $exe_YmdHM by menat-cr.sh-$version. #menat-cr.sh was executed automatically by $auto_exe_user for video server $vs_hn." >>$tmp_ma_file fi if [ "$ext_iepg" ];then iepg_org_info=`cat $ext_iepg`;iepg_v=$? else if [ $ch_ls_ok = 1 ];then iepg_org_info=`$menat_progchk -v $vs_hn -i $time_s -c $ma_ch`;iepg_v1=$? else iepg_v1=125 fi if [ $iepg_v1 != 125 ]&&[ $iepg_v1 != 0 ];then iepg_org_info_e1=`$menat_progchk -v $vs_hn -i $time_s -c $ma_ch -N`;iepg_v2=$? if [ $iepg_v2 = 0 ];then iepg_Y_e1=`echo "$iepg_org_info_e1"|grep ^year:|cut -d' ' -f2` iepg_m_e1=`echo "$iepg_org_info_e1"|grep ^month:|cut -d' ' -f2` iepg_d_e1=`echo "$iepg_org_info_e1"|grep ^date:|cut -d' ' -f2` iepg_psHM_e1=`echo "$iepg_org_info_e1"|grep ^start:|cut -d' ' -f2` iepg_peHM_e1=`echo "$iepg_org_info_e1"|grep ^end:|cut -d' ' -f2` iepg_sHM_e1=`echo $iepg_psHM_e1|sed 's/://'` iepg_eHM_e1=`echo $iepg_peHM_e1|sed 's/://'` iepg_sYmd_e1=$iepg_Y_e1$iepg_m_e1$iepg_d_e1 iepg_sYmdHM_e1=$iepg_Y_e1$iepg_m_e1$iepg_d_e1$iepg_sHM_e1 iepg_psYmdHM_e1="$iepg_Y_e1-$iepg_m_e1-$iepg_d_e1 $iepg_psHM_e1" if [ $iepg_sYmdHM_e1 '<' $ma_time_e ];then iepg_org_info=$iepg_org_info_e1 iepg_v=0 else iepg_v=125 fi else iepg_v=125 fi else iepg_v=${iepg_v1} fi fi if [ $iepg_v = 0 ];then iepg_tail1=`echo "$iepg_org_info"|grep -v ': '|tail -n1` iepg_stn=`echo "$iepg_org_info"|grep ^station:` iepg_ttl=`echo "$iepg_org_info"|grep ^program-title:` cr_iepg_ttl=${iepg_ttl#program-title: } iepg_st=`echo "$iepg_org_info"|grep ^start:|cut -d' ' -f2` iepg_et=`echo "$iepg_org_info"|grep ^end:|cut -d' ' -f2` iepg_sb_ttl=`echo "$iepg_org_info"|grep ^program-subtitle:` iepg_ext=`echo "$iepg_org_info"|grep ^Extend:` iepg_ext_v=`echo "$iepg_org_info"|grep ^Extend:|cut -d' ' -f2` iepg_opt_str=`echo "$iepg_tail1"|sed 's/」/」 /g;s/「/ 「/g;s/(終)/ (終) /g'` iepg_dsp=`echo "$iepg_org_info"|grep ^description:` iepg_pfm=`echo "$iepg_org_info"|grep ^performer:` if [ "$iepg_st" != ${p_st_HM#* } ];then p_st_YmdaHM="$p_st_YmdaHM($iepg_st)" iepg_err_st=1 else iepg_err_st=0 fi iepg_st_H=${iepg_st:0:2} iepg_st_M=${iepg_st:3:2} iepg_et_H=${iepg_et:0:2} iepg_et_M=${iepg_et:3:2} if [ 1$iepg_st_H$iepg_st_M '<' 1$iepg_et_H$iepg_et_M ];then iepg_et_Ymd=$or_Ymd elif [ 1$iepg_st_H$iepg_st_M = 1$iepg_et_H$iepg_et_M ];then iepg_et_Ymd=$or_Ymd else iepg_et_Ymd=`date -d "1day $or_Ymd" '+%Y%m%d'` fi iepg_et_YmdHM=$iepg_et_Ymd$iepg_et_H$iepg_et_M p_iepg_et_YmdHM="$iepg_et_Ymd $iepg_et_H:$iepg_et_M" if [ "$iepg_et" != ${p_et_HM#* } ];then echo "#$p_st_YmdaHM - $p_et_HM($iepg_et) ${ma_ch}ch ${ma_name_f##*/}$r_opt1" >>$tmp_ma_file iepg_err_et=2 else echo "#$p_st_YmdaHM - $p_et_HM ${ma_ch}ch ${ma_name_f##*/}$r_opt1" >>$tmp_ma_file iepg_err_et=0 fi for t in $iepg_opt_str ;do case $t in 「S」 ) iepg_opt="$iepg_opt STEREO" ;; 「字」 ) iepg_opt="$iepg_opt 文字多重" ;; 「E」 ) iepg_opt="$iepg_opt 二ヵ国語" ;; 「再」 ) iepg_opt="$iepg_opt 再放送" ;; 「N」 ) iepg_opt="$iepg_opt NEWS" ;; 「多」 ) iepg_opt="$iepg_opt 音声多重" ;; 「新」 ) iepg_opt="$iepg_opt 新番組" ;; 「天」 ) iepg_opt="$iepg_opt 天気予報" ;; (終) | 「終」 ) iepg_opt="$iepg_opt 最終回" ;; * ) ext_str_fin="$ext_str_fin $t" ;; esac done iepg_ln=${iepg_ln:-80} echo "#$iepg_stn #$iepg_ttl" >>$tmp_ma_file if [ "$iepg_sb_ttl" ];then echo "$iepg_sb_ttl" |nkf -ef$iepg_ln |sed 's/^/#/' >>$tmp_ma_file fi if [ ${iepg_ext_v:-0} != 0 ];then echo "#$iepg_ext" >>$tmp_ma_file iepg_ext_YmdHM=`date -d "${iepg_ext_v}minutes $p_iepg_et_YmdHM" '+%Y%m%d%H%M'` if [ $iepg_ext_YmdHM != $ma_time_e ];then iepg_err_ext=8 else if [ $iepg_err_st = 0 ];then iepg_err_et=0 iepg_err_ext=0 else iepg_err_ext=8 fi fi iepg_ext_p="iepg_ext=$iepg_ext_v " else iepg_err_ext=0 fi if [ "$iepg_dsp" ];then echo "$iepg_dsp" |nkf -ef$iepg_ln |sed 's/^/#/' >>$tmp_ma_file fi if [ "$iepg_pfm" ];then echo "$iepg_pfm" |nkf -ef$iepg_ln |sed 's/^/#/' >>$tmp_ma_file fi if [ "$iepg_opt" ];then echo "#$iepg_opt" >>$tmp_ma_file fi if [ "$iepg_tail1" ]&&[ "$ext_str_fin" ];then echo "${ext_str_fin# }" |nkf -ef$iepg_ln |sed 's/^/#/' >>$tmp_ma_file fi cr_iepg=`grep -c "^#" $tmp_ma_file` else if [ -f $iepg_ch_ls ];then st_char=`grep " ch${ma_ch} " $iepg_ch_ls|head -n1|cut -d' ' -f1` if [ "$st_char" ];then st_char="$st_char " fi fi echo "#$p_st_YmdaHM - $p_et_HM $st_char${ma_pch} ${ma_name_f##*/}$r_opt1" >>$tmp_ma_file cr_iepg=0 iepg_err_st=0 iepg_err_et=0 iepg_err_ext=0 fi if [ "$keep_sq" = 0 ];then f0_ls2=`grep -Hc "^bfn=$ma_bfn_b\." $menat_h_t/*.mtq|grep -v ':0$'` for t in $f0_ls2 ;do f0=${t%:*} f0_b=${f0##*/} f0_b12=${f0_b%.*.mtq} if [ $f0_b = $f0_b12 ]||[ ${#f0_b12} != 12 ];then continue fi week_mx_f0=`$f0 -c week` if [ `$f0 -c exe_v` -lt 0 ]||[ ${week_mx_f0:-0} = 0 ];then continue fi if [ ! "$mx_f0_b12" ];then mx_f0_b12=$f0_b12 mx_f0=$f0 else if [ $f0_b12 '>' $mx_f0_b12 ];then mx_f0_b12=$f0_b12 mx_f0=$f0 fi fi done fi if [ ${cmp_v:-0} = 1 ];then cmp_enc_v=" cmp_enc=$cmp_enc" fi if [ ${cr_iepg:-0} = 0 ];then cr_iepg_r=4 else cr_iepg_r=$cr_iepg fi echo " $ma_user $ma_host vs_hn=$vs_hn exe_hn=$p_exe_hn exe_time=$exe_t12 version=$version exe_v=-2 LANG=C org_id=$org_id;prs_id=$prs_id;sr_id=0 $week auto_exe=$auto_exe cr_iepg=$cr_iepg iepg_title=\"$cr_iepg_ttl\" org_title= iepg_err= ${iepg_ext_p}exe_end_ln= cr_end_ln= menat_h=$menat_h menat_h_t=\$menat_h/tmp ma_h=$ma_h ma_h_t=\$ma_h/tmp menat_sad=$menat_sad menat_cr=$menat_cr menat_bp=$menat_bp menat_mail=$menat_mail menat_progchk=$menat_progchk menat_midentify=$menat_midentify menat_log=\$menat_h_t/menat.log menat_lock=$cr_menat_lock name_f=$ma_name_f bfn=$ma_bfn tm_f=\$ma_h_t/\$bfn ch=$ma_ch pch=$ma_pch input_v=${input_v:-c} cap_dev=$cap_dev normid=$cap_normid chanlist=$cap_chanlist vcodec=$cap_vcodec acodec=$cap_acodec cap_fps=$cap_fps amode=$cap_amode$cr_hw_cap sz_v=\"$sz_v\" opt1=\"$opt1\" opt2=\"$opt2\" cmp_v=\"$cmp_v\" cmp_bfn=$cmp_bfn cmp_lv=0$cmp_enc_v mop1=\"$mop1\";mop2=\"$mop2\";mop3=\"$mop3\" obp=${obp:-0};cbp=${cbp:-0} time_s=$time_s #TIME_START time_epm=$ma_time_epm time_e=$ma_time_e #TIME_END ma_file=\$time_s.w$cap_dev_n.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\" #external_exe_start if [ \"\$1\" = -c ];then re_c=\${2:-p_time_n} ex_b=\${0%.*.mtq};ex_bb=\${ex_b##*/} exm_opt=\${2##*\\(*};exm_opt=\${exm_opt##*\\\`*};exm_opt=\${exm_opt##*\\\$*} if [ \"\$2\" ]&&[ ! \"\$exm_opt\" ];then echo \"invalid constant \$2.\" >&2 echo \"cr-$ma_bfn: \`id -un\` tried to execute invalid constant \$2.\" >>\$menat_log exit 1 elif [ \"\$ex_bb\" != $time_s ];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 menat_ui_dd=\"vs_hn=\$vs_hn:user=\$menat_user:host=\$menat_host:exe_hn=\$exe_hn\" echo \"#\$menat_ui_dd\" week_v_str=\"${week:-week=0} ${auto_exe:-0}\" echo \"#org_id=\$org_id:prs_id=\$prs_id:sr_id=\$sr_id; \$week_v_str; iepg_err=\$iepg_err; $cr_version\" fi else exit 1 fi elif [ \"\$re_c\" = cap_dd ];then grep -A 2 \"#\$bfn:\" \$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 exe_tty=\`tty 2>/dev/null\`;tty_v=\$? exe_user=\`id -un\` if [ \$tty_v = 0 ];then echo >>\$menat_h_t/menat.log echo \"cr-$ma_bfn: 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 \"cr-$ma_bfn: executed \$ma_file by unexpected user, \$exe_user.\" >>\$menat_log exit 1 fi #external_exe_end if [ ! -f \$menat_h/\$ma_file ]&&[ ! -f \$menat_h/\$time_s.n$cap_dev_n.mtq ];then echo >>\$menat_log echo \"cr-$ma_bfn: \$cap_st_d:\$opt1::removed just before capture.\" >>\$menat_log exit 0 fi if [ \$time_n '<' $time_sE ];then echo >>\$menat_log echo \"cr-$ma_bfn: the time was not expired. \$ma_file was not executed.\" >>\$menat_log exit 1 elif [ \$time_n '>' $ma_time_e ]||[ \$time_n = $ma_time_e ];then echo >>\$menat_log if [ \`grep -c ' menat_ends\$' \$menat_h/\$ma_file\` != 0 ];then echo \"cr-$ma_bfn: retried to execute \$ma_file, this job was discarded.\" >>\$menat_log exit 1 else echo \"cr-$ma_bfn: the time was over. this job, \$ma_file was discarded.\" >>\$menat_log time_out=1 if [ -d \$menat_lock ];then menat_lock_f=\$menat_lock/\$bfn else if [ -f \$menat_lock ];then rm -f \$menat_lock fi mkdir \$menat_lock menat_lock_f=\$menat_lock/\$bfn fi echo \"\$p_time_n ${ma_time_epm}分 $ma_pch \$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 '>' $time_s ];then time_n_s=\`date '+%s'\` time_eps=\$(($ma_time_e_s-\$time_n_s)) fi echo >>\$menat_log echo \"cr-$ma_bfn: \$cap_st_d:\$opt1::start \$time_s\" >>\$menat_log if [ -d \$menat_lock ];then menat_lock_f=\$menat_lock/\$bfn else if [ -f \$menat_lock ];then rm -f \$menat_lock fi mkdir \$menat_lock menat_lock_f=\$menat_lock/\$bfn fi echo \"\$cap_st_d:\$opt1::start \$time_s\" >>\$menat_lock_f echo \"${ma_name_f##*/}:$psz:$cap_vcodec::$cap_fps:$cap_acodec:$ma_time_epm $time_s.w$cap_dev_n.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 awxu --width 512|grep -v grep|grep \"^menat .*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 \"cr-$ma_bfn: the process \$t was stoped to capture \$bfn.\" >>\$menat_log stv=1 done fi sl=1 end_lock_0=\$menat_h_t/end.lock$cap_dev_n end_lock_ts=\$menat_h_t/end.lock$cap_dev_n.$time_s end_lock_te=\$menat_h_t/end.lock$cap_dev_n.$ma_time_e if [ -f \$end_lock_ts ];then echo \$\$ >>\$end_lock_ts while [ -f \$end_lock_ts ];do cont_safe=\`sleep 0.1s;/bin/kill -s CONT \$\$ 2>/dev/null;echo const_safe: sleep 0.1s sl=\$sl >>\$menat_log\`& echo \"cr-$ma_bfn: /bin/kill -s STOP \$\$ sl=\$sl\" >>\$menat_log /bin/kill -s STOP \$\$ if [ \"\`tail -n1 \$end_lock_0\`\" = end.lock$cap_dev_n.$time_s ];then echo \"cr-$ma_bfn: end_lock_ts was moved to end_lock_0, break.\" >>\$menat_log break fi sl=\$((\$sl+1)) done fi touch \$end_lock_te fi " >>$tmp_ma_file if [ "$hw_cap" = 1 ];then if [ $ma_ch != Composite1 ]&&[ $ma_ch != S-Video ];then hwc_ch_opt="--channel $ma_ch" fi echo "if [ \"\$time_out\" != 1 ];then hwn=0 hwc_dir=hw_cap.\$bfn while [ -e \$ma_h_t/\$hwc_dir ];do hwn=\$((\$hwn+1)) hwc_dir=hw_cap.\$bfn.\$hwn done mkdir \$ma_h_t/\$hwc_dir ######### for test ######### re_st_HMS=\`date '+%H:%M:%S'\` ############################ record-v4l2.pl --freqtable ${hwc_frq_t:-ntsc-bcast-jp} $hwc_rsl\ --input $cap_dev --inputnum ${hwc_in:-4}\ --dnrspatial ${dnr_sp:-8} --dnrtemporal ${dnr_tmp:-8}\ --bitrate ${hwc_vbr:-12000000} --peakbitrate ${hwc_pvbr:-13600000}\ $hwc_ch_opt -t \$time_eps -D \$ma_h_t/\$hwc_dir --directory-format \"\" -o \$bfn.mpg;cap_v=\$? end_lock_id=\`cat \$end_lock_te 2>/dev/null\` mv -f \$end_lock_te \$end_lock_0;mv_v=\$? echo end.lock$cap_dev_n.$ma_time_e >>\$end_lock_0 if [ \$mv_v != 0 ];then rm -f \$end_lock_te fi if [ \"\$end_lock_id\" ];then /bin/kill -s CONT \$end_lock_id echo \"cr-$ma_bfn: /bin/kill -s CONT \$end_lock_id\" >>\$menat_log for t in \$end_lock_id ;do echo -n \"cr-$ma_bfn: \" >>\$menat_log ps w --width 512 -p \$t -o cmd |tail -n1 >>\$menat_log done nx_cap_on=1 if [ \${stv:-0} = 1 ];then stv=0 echo \"cr-$ma_bfn: restart of \$men_r_id was suspended for \$end_lock_id.\" >>\$menat_log fi else nx_cap_on=0 fi hw_w=0 while [ -e \$ma_h_t/\$bfn ]&&[ \$hw_w -lt 20 ];do hw_w=\$((\$hw_w+1)) sleep 3s done mv -f \$ma_h_t/\$hwc_dir/\$bfn.mpg \$ma_h_t/\$bfn >/dev/null 2>&1 cp \$ma_h_t/\$hwc_dir/video.settings \$menat_h_t >/dev/null 2>&1 rm -f \$ma_h_t/\$hwc_dir/video.settings >/dev/null 2>&1 rm -rf \$ma_h_t/\$hwc_dir >/dev/null 2>&1 else nx_cap_on=0 cap_v=125 fi " >>$tmp_ma_file else echo "if [ \"\$time_out\" != 1 ];then ######### for test ######### re_st_HMS=\`date '+%H:%M:%S'\` ############################ # v4lctl -c /dev/video0 $v4lopt $v4l_ch mencoder tv://\ -tv driver=v4l2:device=\$cap_dev:normid=\$normid:chanlist=\$chanlist:channel=\$ch:amode=\$amode:fps=\$cap_fps$men_v4l$sz_v\ -ofps \$cap_fps -ovc lavc -oac \$acodec -lavcopts vcodec=\$vcodec:autoaspect -o \$tm_f\ -endpos \$time_eps >/dev/null 2>&1;cap_v=\$? end_lock_id=\`cat \$end_lock_te 2>/dev/null\` mv -f \$end_lock_te \$end_lock_0;mv_v=\$? echo end.lock$cap_dev_n.$ma_time_e >>\$end_lock_0 if [ \$mv_v != 0 ];then rm -f \$end_lock_te fi if [ \"\$end_lock_id\" ];then /bin/kill -s CONT \$end_lock_id echo \"cr-$ma_bfn: /bin/kill -s CONT \$end_lock_id\" >>\$menat_log for t in \$end_lock_id ;do echo -n \"cr-$ma_bfn: \" >>\$menat_log ps w --width 512 -p \$t -o cmd >>\$menat_log done nx_cap_on=1 if [ \${stv:-0} = 1 ];then stv=0 echo \"cr-$ma_bfn: restart of \$men_r_id was suspended for \$end_lock_id.\" >>\$menat_log fi else nx_cap_on=0 fi else nx_cap_on=0 cap_v=125 fi " >>$tmp_ma_file fi echo "ep_YmdaHM=\`date '+%Y-%m-%d %a %H:%M'\` time_re=\`date '+%Y%m%d%H%M'\` time_re_HMS=\`date '+%H:%M:%S'\` 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 \"cr-$ma_bfn: the process \$t stopped to capture \$bfn was re-started.\" >>\$menat_log echo \"cr-$ma_bfn: \$men_r0_id\"|grep \" \$t \"|cut -d' ' -f11- >>\$menat_log done fi cmp_lock_ls=\`ls -d \$menat_h_t/lock.*\` echo \"cr-$ma_bfn: cmp_lock_ls=\$cmp_lock_ls\" >>\$menat_log if [ \"\$men_r_id\" ];then echo \"cr-$ma_bfn: $ma_bfn: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 \"cr-$ma_bfn: 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 \"cr-$ma_bfn: $ma_bfn:stv=0:men_r_id=null\" >>\$menat_log cmp_w_ls=\$cmp_lock_ls fi if [ \$nx_cap_on = 0 ];then ex_stop_ls_0=\`ps auxw --width 512|tr -s ' ' ' '\` ex_stop_ls=\`echo \"\$ex_stop_ls_0\"|grep \"^menat .* T .*\$cap_dev\"|cut -d' ' -f2\` if [ \"\$ex_stop_ls\" ];then for t in \$ex_stop_ls ;do /bin/kill -s CONT \$t echo \"cr-$ma_bfn: the unknown stopped process \$t was re-started.\" >>\$menat_log echo -n \"cr-$ma_bfn: \" >>\$menat_log echo \"\$ex_stop_ls_0\"|grep \" \$t \"|cut -d' ' -f11- >>\$menat_log done fi fi if [ \"\$hta\" = 0 ];then rm -f \$ma_h/.htaccess fi m0=\`df -Pm \$ma_h|tail -n1|tr -s ' ' ' '|cut -d' ' -f4\` m1=\`du -msL \$ma_h 2>/dev/null\` m1=\${m1%\$ma_h};m1=\$((\$m1)) ma_h_mm=\"\$m1/\$((\$m0+\$m1))(MB)\" if [ \"\$time_out\" != 1 ];then echo >>\$menat_h_t/menat.log echo \"cr-$ma_bfn: \$time_n - \$time_re \$time_e :: \$pch:: \$bfn:cap_v=\$cap_v:end\" >>\$menat_log echo \"cr-$ma_bfn: \$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$cap_dev_n.mtq elif [ \$cap_v != 0 ];then cap_failed=\"capture_failed \" ma_file_2=\$time_s.f$cap_dev_n.mtq else ma_file_2=\$time_s.s$cap_dev_n.mtq fi echo \"cr-$ma_bfn: \$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$r_opt1:$cap_dev:cc_obp=$cap_obp:cap_v=\$cap_v\" else p_f_sz=\"0MB(none)$r_opt1:$cap_dev:cc_obp=$cap_obp: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: $cap_vf; \$p_f_sz; \$p_time_nS - \$re_st_HMS - \$time_re_HMS\" >>\$menat_h/\$ma_file echo \"#\$ep_YmdaHM \$ma_file_2 \$ma_h_mm \${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 \$ma_h_mm \${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 " >>$tmp_ma_file if [ ${week:-0} != 0 ];then echo "$week_ex" >>$tmp_ma_file fi echo " 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%.$ma_ext} echo tlong_m=\$time_epm >\$menat_h_t/lock.\$b_name_f echo cap_sol=$psz >>\$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 '<' \$time_e ];do i=\$((\$i+1)) if [ \$i = 1 ];then time_re_s=\`date '+%s'\` ex_sleep=\$(($ma_time_e_s-\$time_re_s)) if [ \$cap_v != 0 ];then echo \"cr-$ma_bfn: capture failed, go into sleep \${ex_sleep}s.\" >>\$menat_log else echo \"cr-$ma_bfn: 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-$ma_time_s_s)) echo \"sleep_out=\${sleep_out}s\" >>\$menat_lock_f break fi done ed -s \$menat_h/\$ma_file >/dev/null 2>&1 <>\$menat_lock_f echo \"cr-$ma_bfn: menat_sad started from \$bfn.\" >>\$menat_log \$menat_sad $ma_bfn$r_opt1 menat-cr.sh-$version -l \$ma_file" >>$tmp_ma_file if [ ${week:-0} != 0 ];then echo "if [ -f \$menat_h/$nw_time_s.w$cap_dev_n.mtq ];then \$menat_progchk -v $vs_hn -n \$menat_h/$nw_time_s.w$cap_dev_n.mtq elif [ -f \$menat_h/$nw_time_s.n$cap_dev_n.mtq ];then \$menat_progchk -v $vs_hn -n \$menat_h/$nw_time_s.n$cap_dev_n.mtq fi" >>$tmp_ma_file fi echo "echo \"$cr_version: menat_sad ended from \$bfn.\" >>\$menat_lock_f echo \"cr-$ma_bfn: 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 \"cr-$ma_bfn: \$menat_mail -vs $vs_hn $ma_user_opt -v \$cap_v -p 0 -i \$ma_file_mail -n $tm_f_bn\" >>\$menat_log \$menat_mail -vs $vs_hn $ma_user_opt -v \$cap_v -p 0 -i \$ma_file_mail -n $tm_f_bn if [ -f \$name_f ];then if [ \"\$opt1\" ]&&[ \${cmp_v:-0} != 0 ];then bp_vv=\`\$menat_bp -N 1 -i \$ma_file_2\`;bp_v1=\$? $menat_cmp -vs \$vs_hn \$name_f \$mop1 \$mop2 \$mop3 -i \$ma_file_2 & echo >>\$menat_log echo \"cr-$ma_bfn: 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-$version: 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 \"cr-$ma_bfn: capture \$bfn was time out at \${ep_YmdaHM}.\" >>\$menat_log else echo \"cr-$ma_bfn: 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 \"cr-$ma_bfn: manat_lock_f was removed.\" >>\$menat_log rm -rf \$menat_lock else echo \"cr-$ma_bfn: capture \$bfn ended, and other capture is running.\" >>\$menat_log echo \"cr-$ma_bfn: now capturing, \$on_cap.\" >>\$menat_log fi else echo \"cr-$ma_bfn: 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$cap_dev_n.* 2>/dev/null\` ;do tt=\${t##*/} tt_YmdHM=\${tt##*.} rt_YmdHM=\`date '+%Y%m%d%H%M'\` if [ \$tt_YmdHM '<' \$rt_YmdHM ]||[ \$tt_YmdHM = \$rt_YmdHM ];then for t1 in \`cat \$t\` ;do kill -s CONT \$t1 cont_YmdaHM=\`date '+%Y-%m-%d %a %H:%M'\` cr_mesg=\$menat_h_t/cr.mesg echo \"cr-$ma_bfn: unknown error occured, maybe critical region was intruded.\" >>\$cr_mesg echo \"cr-$ma_bfn: unexpected kill was executed for PID \${t} at \${cont_YmdaHM}.\" >>\$cr_mesg echo \"cr-$ma_bfn: unknown error occured, maybe critical region was intruded.\" >>\$menat_log echo \"cr-$ma_bfn: unexpected kill was executed for PID \${t} at \${cont_YmdaHM}.\" >>\$menat_log echo \"$menat_mail $ma_user_opt -p 3 -vs $vs_hn -i \$ma_file_mail -n \$cr_mesg\" >>\$menat_log \$menat_mail $ma_user_opt -p 3 -vs $vs_hn -i \$ma_file_mail -n \$cr_mesg done mv -f \$t \$menat_h_t/end.lock$cap_dev_n;mv_v=\$? if [ \$mv_v = 0 ];then echo \"cr-$ma_bfn: \$tt was moved to end.lock$cap_dev_n.\" >>\$menat_log else rm -f \$t echo \"cr-$ma_bfn: move of \$tt was failed, \$tt was removed.\" >>\$menat_log fi fi done echo \"cr-$ma_bfn: capture \$bfn ended at \${ep_YmdaHM}.\" >>\$menat_log echo >>\$menat_log exit 0 #maexe_file_end " >>$tmp_ma_file exe_ln=`cat $tmp_ma_file|wc -l` exe_end_ln=$(($exe_ln)) ed -s $tmp_ma_file >/dev/null 2>/dev/null <' $mx_f0_b12 ];then mx_f0_b12=$f0_b12 mx_f0=$f0 fi fi done else keep_org_id=${keep_org_id:-0} fi if [ "$mx_f0" ];then f0_bfn=`$mx_f0 -c bfn`;f0_bfn_n0=${f0_bfn%.*};f0_bfn_n=${f0_bfn_n0##*.} f0_bfn_b0=${f0_bfn%.*};f0_bfn_b=${f0_bfn_b0%.*} dvn=`n_ident $f0_bfn_n`;dvn_v=$? if [ $dvn_v = 0 ];then keep_sq_ok=1 else keep_sq_ok=0 f0_bfn_n=0 fi tmp_bfn=${ma_name_f##*/};tmp_bfn_n0=${tmp_bfn%.*};tmp_bfn_n=${tmp_bfn_n0##*.} tmp_bfn_b0=${tmp_bfn%.*};tmp_bfn_b=${tmp_bfn_b0%.*} dvn=`n_ident $tmp_bfn_n 2>&1`;dvn_v=$? if [ $dvn_v = 0 ];then keep_sq_ok=$keep_sq_ok else if [ ${week:-0} != 0 ];then keep_sq_ok=0 else keep_sq_ok=$keep_sq_ok fin_ok=1 fi tmp_bfn_n=0 fi if { [ $keep_sq_ok = 1 ]&&[ $f0_bfn_b = $tmp_bfn_b ]; }||[ "$keep_org_id" = 1 ];then if [ $tmp_bfn_n -gt $f0_bfn_n ]||[ "$fin_ok" = 1 ]||[ "$keep_org_id" = 1 ];then f0_org_id=`$mx_f0 -c org_id` f0_sr_id=`$mx_f0 -c sr_id` f0_org_ttl=`$mx_f0 -c org_title` if [ ! "$f0_org_ttl" ];then f0_org_ttl=`$mx_f0 -c iepg_title` if [ ! "$f0_org_ttl" ];then f0_org_ttl="$cr_iepg_ttl" fi fi nw_sr_id=$(($f0_sr_id+1)) ml_n=`grep -n '^exit 0' $mx_f0|head -n 1|cut -d':' -f1` ml_ls=`grep -n 'a menat' $mx_f0|cut -d':' -f1` for av in $ml_ls ;do if [ $av -gt $ml_n ]&&[ $av -le ${ml_nn:-$av} ];then ml_nn=$av fi done sed -n "$ml_nn,\$p" $mx_f0 >>$tmp_ma_file id_v="org_id=$f0_org_id;prs_id=;sr_id=$nw_sr_id" ed -s $tmp_ma_file >/dev/null 2>&1 <>$tmp_ma_file fi fi fi else nw_sr_id=0 fi if [ "$f0_org_ttl" != "$cr_iepg_ttl" ]&&[ ${nw_sr_id:-0} != 0 ];then f0_org2_ttl="`true_title $f0_org_ttl`" if [ "$f0_org2_ttl" ];then if [ "$f0_org2_ttl" = "`true_title $cr_iepg_ttl`" ];then iepg_err_ttl=0 else iepg_err_ttl=4 fi cr_org_title="$f0_org2_ttl" else cr_org_title="" iepg_err_ttl=4 fi else cr_iepg2_ttl="`true_title $cr_iepg_ttl`" if [ "$cr_iepg2_ttl" = "$cr_iepg_ttl" ];then cr_org_title="\$iepg_title" else cr_org_title="$cr_iepg2_ttl" fi iepg_err_ttl=0 fi cr_end_ln_tmp=`cat $tmp_ma_file|wc -l` cr_end_ln_tmp=$(($cr_end_ln_tmp)) if [ ${cr_iepg:-0} = 0 ];then iepg_err_v="-1" else iepg_err_v=$(($iepg_err_st+$iepg_err_et+$iepg_err_ttl+$iepg_err_ext)) if [ $iepg_err_st != 0 ];then iepg_err_v="$iepg_err_v;iepg_st=$iepg_st" fi if [ $iepg_err_et != 0 ];then iepg_err_v="$iepg_err_v;iepg_et=$iepg_et" fi fi ed -s $tmp_ma_file >/dev/null 2>&1 < top1.for 0.3.2c.