diff options
author | Benedikt Böhm <bb@xnull.de> | 2008-10-30 18:07:05 +0100 |
---|---|---|
committer | Benedikt Böhm <bb@xnull.de> | 2008-10-30 18:07:05 +0100 |
commit | bd75a13a203b518c189cb9215d0aa0b5ee8d0641 (patch) | |
tree | e2eb0b3d9e0c896a2d6e19c2823fbd7c48a56ded | |
download | porticron-bd75a13a203b518c189cb9215d0aa0b5ee8d0641.tar.gz porticron-bd75a13a203b518c189cb9215d0aa0b5ee8d0641.tar.bz2 porticron-bd75a13a203b518c189cb9215d0aa0b5ee8d0641.zip |
commit initial version
-rwxr-xr-x | bin/porticron | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bin/porticron b/bin/porticron new file mode 100755 index 0000000..ab16f6e --- /dev/null +++ b/bin/porticron @@ -0,0 +1,55 @@ +#!/bin/bash + +SCRIPT_NAME=$(basename $0) +FQDN=$(hostname --fqdn) +IP=$(dig +short ${FQDN}) +DATE=$(date -R) +PORTDIR=$(portageq portdir) + +# only sync portage if PORTDIR is mounted read-write +if touch "${PORTDIR}"/.read_only_check &>/dev/null; then + rm -f "${PORTDIR}"/.read_only_check + /usr/bin/emerge --sync --quiet &>/dev/null +fi + +PACKAGES=$(/usr/bin/emerge --pretend --changelog --update --deep --newuse --quiet --usepkg world 2>/dev/null) + +if [[ -z ${PACKAGES} ]]; then + exit 0 +fi + +cat <<EOF | sendmail -t +To: root@${FQDN} +From: root@${FQDN} +Subject: Gentoo package updates on ${FQDN} +Date: ${DATE} + +porticron report [${DATE}] +======================================================================== + +${SCRIPT_NAME} has detected that some packages need upgrading on: + + ${FQDN} + [ ${IP} ] + +The following packages are currently pending an upgrade: + +$(echo "${PACKAGES}" | sed 's/^\[/ [/') + +======================================================================== + +You can perform the upgrade by issuing the command: + + emerge -NDuk world + +as root on ${FQDN} + +It is recommended that you pretend the upgrade first to confirm that +the actions that would be taken are reasonable. The upgrade may be +pretended by issuing the command: + + emerge -NDuvpk world + +-- +${SCRIPT_NAME} +EOF |