Blame view
main_tools/RecomposePass.sh
6.77 KB
e6be5137b
|
1 2 3 4 5 6 7 8 9 |
#!/bin/bash ##################################################### # File : RecomposePass.sh # # Brief : Get missing res pass from previous pass # # Author : Jean-François Rey # # Version : 1.0 # # Date : 25/07/13 # ##################################################### |
f37e72eaf
|
10 |
echo "### RecomposePass.sh ###" |
e6be5137b
|
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# Check OTMEDIA_HOME env var if [ -z ${OTMEDIA_HOME} ] then OTMEDIA_HOME=$(dirname $(dirname $(readlink -e $0))) export OTMEDIA_HOME=$OTMEDIA_HOME fi # where is RecomposePass.sh MAIN_SCRIPT_PATH=$(dirname $(readlink -e $0)) # Scripts Path SCRIPT_PATH=$OTMEDIA_HOME/tools/scripts # Include scripts . $SCRIPT_PATH"/Tools.sh" . $SCRIPT_PATH"/CheckSecondPass.sh" # where is RescomposePass.cfg RECOMPOSEPASS_CONFIG_FILE=$OTMEDIA_HOME"/cfg/RecomposePass.cfg" if [ -e $RECOMPOSEPASS_CONFIG_FILE ] then . $RECOMPOSEPASS_CONFIG_FILE else echo "ERROR : Can't find configuration file $RECOMPOSEPASS_CONFIG_FILE" >&2 exit 1 fi #---------------# # Parse Options # #---------------# while getopts ":hDv:" opt do case $opt in h) echo -e "$0 [OPTIONS] <PASS_DIRECTORY> " echo -e "\t Options:" echo -e "\t\t-h :\tprint this message" echo -e "\t\t-D :\tDEBUG mode on" echo -e "\t\t-v l :\tVerbose mode, l=(1|2|3) level mode" exit 1 ;; D) DEBUG=1 ;; v) VERBOSE=$OPTARG ;; :) |
d7e9e4b9d
|
60 |
echo "Option -$OPTARG requires an argument." >&2 |
e6be5137b
|
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
exit 1 ;; \?) echo "BAD USAGE : unknow opton -$OPTARG" #exit 1 ;; esac done # mode debug enable if [ $DEBUG -eq 1 ] then set -x echo -e "## Mode DEBUG ON ##" fi # mode verbose enable if [ $VERBOSE -gt 0 ]; then echo -e "## Verbose level : $VERBOSE ##" ; fi # Check USAGE by arguments number if [ $(($#-($OPTIND-1))) -ne 1 ] then echo "BAD USAGE : RecomposePass.sh [OPTIONS] <PASS_DIR>" echo "$0 -h for more info" exit 1 fi shift $((OPTIND-1)) # check Pass directory - First argument if [ -e $1 ] && [ -d $1 ] then PASS_DIR=$(readlink -e $1) else print_error "can't find $1 directory" exit 1 fi #-------------# # GLOBAL VARS # #-------------# |
b427f103e
|
101 102 103 104 105 |
BASENAME=$(basename $PASS_DIR) OUTPUT_DIR_BASENAME=$PASS_DIR RES_DIR="$PASS_DIR/res_all" LOGFILE=$PASS_DIR"/info_recpass.log" ERRORFILE=$PASS_DIR"/error_recpass.log" |
e6be5137b
|
106 107 108 109 110 |
THIRDPASS_CONFIG_FILE="$PASS_DIR/ThirdPass.cfg" if [ -e $THIRDPASS_CONFIG_FILE ] then RES_P3=$(cat $THIRDPASS_CONFIG_FILE | grep "^RES_DIR=" | cut -f2 -d"=") else |
b427f103e
|
111 |
print_warn "[${BASENAME}] can't find $THIRDPASS_CONFIG_FILE file" 2 |
e6be5137b
|
112 113 114 115 116 117 118 |
#exit 1 fi SECONDPASS_CONFIG_FILE="$PASS_DIR/SecondPass.cfg" if [ -e $SECONDPASS_CONFIG_FILE ] then RES_P2=$(cat $SECONDPASS_CONFIG_FILE | grep "^RES_DIR=" | cut -f2 -d"=") else |
b427f103e
|
119 |
print_warn "[${BASENAME}] can't find $SECONDPASS_CONFIG_FILE file" 2 |
e6be5137b
|
120 121 122 123 124 125 126 |
#exit 1 fi FIRSTPASS_CONFIG_FILE="$PASS_DIR/FirstPass.cfg" if [ -e $FIRSTPASS_CONFIG_FILE ] then RES_P1=$(cat $FIRSTPASS_CONFIG_FILE | grep "^RES_DIR=" | cut -f2 -d"=") else |
b427f103e
|
127 |
print_warn "[${BASENAME}] can't find $FIRSTPASS_CONFIG_FILE file" 2 |
e6be5137b
|
128 129 |
#exit 1 fi |
b427f103e
|
130 131 132 133 134 135 |
if ( [ -z "$RES_P1" ] && [ -z "$RES_P2" ] ) || [ -z $RES_P3 ] then print_error "[${BASENAME}] No configuration pass files in $PASS_DIR -> exit" if [ $CHECK -eq 1 ]; then print_log_file $ERROFILE "No configuration pass files in $PASS_DIR -> exit";fi exit 1 fi |
e6be5137b
|
136 |
|
b427f103e
|
137 |
print_info "[${BASENAME}] => RecomposePass start | $(date +'%d/%m/%y %H:%M:%S')" 1 |
e6be5137b
|
138 139 140 141 142 143 |
#------------------# # Create WORKSPACE # #------------------# # Lock directory |
b427f103e
|
144 145 146 147 148 |
if [ -e $OUTPUT_DIR_BASENAME/RECOMPOSEPASS.lock ] && [ $RERUN -eq 0 ] then print_warn "[${BASENAME}] RECOMPOSEPASS is locked -> exit" 2 exit 1 fi |
e6be5137b
|
149 150 151 152 |
rm "$OUTPUT_DIR_BASENAME/RECOMPOSEPASS.unlock" > /dev/null 2>&1 touch "$OUTPUT_DIR_BASENAME/RECOMPOSEPASS.lock" > /dev/null 2>&1 if [ $RERUN -eq 0 ]; then rm -r $RES_DIR > /dev/null 2>&1; fi |
b427f103e
|
153 154 |
mkdir -p $RES_DIR 2> /dev/null print_info "Make directory $RES_DIR" 3 |
e6be5137b
|
155 156 157 158 159 160 161 162 163 |
#--------------------# # Save configuration # #--------------------# cp $RECOMPOSEPASS_CONFIG_FILE $OUTPUT_DIR_BASENAME/RecomposePass.cfg echo "RES_ALL=$RES_DIR" >> $OUTPUT_DIR_BASENAME/RecomposePass.cfg echo "RES_P1=$RES_P1" >> $OUTPUT_DIR_BASENAME/RecomposePass.cfg echo "RES_P2=$RES_P2" >> $OUTPUT_DIR_BASENAME/RecomposePass.cfg echo "RES_P3=$RES_P3" >> $OUTPUT_DIR_BASENAME/RecomposePass.cfg |
b427f103e
|
164 |
print_info "[${BASENAME}] Save config in $OUTPUT_DIR_BASENAME/RecomposePass.cfg" 1 |
e6be5137b
|
165 166 167 168 |
#--------------------------------------------------# # Recompose Pass using previous pass # #--------------------------------------------------# |
b427f103e
|
169 |
print_info "[${BASENAME}] Launch Recompose Pass" 1 |
e6be5137b
|
170 171 |
## Check seg in p3 |
3aadb2261
|
172 |
print_info "cp res_p3 into res_all" 3 |
e6be5137b
|
173 174 175 176 177 |
cp $RES_P3/*.res $RES_DIR ls $RES_P3/*.res | sed -e "s|$RES_P3\/||g" | sed -e 's/\.res//' | sort > ${OUTPUT_DIR_BASENAME}/res_p3.tmp ls $RES_P2/*.res | sed -e "s|$RES_P2\/||g" | sed -e 's/\.res//' | sort > ${OUTPUT_DIR_BASENAME}/res_p2.tmp ls $RES_P1/*.res | sed -e "s|$RES_P1\/||g" | sed -e 's/\.res//' | sort > ${OUTPUT_DIR_BASENAME}/res_p1.tmp diff_3_2=$(diff ${OUTPUT_DIR_BASENAME}/res_p3.tmp ${OUTPUT_DIR_BASENAME}/res_p2.tmp | grep -e "^> " | sed -e "s/> //") |
3aadb2261
|
178 |
print_info "cp missing res_p2 into res_all" 3 |
e6be5137b
|
179 180 181 182 183 184 |
for res in $diff_3_2 do cp $RES_P2/$res.res $RES_DIR done ls $RES_DIR/*.res | sed -e "s|$RES_DIR\/||g" | sed -e 's/\.res//' | sort > ${OUTPUT_DIR_BASENAME}/res_all.tmp diff_3_1=$(diff ${OUTPUT_DIR_BASENAME}/res_all.tmp ${OUTPUT_DIR_BASENAME}/res_p1.tmp | grep -e "^> " | sed -e "s/> //") |
3aadb2261
|
185 |
print_info "cp missing res_p1 into res_all" 3 |
e6be5137b
|
186 187 188 189 |
for res in $diff_3_1 do cp $RES_P1/$res.res $RES_DIR done |
b427f103e
|
190 |
rm ${OUTPUT_DIR_BASENAME}/res_p3.tmp ${OUTPUT_DIR_BASENAME}/res_p2.tmp ${OUTPUT_DIR_BASENAME}/res_p1.tmp ${OUTPUT_DIR_BASENAME}/res_all.tmp 2> /dev/null |
e6be5137b
|
191 192 193 194 |
#---------------# # Convert res # #---------------# |
b427f103e
|
195 |
print_info "[${BASENAME}] Convert .res into .ctm" 1 |
e6be5137b
|
196 197 |
# .res => .ctm $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format CTM --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.allpass.ctm |
b427f103e
|
198 |
print_info "[${BASENAME}] Convert .res into .trs" 1 |
e6be5137b
|
199 200 201 202 203 204 205 |
# .res => .trs echo -e "name $AUTHOR fileName ${BASENAME} fileExt wav segFile ${OUTPUT_DIR_BASENAME}/${BASENAME}.seg" > ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TRS --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.allpass.trs --trs_config ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg rm ${OUTPUT_DIR_BASENAME}/${BASENAME}.trs_cfg |
b427f103e
|
206 |
print_info "[${BASENAME}] Convert .res into .txt" 1 |
e6be5137b
|
207 208 |
# .res => .txt $SCRIPT_PATH/res2out.pl --dir $RES_DIR --format TXT --ignore $RULES/asupp --out ${OUTPUT_DIR_BASENAME}/${BASENAME}.allpass.txt |
b427f103e
|
209 |
print_info "[${BASENAME}] <= RecomposePass End | $(date +'%d/%m/%y %H:%M:%S')" 1 |
e6be5137b
|
210 211 212 |
# unlock directory mv "$OUTPUT_DIR_BASENAME/RECOMPOSEPASS.lock" "$OUTPUT_DIR_BASENAME/RECOMPOSEPASS.unlock" |