#!/bin/bash

# h4 script to generate an hbrsrv support bundle.

if [ "$1" == "" ]; then
   /usr/bin/echo "Usage: $0 /path/to/bundle.tar.gz" 1>&2
   exit 1
fi

if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 2
fi

/usr/bin/install -b -m 640 -o hbrsrv -g vmware /dev/null "$1"

# Unfortunately, if we don't run this as root, the hbr bundle won't include core
# dumps, which are important for hbrsrv troubleshooting...
/usr/bin/hbrsrv-support-bundle.sh -f "$1"

/usr/bin/chown h4.h4 "$1"
