From 593de8279f9bd14c5f9b24d2897128d42f7793da Mon Sep 17 00:00:00 2001 From: Gardouille Date: Fri, 20 Nov 2015 10:03:42 +0100 Subject: [PATCH] Add apt-fast script. --- README.md | 7 +++++++ apt-fast | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 apt-fast diff --git a/README.md b/README.md index ecec726..5374468 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ Some useful scripts (for me) that can be added to $PATH :) ## List: +* apt-fast: Script for faster package downloading with 'axel'. * bash_quote: Get a random quote from http://danstonchat.com * firewall: A script shell to set some iptables rules. * update-dynmotd.d/: scripts to update the motd (via the /etc/update-motd.d directory). @@ -19,6 +20,12 @@ Some useful scripts (for me) that can be added to $PATH :) * zenity_generator: Script to generate zenity window. * zfSnap.sh: Take snapshot of a ZFS pool. +### Apt-fast +Speed-up APT packages downloading with 'axel' (light command line download accelerator). Juste use it like aptitude/apt/apt-get. +```sh +sudo apt-fast full-upgrade +``` + ### Num_circle Tiny Bash script that take a number between 0 and 20 as argument and transform it into a digit with into a circle. ```sh diff --git a/apt-fast b/apt-fast new file mode 100755 index 0000000..de94ee9 --- /dev/null +++ b/apt-fast @@ -0,0 +1,28 @@ +#!/bin/bash +#apt-fast by Matt Parnell http://www.mattparnell.com , this thing is FOSS +#please feel free to suggest improvments to admin@mattparnell.com +# Use this just like apt-get for faster package downloading. Make sure to have axel installed + +#If the first user entered variable string contains apt-get, and the second string entered is either install or dist-upgrade +if echo "$1" | grep -q "[upgrade]" || echo “$2″ | grep -q "[install]" || echo "$2" | grep -q "[full-upgrade]"; then + echo “Working…”; + + #Go into the directory apt-get normally puts downloaded packages + cd /var/cache/apt/archives/; + + #Have apt-get print the information, including the URI’s to the packages + apt-get -y --print-uris $1 $2 $3 $4 > debs.list; + + #Strip out the URI’s, and download the packages with Axel for speediness + egrep -o -e "(ht|f)tp://[^\']+" debs.list | xargs -l1 axel -a; + + #Perform the user’s reqested action via aptitude + aptitude -y $1 $2 $3 $4; + + echo "Done! Make sure and check to see that the packages all were installed properly. If a package is erred, run sudo apt-get autoclean and try installing it again without the use of this