#!/bin/sh -e

##########################################################################
#   Script description:
#       Check out wip on all nodes
#       
#   History:
#   Date        Name        Modification
#   2021-01-12  J Bacon     Begin
##########################################################################

usage()
{
    printf "Usage: $0\n"
    exit 1
}


##########################################################################
#   Main
##########################################################################

if [ $# != 0 ]; then
    usage
fi

case $(auto-ostype) in
FreeBSD)
    if ! which wip-update; then
	auto-freebsd-wip-checkout
    fi
    cluster-run "touch /etc/make.conf && auto-set-conf-var USE_LOCAL_MK yes /etc/make.conf $0" all
    cluster-run "auto-set-conf-var VALID_CATEGORIES+ wip /usr/ports/Mk/bsd.local.mk $0" all
    cluster-run "pkg install -y git" all
    cluster-wip-update
    : ${PORTSDIR:=/usr/ports}
    cluster-run "cd $PORTSDIR/wip/wip-tools && make deinstall clean reinstall" all
    ;;
    
*)
    printf "$0: Not supported on $(auto-ostype).\n"
    exit 1
    ;;
esac
