Advertisement
emcek

emerge-status.sh

Nov 5th, 2011
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. emc@meee ~/bin $ cat emerge-status.sh
  2. #!/bin/bash
  3. #
  4. # emerge-status.sh by Hellf[i]re
  5. #
  6. # This script will report the current status of portage.
  7. #
  8. # Usage:
  9. # .conkyrc: ${execi [time] /path/to/script/emerge-current.sh}
  10. #
  11. # Usage Example
  12. # ${execi 30 /home/youruser/scripts/emerge-current.sh}
  13. #
  14. # Known Bugs:
  15. # 1) If there are two emerges running at once, when the first one finishes
  16. # running, the script will report the current status as "Completed".
  17. # 2) If there is a emerge running and you run a search, the script will
  18. # report the current status as "Completed", until the running emerge
  19. # moves to the next package, or itself completes.
  20. # The reasons for this are twofold - one, it's a feature ;) and two, there
  21. # would be far too much parsing required to find out the current status of
  22. # every command which is run in parallel.
  23.  
  24. STATUS=`tail -n 15 /var/log/emerge.log |\
  25. grep -iE "Compiling|Cleaning|AUTOCLEAN|completed|search|terminating|rsync" |\
  26. cut -d ' ' -f "2-" |\
  27. grep -Ev 'Finished\.|Cleaning up\.\.\.' |\
  28. tail -n 1`
  29.  
  30. #echo "$STATUS"
  31.  
  32. if [ "`echo "$STATUS" | grep -i compiling`" != "" ]; then echo Compiling
  33. elif [ "`echo "$STATUS" | grep -i cleaning`" != "" ]; then echo Cleaning
  34. elif [ "`echo "$STATUS" | grep -i autoclean`" != "" ]; then echo Autoclean
  35. elif [ "`echo "$STATUS" | grep -i sync`" != "" ]; then echo Syncing
  36. elif [ "`echo "$STATUS" | grep -i search`" != "" ]; then echo Searching
  37. elif [ "`echo "$STATUS" | grep -i completed`" != "" ]; then echo Completed
  38. elif [ "`echo "$STATUS" | grep -i terminating`" != "" ]; then echo Completed
  39. else echo Script Error!
  40. fi
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement