如何修改apt-axel腳本

這篇文章給大家分享的是有關(guān)如何修改apt-axel腳本的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

為喀喇沁等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及喀喇沁網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為做網(wǎng)站、成都做網(wǎng)站、喀喇沁網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

我把a(bǔ)pt-axel腳本更改了一下,以適合自己的使用: 修改如下:

  • 使用一個(gè)server

  • 使用mirror server達(dá)到更快的速度

下面是apt-axel文件

#!/bin/bash

###########################################################################
#
# Authors: Jes鷖 Espino Garc韆 & Lucas Garc韆
# Email: jespino@imap.cc
# Date: 31/05/2004
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
###########################################################################

# If the config file not exist, load the default parameters

VERSION="0.1"
CONFIG_FILE="/etc/apt-axel.conf";

if [ -f $CONFIG_FILE ]; then
. $CONFIG_FILE
else
# Verbose TRUE or FALSE
VERBOSE="FALSE"

# Conections
CONNECTIONS=8

# Servers
server1="ftp://ftp.de.debian.org/debian/"
server2="ftp://ftp.es.debian.org/debian/"
server3="ftp://ftp.fr.debian.org/debian/"
server4="ftp://ftp.it.debian.org/debian/"
server5="ftp://ftp.fi.debian.org/debian/"
server6="ftp://ftp.uk.debian.org/debian/"
server7="ftp://ftp.tk.debian.org/debian/"
server8="ftp://ftp.us.debian.org/debian/"
fi

# Set the package variable to be global
package="";

# Show the help
mostrar_ayuda() {
echo "Usage: apt-axel  ";
echo "";
echo "Options:";
echo "  install - Install new packages (paquete es libc6 y no libc6.deb)";
echo "  upgrade - Do a software upgrade";
echo "  dist-upgrade - Do a distribution upgrade, see apt-get(8)";
echo "  --version - Print the current version of apt-axel";
echo "  --help - Show this help";
echo "";
}

# Get a package from the ftp server
get_package() {
descargar() {
# Check the $VERBOSE variable and the filesize, if the filesize is lower than 200K will use only 4 conections
# And if the $VERBOSE variable is TRUE, then print the axel output
if [ $VERBOSE == "TRUE" ]; then
if [ $size -gt 200000 ]; then
echo $server1$url
axel -a -n $CONNECTIONS $server1$url -o /tmp/$archivo -S $mirror1
else
axel -a -n 4 $server1$url -o /tmp/$archivo -S $mirror1
fi
else
echo -n "Geting $package package: "
if [ $size -gt 200000 ]; then
axel -a -n $CONNECTIONS $server1$url -o /tmp/$archivo -S $mirror1 > /dev/null
else
axel -a -n 4 $server1$url -o /tmp/$archivo -S $mirror1 > /dev/null
fi
echo "Done"
fi
}

# Getting data
url=$(apt-cache show $package | grep ^Filename: | sed s/^Filename: //)
archivo=$(echo "$url" | sed s/^.*$package/$package/)
pkgstatus=$(dpkg -s $package 2> /dev/null | grep ^Status: | grep -v "not-installed")
md5sum=$(apt-cache show $package | grep ^MD5sum: | sed s/^MD5sum: //)
size=$(apt-cache show $package | grep ^Size: | sed s/^Size: //)

# Downloading the package
if [ -f /var/cache/apt/archives/$archivo ]; then
echo -n "Package already downloaded. Checking md5sum of $package package: "
while [ $md5sum != $(md5sum /var/cache/apt/archives/$archivo | sed s/ .*$//) ]; do
echo "incorrect"
echo "Downloading again $package package."
rm -f /var/cache/apt/archives/$archivo
descargar
done
echo "correct"
else
descargar
fi

# Move the file to /var/cache/apt/archives
if [ -f /tmp/$archivo ]; then
if [ $md5sum == $(md5sum /tmp/$archivo | sed s/ .*$//) ]; then
mv -f /tmp/$archivo /var/cache/apt/archives/
fi
fi
}

pkg_install() {
for package in $(apt-get -s install $1 | grep ^Inst | sed s/^Inst // | sed s/ .*$//); do
get_package
done
apt-get -y install $1
}

upgrade() {
for package in $(apt-get -s upgrade | grep ^Inst | sed s/^Inst // | sed s/ .*$//); do
get_package
done
apt-get -y upgrade
}

dist_upgrade() {
for package in $(apt-get -s dist-upgrade | grep ^Inst | sed s/^Inst // | sed s/ .*$//); do
get_package
done
apt-get -y dist-upgrade
}

#
# Main program
#
if [ `id -u` != 0 ]; then
echo "You must be root to run this command."
else
case $1 in
install) pkg_install $2;;
upgrade) upgrade;;
dist-upgrade) dist_upgrade;;
(--version) echo "Current Version: $VERSION";;
(--help | -h) mostrar_ayuda;;
*) mostrar_ayuda;;
esac
fi

配置文件: GNU nano 1.3.12 File: /etc/apt-axel.conf

# Verbose TRUE or FALSE
VERBOSE="TRUE"

# Conections
CONNECTIONS=20

# Servers
server1="http://ubuntu.cnsite.org/ubuntu/"
mirror1="http://ubuntu.cn99.com/ubuntu/"

[download id=“24”]

感謝各位的閱讀!關(guān)于“如何修改apt-axel腳本”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

網(wǎng)頁(yè)名稱:如何修改apt-axel腳本
文章地址:http://muchs.cn/article30/piespo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開(kāi)發(fā)、網(wǎng)站設(shè)計(jì)、云服務(wù)器、網(wǎng)站設(shè)計(jì)公司定制網(wǎng)站、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁(yè)設(shè)計(jì)