Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
Last active January 26, 2017 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PieterScheffers/7e245ca05269a5dc0481 to your computer and use it in GitHub Desktop.
Save PieterScheffers/7e245ca05269a5dc0481 to your computer and use it in GitHub Desktop.
FreeBSD - find updates script
#!/usr/bin/env sh
# for finding changes in UPDATING
PKGQUERY=`pkg query %t | sort | tail -n1`
echo "####################################"
echo "# Updating ports collection (Host) #"
echo "####################################"
portsnap fetch update
echo " "
echo "#####################################"
echo "# Updating ports collection (Jails) #"
echo "#####################################"
ezjail-admin update -P
echo " "
echo "################################"
echo "# Programs with updates (Host) #"
echo "################################"
portmaster -L | grep New | cut -d: -f2 | tr -d " "
echo " "
echo "#################################"
echo "# Programs with updates (Jails) #"
echo "#################################"
jls | grep -v JID | tr -s " " | cut -d' ' -f2 | xargs -I {} sh -c 'echo {} && jexec -U root {} portmaster -L | grep New | cut -d: -f2 && jexec -U root {} sh ~/check_updates.sh'
echo " "
echo "###### List Jails ###############"
jls
echo " "
echo "Start jail console with: 'ezjail-admin console <Hostname>'"
echo "To install: 'portmaster -ydbg --no-confirm <ports>'"
echo " "
echo "###### Contents of UPDATING since last update ###############"
UPDATE=`date -r $PKGQUERY "+%Y%m%d"`
AWKCMD="awk -F':' '\$2 < "$UPDATE" { print \$1 }'"
LINE=`grep -n -E '^[0-9]{8}' /usr/ports/UPDATING | eval $AWKCMD | head -n1`
CONTENTS=`head -n$LINE /usr/ports/UPDATING`
echo "$CONTENTS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment