#!/bin/bash # gund v 2005-12-13-c cmd=$0 opt=$1 echo "Gentoo Update Notification Dragon '$cmd' on:" `/usr/bin/hostname` echo "Options: self,sync,glsa,update,revdep,clean,depclean,prune" export FEATURES="notitles strict" export NOCOLOR="true" export PATH=/bin:/usr/bin export PORTAGE_NICENESS=15 # If any of these phrases are listed in the emerge output # the automatic update will not take place, is passed to egrep no_auto="apache|glibc|postgresql|ssh" if [ "$opt" = "self" ]; then # neat that I can overwrite myself while I'm running and start it. echo "Updrading Self..." wget -q -O- http://www.edoceo.com/dl/gund > $cmd exit fi if [ -z $opt ] || [ "$opt" = "sync" ]; then emerge --sync >/dev/null || exit fi # GLSA if [ -z $opt ] || [ "$opt" = "glsa" ]; then echo "* GLSA Checks" buf=`glsa-check --test all 2>&1 |grep '^[0-9]'` for glsa in $buf do glsa-check --print $glsa 2>/dev/null|head -n2 glsa-check --pretend $glsa 2>/dev/null|egrep '^The following| ' echo done fi # Update # note: may not want --deep in here if [ -z $opt ] || [ "$opt" = "update" ]; then echo "* Checking for updates [ -DNpuv ]" buf=`emerge -DNpuv --nospinner world |grep '^\[ebuild'` if [ -n "$buf" ]; then echo "${buf}" | /bin/egrep ${no_auto} >/dev/null if [ "$?" != "0" ]; then echo "** Performing Automatic Update" echo $buf|sed 's/ +\[eb/\n\[eb/g' emerge -DNu --nospinner world >/dev/null else echo "** Manual Update Required, fetching" # uncomment below to perform download now emerge -DNu --fetch-only >/dev/null echo $buf|sed 's/ \[eb/\n\[eb/g' fi fi fi # Revdeps if [ -z $opt ] || [ "$opt" = "revdep" ] ; then if [ -e /usr/bin/revdep-rebuild ]; then echo "* Reverse Dependency required rebuilds" revdep-rebuild --pretend --quiet | egrep '^ broken|^\[ebuild' rm ./.revdep-rebuild.* fi fi # Packages that can be removed if [ -z $opt ] || [ "$opt" = "clean" ]; then echo "* Cleaning [ -cpv world ]" emerge --clean --nospinner --pretend --verbose world fi if [ -z $opt ] || [ "$opt" = "depclean" ]; then echo "* Useless Packages [ --depclean -pv ]" emerge -pv --depclean --nospinner | egrep '^ \w+' fi if [ -z $opt ] || [ "$opt" = "prune" ]; then echo "* Packages to prune [ -pPv ]" emerge -pPv --nospinner | egrep '^ \w+|^ +selected' fi