Check to make sure libraries are installed, quit on failure

Signed-off-by: Matthew Stidham <stidmatt@protonmail.com>
This commit is contained in:
Matthew Stidham
2021-03-24 14:15:15 -07:00
parent a0102f4360
commit 335fb0a768

View File

@@ -13,6 +13,28 @@
# --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- #
# scripts # scripts
# Check to make sure dependencies are installed
present=(
gnuplot
wkhtmltopdf
)
killcommand=0
for i in "${present[@]}"; do
$present=$(rpm -qa | grep i)
if [[ $present -gt 0 ]]; then
pass
else
killcommand=1
echo "Please install $i on your system"
exit 1
fi
done
if [[ $killcommand -gt 0 ]]; then
exit 1
else
pass
fi
output_dir=diag_report output_dir=diag_report
input_fname= input_fname=
dut= dut=
@@ -20,50 +42,53 @@ clobber=0
show_help=0 show_help=0
while getopts "ho:f:d:C" arg; do while getopts "ho:f:d:C" arg; do
#echo "ARG[$arg] OPTARG[$OPTARG]" #echo "ARG[$arg] OPTARG[$OPTARG]"
case $arg in case $arg in
o) output_dir=$OPTARG o)
;; output_dir=$OPTARG
f) input_fname=$OPTARG ;;
;; f)
d) dut=$OPTARG input_fname=$OPTARG
;; ;;
h) show_help=1 d)
;; dut=$OPTARG
C) clobber=1 ;;
;; h)
*) show_help=1
echo "Ignoring option $arg $OPTARG" ;;
esac C)
clobber=1
;;
*)
echo "Ignoring option $arg $OPTARG"
;;
esac
done done
if [ -z "$input_fname" -o -z "$dut" ]; then if [ -z "$input_fname" -o -z "$dut" ]; then
show_help=1 show_help=1
fi fi
if [ $show_help -gt 0 ]; then if [ $show_help -gt 0 ]; then
echo "Usage: $0 -f {input-pcap-file} -o {output-directory} -d {DUT-bssid}" echo "Usage: $0 -f {input-pcap-file} -o {output-directory} -d {DUT-bssid}"
echo " $0 -f my.pcap -o report -d dc:ef:09:e3:b8:7d" echo " $0 -f my.pcap -o report -d dc:ef:09:e3:b8:7d"
exit 1 exit 1
fi fi
if [ -e $output_dir ]; then
if [ -e $output_dir ] if [ $clobber = "1" ]; then
then echo "Removing existing output directory: $output_dir"
if [ $clobber = "1" ] rm -fr $output_dir
then else
echo "Removing existing output directory: $output_dir" echo "ERROR: Output directory: $output_dir already exists."
rm -fr $output_dir exit 1
else fi
echo "ERROR: Output directory: $output_dir already exists."
exit 1
fi
fi fi
mkdir -p $output_dir || exit 1 mkdir -p $output_dir || exit 1
echo "Starting the wifi_pcap_diag.pl script, this can take a while...." echo "Starting the wifi_pcap_diag.pl script, this can take a while...."
tshark -V -r $input_fname | ./wifi_pcap_diag.pl --report_prefix $output_dir --dut $dut > $output_dir/output.txt tshark -V -r $input_fname | ./wifi_pcap_diag.pl --report_prefix $output_dir --dut $dut >$output_dir/output.txt
echo "All done, open this file with a browser to view report: $output_dir/index.html" echo "All done, open this file with a browser to view report: $output_dir/index.html"
exit 0 exit 0