Advertisement
SunMar

gentoo-update

Nov 28th, 2014
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.17 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Script to keep a Gentoo system fully up-to-date and clean.
  4. # See http://pastebin.com/sAHz1FqH for oldlib-check.
  5. # Author: Marijn van Zon <marijn@suninet.org>
  6.  
  7. function show_usage {
  8.  
  9.     echo "Usage: gentoo-update [options]"
  10.     echo
  11.     echo -e "\t--sync\t\tforce sync of portage tree"
  12.     echo -e "\t--no-sync\tdo not sync portage tree"
  13.     echo
  14.  
  15.     exit
  16. }
  17.  
  18. sync=-1
  19.  
  20. for i in $(seq 1 ${#}); do
  21.  
  22.     eval param="\${${i}}"
  23.  
  24.     case "${param}" in
  25.         "--sync")    sync=1 ;;
  26.         "--no-sync") sync=0 ;;
  27.     *)           show_usage ;;
  28.     esac
  29. done
  30.  
  31. if [[ $sync -lt 0 ]]; then
  32.  
  33.     lastsync=$(grep 'Sync completed' /var/log/emerge.log |sed -n '$ s/:.*//p')
  34.     current=$(date +%s)
  35.     let diff="$current - $lastsync"
  36.  
  37.     if [[ $diff -lt 86400 ]]; then
  38.         echo
  39.     echo -n "Skipping sync, last sync was: "
  40.     date -R -d @$lastsync
  41.         sync=0
  42.     else
  43.         sync=1
  44.     fi
  45. fi
  46.  
  47. if [[ $sync -eq 1 ]]; then
  48.     sync="eix-sync -v"
  49. else
  50.     sync="echo -n"
  51. fi
  52.  
  53. $sync && \
  54. emerge -uvDNa --with-bdeps=y @world && \
  55. etc-update && \
  56. emerge -ca && \
  57. /usr/local/sbin/oldlib-check && \
  58. revdep-rebuild && \
  59. eclean-dist --destructive
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement