如何修改apt-axel脚本
这篇文章给大家分享的是有关如何修改apt-axel脚本的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
为喀喇沁等地区用户提供了全套网页设计制作服务,及喀喇沁网站建设行业解决方案。主营业务为做网站、成都做网站、喀喇沁网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
我把apt-axel脚本更改了一下,以适合自己的使用: 修改如下:
使用一个server
使用mirror server达到更快的速度
下面是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”]
感谢各位的阅读!关于“如何修改apt-axel脚本”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
网站题目:如何修改apt-axel脚本
URL链接:http://azwzsj.com/article/piespo.html