#!/bin/sh
dir_romfs=../../romfs
dir_romfs_web=../../romfs/web
dir_web=../../users/www/
www_path=web
comp_path=compress_web
tmp_list=/tmp/list.txt
cgi=0

filelist=$(cd $www_path && find -type f -name "*" | egrep --regexp '(js|css)$')  找出所有的js和css檔
cgilist=(./state.js ./util_gw.js ./general.js)  不使用YUI工具進行壓縮的檔案

chmod -R 777 $dir_romfs 將目錄權限改成可以讀寫

# for JS and CSS compress
for filename in $filelist
do
   for ((i=0; i<${#cgilist[@]}; i++))    #${cglist[@]}是指cgilist這個陣列的個數
    do
        if [ $filename == ${cgilist[$i]} ]; then 若非cglist中的檔案,才會進行YUI壓縮
cgi=1
break
else
cgi=0
fi
     done
if [ $cgi -eq 0 ]; then      cgi 等於0表示非cgilist中的檔案,所以需使用YUI 工具壓縮網頁
if [ ! -d "$comp_path" ]; then
mkdir -p $comp_path/qis
else
rm -rf $comp_path
mkdir -p $comp_path/qis
fi

./yuicompressor-2.4.2.jar $www_path/$filename -o $comp_path/$filename   yui 工具的使用方法
cp -r $comp_path/* $dir_romfs_web
echo "YUI Downsizing:" $filename
fi
done


# for htm, asp, jsp(including CGI)
find $dir_romfs_web -type f -name "*" | egrep --regexp '(asp|htm)$' > $tmp_list   所有的asp, htm以及cgilist中的檔案僅使用一般的網頁壓縮,不使用YUI 工具進行壓縮

for ((i=0; i<${#cgilist[@]}; i++))
    do
        find $dir_romfs_web -type f -name "*" | grep ${cgilist[$i]} >> $tmp_list
    done

./web_downsize -f $tmp_list

arrow
arrow
    全站熱搜

    Yisin 發表在 痞客邦 留言(0) 人氣()