comparison moefetch.sh @ 170:0d385f77bb24

derp
author edhoprima@gmail.com <edhoprima@gmail.com>
date Fri, 05 Jun 2009 19:52:21 +0000
parents b9a49b36e4ab
children ba4ea5d19d2b
comparison
equal deleted inserted replaced
169:b9a49b36e4ab 170:0d385f77bb24
143 143
144 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR} 144 # current dir: ${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}
145 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" 145 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
146 for TRASH in `ls * | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$` 146 for TRASH in `ls * | sed -e 's/\([0-9a-f]\{32\}.*\)//g' | grep -v ^$`
147 do 147 do
148 mv -f "${BASE_DIR}/${SITE_DIR}/${TRASH}" "${BASE_DIR}/trash" 148 mv -f "${TRASH}" "${BASE_DIR}/trash" || Err_Fatal "Error deleting files"
149 echo "Moved ${TRASH} to ${BASE_DIR}/trash" 149 echo "Moved ${TRASH} to ${BASE_DIR}/trash"
150 done 150 done
151 printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" 151 printf "" > "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error"
152 for FILE in * 152 for FILE in *
153 do 153 do
154 if [ "`${MD5} "${FILE}" | cut -d ' ' -f1 -` != `echo "${FILE}" | cut -d '.' -f1`" ] 154 if [ "`${MD5} "${FILE}" | cut -d ' ' -f1 -`" != "`echo "${FILE}" | cut -d '.' -f1`" ]
155 then 155 then
156 echo 156 echo
157 echo "${FILE}" >> "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" 157 echo "${FILE}" >> "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error"
158 echo "Error: ${FILE}" 158 echo "Error: ${FILE}"
159 fi 159 fi
160 printf "." 160 printf "."
161 done 161 done
162 echo 162 echo
163 163
164 # back to target dir
165 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
166
167 echo "Removing error files"
168 if [ "${TOTAL_ERROR}" -eq 0 ]; then
169 echo "No error file. 0 file removed"
170 else
171 cat "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" | xargs rm
172 echo "${TOTAL_ERROR} file(s) removed"
173 fi
174 echo "`echo \`ls | wc -l\`` file(s) available locally"
175
164 # current dir: ${BASE_DIR}/temp 176 # current dir: ${BASE_DIR}/temp
165 cd ${BASE_DIR}/temp 177 cd ${BASE_DIR}/temp
166 TOTAL_ERROR=`echo \`wc -l < "${SITE_DIR}-${TARGET_DIR}-error"\`` 178 TOTAL_ERROR=`echo \`wc -l < "${SITE_DIR}-${TARGET_DIR}-error"\``
167 echo "${TOTAL_ERROR} file(s) error" 179 echo "${TOTAL_ERROR} file(s) error"
168 180
172 # 184 #
173 ls "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | comm -1 -3 "${SITE_DIR}-${TARGET_DIR}-error" - > "${SITE_DIR}-${TARGET_DIR}-ok" 185 ls "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | comm -1 -3 "${SITE_DIR}-${TARGET_DIR}-error" - > "${SITE_DIR}-${TARGET_DIR}-ok"
174 cat "${SITE_DIR}-${TARGET_DIR}-list" | grep -vf "${SITE_DIR}-${TARGET_DIR}-ok" > "${SITE_DIR}-${TARGET_DIR}-newlist" 186 cat "${SITE_DIR}-${TARGET_DIR}-list" | grep -vf "${SITE_DIR}-${TARGET_DIR}-ok" > "${SITE_DIR}-${TARGET_DIR}-newlist"
175 echo "`echo \`wc -l < \"${SITE_DIR}-${TARGET_DIR}-newlist\"\`` file(s) to be downloaded" 187 echo "`echo \`wc -l < \"${SITE_DIR}-${TARGET_DIR}-newlist\"\`` file(s) to be downloaded"
176 188
177 # back to target dir
178 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
179
180 echo "Removing error files"
181 if [ "${TOTAL_ERROR}" -eq 0 ]; then
182 echo "No error file. 0 file removed"
183 else
184 cat "${BASE_DIR}/temp/${SITE_DIR}-${TARGET_DIR}-error" | xargs rm
185 echo "${TOTAL_ERROR} file(s) removed"
186 fi
187 echo "`echo \`ls | wc -l\`` file(s) available locally"
188 else 189 else
189 if [ "${ISQUICK}" ]; then 190 if [ "${ISQUICK}" ]; then
190 echo "quick mode selected. Skipping check" 191 echo "quick mode selected. Skipping check"
191 else 192 else
192 echo "Empty local repository" 193 echo "Empty local repository"