#!/bin/sh
#
# Unattended FreeBSD Ports upgrade cycle, please note that starting and stopping
# of services is taken care of in the pkgtools.conf
#
# Rick van der Zwet <info@rickvanderzwet.nl>
#
PATH=$PATH:/usr/local/sbin:/usr/local/bin
WC=`cd $(dirname $0); pwd -P`
export PKGTOOLS_CONF=$WC/pkgtools.conf

if [  `id -u` -ne 0 ]; then
  echo "Root only!" 1>&2
  exit 1
fi

# Fetch the latest details and provide listing of packages to be updated
portsnap fetch update || exit 1
portversion -vL= || exit 1

# Make sure the internal database is consistent
pkgdb -Fa || exit 1

# Fetch all required sources first
portupgrade -aFR || exit 1

# Install all new packages
portupgrade -aR

