#!/bin/bash

ln -s /usr/lib/libcrypto.so.0.9.8 /usr/lib/libcrypto.so.4

for i in `fdisk -l | grep "^/dev/sd" | grep FAT | awk '{ print $1}'`
do
    SYSID=`dmidecode | grep UUID | awk '{ print $2 }' | sed 's/......-[0-z]*-[0-z]*-[0-z]*-......//'`
    TMPMNT=`echo $i | awk -F"/"  '{ print "/mnt/" $3 }'`
    mkdir -p $TMPMNT
    mount $i $TMPMNT
    mkdir -p $TMPMNT/capture/$SYSID

    echo Capture info to device $i into location $TMPMNT/capture/$SYSID
    echo Capturing DMIDECODE ...
    dmidecode 2>&1 > $TMPMNT/capture/$SYSID/dmi.txt
    echo Capturing TAM info ...
    tamutil 2>&1 > $TMPMNT/capture/$SYSID/tamutil.txt
    echo Capturing FRU data ...
    ipmiutil fru 2>&1   > $TMPMNT/capture/$SYSID/frudata.txt
    echo Capturing ShowSEL ...
    ipmiutil sel 2>&1   > $TMPMNT/capture/$SYSID/sel.log
    echo Capturing Sensor info ...
    ipmiutil sensor -v 2>&1 > $TMPMNT/capture/$SYSID/sensor.txt
    umount $TMPMNT
    rmdir $TMPMNT
done

echo ...
echo DONE
echo ...
echo System info has been captured to "/capture" onto your USB storage devices.
echo into location $TMPMNT/capture/$SYSID
[ "`grep autoexec= /proc/cmdline`" == "" ] || echo This system will power off in 45 seconds......
[ "`grep autoexec= /proc/cmdline`" == "" ] || sleep 45
