#!/bin/bash
# ACFS1.0 問題修正工具 by 村仔 98.11.24
# 寫作參考
http://news.ols3.net/techdoc/old/shell/c1009.html
#
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
#URL="
ftp://localhost/ACFS/"
URL="
ftp://163.23.89.100/ACFS/"
Fix_Dir="/opt/chc/fix/"
Tmp_Dir="/tmp/"
##--取到版本號Ubuntu904------
Ver=`sed -n 's/ //p' /etc/
issue.net`
######## 建立目錄--存放目錄 ###################
if ! [ -d $Fix_Dir ]; then
mkdir $Fix_Dir -p
fi
if ! [ -d $Tmp_Dir ]; then
mkdir $Tmp_Dir -p
fi
######## 下載更新檔 ###################
DFile="ACFS_${Ver}.txt"
cd $Tmp_Dir
if [ -a ${DFile} ];then
#echo "刪除舊檔"
rm ${DFile}
fi
echo "下載更新列表檔中${URL}fix${Ver}/${DFile}"
`wget -q ${URL}fix${Ver}/${DFile}`
UpList=${Tmp_Dir}${DFile}
##--無法下載或找不到檔案----
if ! [ -a ${UpList} ];then
echo "目前無更新"
exit
fi
##--- 函式 執行更新動作---###
function Hello () {
Fixed=$Fix_Dir$1
Run=$Tmp_Dir$1
#echo $Run# echo $Fixed
##--- 1.檢查己更新----
if [ -a $Fixed ];then
echo "${1}己更新,不用再更新"
return
fi
##--- 2.下載更新檔----
if ! [ -a $Fixed ];then
echo "下載更新檔中${URL}fix${Ver}/$1"
`wget -q ${URL}fix${Ver}/$1`
fi
##--- 3.檢查下載檔----
if [ -a $Run ];then
echo "進行更新程序"$1
sh $1
touch $Fixed
Ti=`date "+%F_%T"`
echo "${Ti}" > $Fixed
rm ${1}
fi
return
}
cat ${UpList} | while read aa
do
if [ "$aa" = "" ]; then
continue
fi
Hello "$aa"
done
cd $Tmp_Dir
rm ${DFile}
echo "更新程序結束---"
exit