~utappia/2clickupdate/master

« back to all changes in this revision

Viewing changes to modules/speed_apt.module

  • Committer: Salih Emin
  • Date: 2011-08-18 13:31:13 UTC
  • Revision ID: git-v1:6611df63c058f6b5bcc1284ab8ff4512f185b889
alpha 1 release of uCareSystem

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
#Enabled untrusted and no-prompt package installations
 
4
UntrustedUPEnabled='upgrade'
 
5
 
 
6
#Beginig the axeleration of package downloads
 
7
if echo "$@" | grep -q "$UntrustedUPEnabled"; then
 
8
        cd /var/cache/apt/archives/
 
9
        gksudo 'apt-get -qq --print-uris -y --force-yes --allow-unauthenticated' $@ | while read line ; do
 
10
                Url="$(echo $line | awk '{print $1}' | tr -d \')"
 
11
                axel -a -n 10l "$Url"
 
12
                Hash="$(echo $line | sed "s/.* .*:\(.*\)/\1/g")"
 
13
                HashType="$(echo $line | sed "s/.* \(.*\):.*/\1/g")"
 
14
                HashCalc="$(echo ${HashType,,}sum)"
 
15
                File="$(basename $Url)"
 
16
                FileHash="$($HashCalc $File | awk '{print $1}')"
 
17
                if [[ "$FileHash" = "$Hash" ]]; then
 
18
                        echo -e "\E[32m33[1m$File successfully verified.33[0m"
 
19
                else
 
20
                        echo -e "\E[31m\33[1m$File failed verification, retrying...33[0m"
 
21
                        rm "$File"
 
22
                        axel -a -n 10l "$Url"
 
23
                        FileSum="$($HashCalc $File | awk '{print $1}')"
 
24
                        if [[ "$FileHash" = "$Hash" ]]; then
 
25
                                echo -e "\E[32m33[1m$File successfully verified.33[0m"
 
26
                        else
 
27
                                echo -e "\E[31m33[1m$File failed verification, quiting.33[0m"
 
28
                                rm "$File"
 
29
                                exit 1
 
30
                        fi
 
31
                fi
 
32
        done
 
33
        gksudo 'apt-get -y --force-yes --allow-unauthenticated' $@
 
34
fi