Advertisement
Saichovsky

apt-fast.sh

Aug 3rd, 2024 (edited)
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -eu
  4. ARCHDIR=/var/cache/apt/archives
  5. ARCHLIST=${ARCHDIR}/apt-fast_$$.list
  6.  
  7. # Test if aria2 is installed
  8. if [ ! -x /usr/bin/aria2c ]; then
  9.   echo "aria2 is not installed, perform installation? (y/n)"
  10.   read ops
  11.   case ${ops,,} in
  12.   y) if apt-get install aria2 -y; then
  13.     echo "aria2 installed"
  14.   else
  15.     echo "Unable to install the aria2. Are you sudo?"
  16.     exit
  17.   fi ;;
  18.   n)
  19.     echo "Aborting script"
  20.     exit 1
  21.     ;;
  22.   esac
  23. fi
  24.  
  25. # If the user entered arguments contain upgrade, install, or dist-upgrade
  26. if echo "$@" | grep -Eqw "(dist-)?upgrade|(re)?install"; then
  27.   echo "Working..."
  28.  
  29.   # Have apt-get print the information, including the URI's to the packages
  30.   apt-get -y --print-uris $@ |
  31.     grep -Po "(ht|f)tps?://[^\']+" >${ARCHLIST} &&
  32.     aria2c -c -i ${ARCHLIST} -d ${ARCHDIR} ||
  33.     echo "No files to download"
  34. fi
  35.  
  36. # Perform the user's requested action via apt-get
  37. apt-get $@
  38.  
  39. 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"
  40.  
  41. # Clean up
  42. apt clean
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement