一个生成manifest的脚本
#!/bin/bash
if [ $# -ne 1 ];then
echo Usage: ${0} dir
exit
fi
list_alldir(){
for file in `find $1`
do
if [ -f $file -a $file != $2 ];then
echo ${file#${1}} >> $2
fi
done
}
lastChar=${1: 1}
dir=${1}
if [ a/ != a$lastChar ];then
dir=${dir}/
fi
targetfile=${dir}appcache.manifest
if [ -f ${targetfile} ];then
rm -f ${targetfile}
fi
echo CACHE MANIFEST > ${targetfile}
now=$(date +%Y-%m-%d_%k:%M:%S)
echo "# version: ${now}" >> ${targetfile}
echo $'\n'CACHE:$'\n' >> ${targetfile}
list_alldir ${dir} ${targetfile}
echo $'\n'NETWORK:$'\n'* >> ${targetfile}