#!/bin/sh
. /etc/init.d/tc-functions
TMPDIR=/tmp/bcwipe123
VER="1.9-8"
SRC="BCWipe-"$VER".tar.gz"
MIRROR="http://www.jetico.com/linux"
DEPS="compiletc.tcz \
squashfs-tools-4.x"
if [ -f /etc/sysconfig/tcedir ]; then
TCEDIR=`readlink /etc/sysconfig/tcedir`
elif [ -f /opt/.tce_dir ]; then
TCEDIR=`cat /opt/.tce_dir`
fi
for I in `echo "$DEPS"`; do
DEPNAME=`basename "$I" .tcz`
if [ ! -f /usr/local/tce.installed/"$DEPNAME" ]; then
if [ -f "$TCEDIR"/"$I" ]; then
if su tc -c "tce-load -i "$I""; then
echo "${YELLOW}"$I" loaded locally${NORMAL}"
else
echo "${RED}"$I" failed to load, exiting..${NORMAL}"
exit 1
fi
else
if su tc -c "tce-load -iw "$I""; then
echo "${YELLOW}"$I" loaded from repo${NORMAL}"
else
echo "${RED}"$I" failed to load, exiting..${NORMAL}"
exit 1
fi
fi
fi
done
[ -d "$TMPDIR" ] && rm -r "$TMPDIR"
mkdir -p "$TMPDIR"
cd "$TMPDIR"
wget "$MIRROR"/"$SRC"
tar xvf "$SRC"
cd bcwipe-"$VER"
./configure --prefix=/usr/local
make
make install DESTDIR="$TMPDIR"/pkg
cd "$TMPDIR"
mksquashfs pkg/ "$TCEDIR"/optional/bcwipe.tcz -noappend > /dev/null 2>&1
cd "$TCEDIR"
grep "bcwipe.tcz" "$TCEDIR"/onboot.lst > /dev/null 2>&1 || echo "bcwipe.tcz" >> "$TCEDIR"/onboot.lst
cd "$TCEDIR"/optional
md5sum bcwipe.tcz > bcwipe.tcz.md5.txt
if [ ! -f /usr/local/tce.installed/bcwipe ]; then
tce-load -i "$TCEDIR"/optional/bcwipe.tcz
fi
echo "${BLUE}bcwipe.tcz${GREEN} is now installed and will be loaded onboot.${NORMAL}"