#!/bin/sh PATH="$PATH:/usr/sbin:/sbin" TMP_FILE=$(mktemp) MAIL=$(mktemp) PORTAGE_QUIET='1' eix-sync 1>/dev/null 2>${TMP_FILE} emerge -v --update --newuse --deep --with-bdeps=y --quiet-build=y @world \ &>> ${TMP_FILE} if [ "$(grep '\[ebuild U' ${TMP_FILE})" != '' ]; then echo "From: $(whoami)@$(hostname -f)" > ${MAIL} echo "To: root@$(hostname -f)" >> ${MAIL} echo "Subject: $(hostname -f):$(grep Total: ${TMP_FILE} \ | cut -d ':' -f 2 | cut -d ')' -f 1))" >> ${MAIL} echo "Content-Type: text/plain; charset=UTF-8" >> ${MAIL} echo "Date: $(date --rfc-email)" >> ${MAIL} printf "\n" >> ${MAIL} cat ${TMP_FILE} >> ${MAIL} if [ "$(lsof -n | awk '{ if ($5 == "DEL") print $9 }' | sort -u)" ]; then restart-services --no-color >> ${MAIL} fi if ! [ -z "$(grep -v '{}' /var/lib/portage/preserved_libs_registry)" ]; then emerge -v --quiet-build=y @preserved-rebuild >> ${MAIL} fi emerge -p --depclean --with-bdeps\=y >> ${MAIL} eix-test-obsolete \ | grep -Pv '^No|^Skipping|[Aa]ll.*packages are in the database' \ >> ${MAIL} cat ${MAIL} | sendmail -t root@$(hostname -f) fi rm ${TMP_FILE} ${MAIL}