Advertisement
Guest User

apt-fast

a guest
May 28th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.58 KB | None | 0 0
  1. ralf@huntington:~$ sudo apt-fast install blender
  2.  
  3. # Config File
  4. source /etc/apt-fast.conf
  5. + source /etc/apt-fast.conf
  6. ###################################################################
  7. # CONFIGURATION OPTIONS                                          
  8. ###################################################################
  9.  
  10. # Maximum number of connections
  11. _MAXNUM=7
  12. ++ _MAXNUM=7
  13.  
  14. # Use aptitude or apt-fast?
  15. # Note that for outputting the package URI list, we always use apt-get
  16. # ...since aptitude can't do this
  17. _APTMGR=aptitude
  18. ++ _APTMGR=aptitude
  19.  
  20. # Note that the manager you choose has other options - feel free
  21. # to setup your own _DOWNLOADER or customize one of the ones below
  22. # they're simply here as examples, and to provide sane defaults
  23.  
  24. # Download manager selection
  25. # (choose one by uncommenting one #_DOWNLOADER line)
  26.  
  27. # aria2c:
  28. #_DOWNLOADER='aria2c -c -j ${_MAXNUM} --input-file=/tmp/apt-fast.list --connect-timeout=600 --timeout=600 -m0'
  29.  
  30. # aria2c with a proxy (set username, proxy, ip and password!)
  31. #_DOWNLOADER='aria2c -c 20 -j ${_MAXNUM} --http-proxy=http://username:password@proxy_ip:proxy_port -i apt-fast.list'
  32.  
  33. # axel:
  34. _DOWNLOADER='cat /tmp/apt-fast.list | xargs -l1 axel -n ${_MAXNUM} -a' # axel
  35. ++ _DOWNLOADER='cat /tmp/apt-fast.list | xargs -l1 axel -n ${_MAXNUM} -a'
  36.  
  37. # Check for proper priveliges
  38. [ "`whoami`" = root ] || exec sudo "$0" "$@"
  39. whoami
  40. ++ whoami
  41. + '[' root = root ']'
  42.  
  43. # Check if a lockfile exists
  44. LCK_FILE=/var/run/$(basename $0).lock
  45. basename $0).lock
  46. basename $0
  47. ++ basename /usr/sbin/apt-fast
  48. + LCK_FILE=/var/run/apt-fast.lock
  49. [ -f $LCK_FILE ] && { echo "$(basename $0) already running"; exit 1; }
  50. + '[' -f /var/run/apt-fast.lock ']'
  51.  
  52. # Remove lockfile
  53. LCK_RM() {
  54. rm -f $LCK_FILE
  55. #echo lock-File $LCK_FILE deleted
  56. }
  57.  
  58. trap "LCK_RM ; exit 1" 2 9 15
  59. + trap 'LCK_RM ; exit 1' 2 9 15
  60.  
  61. # Create and insert a PID number to lockfile
  62. echo $$ > $LCK_FILE
  63. + echo 6869
  64. NUM=1
  65. + NUM=1
  66.  
  67. # Make sure one of the download managers is enabled
  68. [ -z "$_DOWNLOADER" ] && echo "You must configure /etc/apt-fast.conf to use axel or aria2c" && LCK_RM && exit 1
  69. + '[' -z 'cat /tmp/apt-fast.list | xargs -l1 axel -n ${_MAXNUM} -a' ']'
  70.  
  71. # If the user entered arguments contain upgrade, install, or dist-upgrade
  72. if echo "$@" | grep -q "upgrade\|install\|dist-upgrade|full-upgrade"; then
  73.   echo "Working...";
  74.  
  75.   # Test if apt-fast directory is present where we put packages
  76.   if [ ! -d /var/cache/apt/archives/apt-fast ] ; then
  77.         mkdir /var/cache/apt/archives/apt-fast;
  78.   fi
  79.   cd /var/cache/apt/archives/apt-fast;
  80.  
  81.   # Get the package URL's
  82.   # note aptitude doesn't have this functionality
  83.   # so we use apt-get only
  84.   apt-get -y --print-uris $@ | egrep -o -e "(ht|f)tp://[^\']+" > /tmp/apt-fast.list
  85.  
  86.   # Download the packages
  87.   eval ${_DOWNLOADER}
  88.  
  89.   # Move all packages to the apt install directory by force to ensure
  90.   # already existing debs which may be incomplete are replaced
  91.   mv -f *.deb /var/cache/apt/archives/
  92.  
  93.   # Install our downloaded packages
  94.   ${_APTMGR} $@;
  95.  
  96.   echo -e "\nDone! Verify that all packages were installed successfully. If errors are found, run apt-get clean as root and try again using apt-get directly.\n";
  97.  
  98. else
  99.    ${_APTMGR} $@;
  100. fi
  101. + echo install blender
  102. + grep -q 'upgrade\|install\|dist-upgrade|full-upgrade'
  103. + echo Working...
  104. Working...
  105. + '[' '!' -d /var/cache/apt/archives/apt-fast ']'
  106. + cd /var/cache/apt/archives/apt-fast
  107. + apt-get -y --print-uris install blender
  108. + egrep -o -e '(ht|f)tp://[^\'\'']+'
  109. + eval cat /tmp/apt-fast.list '|' xargs -l1 axel -n '${_MAXNUM}' -a
  110. cat /tmp/apt-fast.list | xargs -l1 axel -n ${_MAXNUM} -a
  111. ++ xargs -l1 axel -n 7 -a
  112. ++ cat /tmp/apt-fast.list
  113. Aufruf: axel [Optionen] url1 [url2] [url...]
  114.  
  115. --max-speed=x           -s x    maximale Geschwindigkeit (Bytes pro Sekunde)
  116. --num-connections=x     -n x    maximale gleichzeitige Verbindungen
  117. --output=f              -o f    lokale Ausgabe-Datei
  118. --search=[x]            -S [x]  Suche nach Spiegelservern und Abruf von x Servern
  119. --header=x              -H x    Sende HTTP-Header
  120. --user-agent=x          -U x    Setze Browser-Kennung
  121. --no-proxy              -N      keinen Proxy-Server benutzen
  122. --quiet                 -q      keine Meldungen auf Standard-Ausgabe
  123. --verbose               -v      zusätzliche Status-Information
  124. --help                  -h      diese Information
  125. --version               -V      Versions-Information
  126.  
  127. Fehler an lintux@lintux.cx melden.
  128. + mv -f '*.deb' /var/cache/apt/archives/
  129. mv: Aufruf von stat für „*.deb“ nicht möglich: Datei oder Verzeichnis nicht gefunden
  130. + aptitude install blender
  131. Es werden keine Pakete installiert, aktualisiert oder entfernt.
  132. 0 Pakete aktualisiert, 0 zusätzlich installiert, 0 werden entfernt und 4 nicht aktualisiert.
  133. Muss 0 B an Archiven herunterladen. Nach dem Entpacken werden 0 B zusätzlich belegt sein.
  134.                                              
  135. + echo -e '\nDone! Verify that all packages were installed successfully. If errors are found, run apt-get clean as root and try again using apt-get directly.\n'
  136.  
  137. Done! Verify that all packages were installed successfully. If errors are found, run apt-get clean as root and try again using apt-get directly.
  138.  
  139.  
  140. # Test the date of our lockfile
  141. while [ $NUM -le 2 ] ; do
  142.         NUM=`expr $NUM + 1`
  143.         sleep 2
  144. done
  145. + '[' 1 -le 2 ']'
  146. expr $NUM + 1
  147. ++ expr 1 + 1
  148. + NUM=2
  149. + sleep 2
  150. + '[' 2 -le 2 ']'
  151. expr $NUM + 1
  152. ++ expr 2 + 1
  153. + NUM=3
  154. + sleep 2
  155. + '[' 3 -le 2 ']'
  156. # After error or all done remove our lockfile with a PID number
  157. LCK_RM
  158. + LCK_RM
  159. + rm -f /var/run/apt-fast.lock
  160.  
  161. exit 0
  162. + exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement