#!/usr/bin/sh

# Run q4 and get a crash analysis (no parameters required)

# Must cd into directory with crash dump files
# Will unpack vmunix if needed.
# Runs crash prep
# Runs q4


if [ -f vmunix.gz ]
then
   gunzip vmunix.gz
fi

if [ ! -f vmunix ]
then
   echo "\nCan't find vmunix file\n"
   exit 1
fi

# Source the env
. /usr/contrib/Q4/bin/set_env 

# Prep the dump if needed
/usr/contrib/Q4/bin/q4pxdb vmunix 

# whatHappened is shorter and more useful
echo "\nWhatHappened...\n"
echo "include whathappened.pl\nrun WhatHappened -HANG > whatHappened.txt" \
     | /usr/contrib/Q4/bin/q4 -p . 


