Language/Script Etc
html cache 만들기
미니옵빠
2012. 9. 10. 15:51
#!/bin/sh
#########################
# Static file creation
#########################
TEMP_FILE="/index.html.temp"
FAIL_FILE="/index.html.fail"
DEST_FILE="/index.html"
# Temp 파일로 먼저 받아서
curl -s --connect-timeout 10 'http://www.xxx.com/index.xxx' -o $TEMP_FILE
# 마지막 라인만 읽어 success flag를 확인
FLAG=`tail -n 1 ${TEMP_FILE}`
echo "Flag message: ${FLAG}"
if [[ $FLAG == *success* ]]
then
mv ${TEMP_FILE} ${DEST_FILE}
echo 'Static file creation successful.'
rsync -avz /index.html xxx.xxx.xxx.xx1::R/index.html
rsync -avz /index.html xxx.xxx.xxx.xx2::R/index.html
exit 0
else
mv ${TEMP_FILE} ${FAIL_FILE}
echo 'Static file creation failure.'
exit 1
fi