第一个脚本程序,自动生成离线升级包并自动删除旧包

sh/bash/dash/ksh/zsh等Shell脚本
回复
djhui
帖子: 85
注册时间: 2007-03-10 12:34
送出感谢: 0
接收感谢: 0
联系:

第一个脚本程序,自动生成离线升级包并自动删除旧包

#1

帖子 djhui » 2008-10-13 12:00

此脚本须要有足够的硬盘空间,因为是第一个,所以可能不怎么好,请见谅

echo "Update the sources"
apt-get update
echo "Update the system & soft"
apt-get dist-upgrade -y

apt-get upgrade -y


if [ -e ~/edgy ]
then
echo ~/"edgy already existed"
else
mkdir ~/edgy
fi
echo "Copy files"
#cp -a /var/cache/apt/archives/* ~/edgy
cd ~/
echo "Make Packages.gz"
dpkg-scanpackages edgy /dev/null |gzip >edgy/Packages.gz

mkdir ~/temp_djhui_net
copy ~/edgy/Packages.gz ~/temp_djhui_net
cd ~/temp_djhui_net
gzip -d Packages.gz
cat Packages |grep ^Filename > temp
sed -e 's/Filename: /cp \~\//g' temp >temp1

sed -e 's/.deb/.deb \~\/new_djhui\//g' temp1 >temp2

mkdir ~/new_djhui

chmod +x temp2

./temp2

cp ~/edgy/Packages.gz ~/new_djhui

rm -rf ~/edgy
rm -rf ~/temp_djhui_net

mv ~/new_djhui ~/edgy
回复

回到 “Shell脚本”