#!/bin/sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

echo "check hdb"

/sbin/fdisk -l /dev/hdb | grep hdb 
if [ $? = 1 ]; then
	echo "Cannot find HDD"
	exit 0
fi

/sbin/fdisk -l /dev/hdb | grep hdb1 | grep Linux
if [ $? = 1 ]; then
	echo "Cannot find valid partion info"
	#/DISK1/hdd_tools/format_hdb.sh
fi

/sbin/hdparm -X udma2 /dev/hdb
/sbin/hdparm -c 3 /dev/hdb

mkdir -p /DATA/hdb1
/bin/mount /dev/hdb1 /DATA/hdb1
if [ $? = 1 ]; then		
	echo "fail to mount /dev/hdb1"
	exit 0
fi

touch /tmp/HAVE_HDD

chmod 777 /DATA/hdb1

if [ ! -e /DATA/hdb1/movie ]; then
echo "make dir /DATA/hdb1/movie"
/bin/mkdir -p /DATA/hdb1/movie
fi
rmdir /DATA/movie
/bin/ln -s /DATA/hdb1/movie /DATA/movie

if [ ! -e /DATA/hdb1/picture ]; then
echo "make dir /DATA/hdb1/picture"
/bin/mkdir -p /DATA/hdb1/picture
fi
rmdir /DATA/picture
/bin/ln -s /DATA/hdb1/picture /DATA/picture

if [ ! -e /DATA/hdb1/music ]; then
echo "make dir /DATA/hdb1/music"
/bin/mkdir -p /DATA/hdb1/music
fi
rmdir /DATA/music
/bin/ln -s /DATA/hdb1/music /DATA/music

if [ ! -e /DATA/hdb1/recording ]; then
echo "make dir /DATA/hdb1/recording"
/bin/mkdir -p /DATA/hdb1/recording
fi
rmdir /DATA/recording
/bin/ln -s /DATA/hdb1/recording /DATA/recording

if [ ! -e /DATA/hdb1/recordfile ]; then
echo "make dir /DATA/hdb1/recordfile"
/bin/mkdir -p /DATA/hdb1/recordfile
fi
rmdir /DATA/recordfile
/bin/ln -s /DATA/hdb1/recordfile /DATA/recordfile

if [ ! -e /DATA/hdb1/pvrfile ]; then
echo "make dir /DATA/hdb1/pvrfile"
/bin/mkdir -p /DATA/hdb1/pvrfile
fi
rmdir /DATA/pvrfile
/bin/ln -s /DATA/hdb1/pvrfile /DATA/pvrfile

if [ ! -e /DATA/hdb1/download ]; then
echo "make dir /DATA/hdb1/download"
/bin/mkdir -p /DATA/hdb1/download
fi
rmdir /DATA/download
/bin/ln -s /DATA/hdb1/download /DATA/download

if [ ! -e /DATA/hdb1/upnp ]; then
echo "make dir /DATA/hdb1/upnp"
/bin/mkdir -p /DATA/hdb1/upnp
fi
rmdir /DATA/upnp
/bin/ln -s /DATA/hdb1/upnp /DATA/upnp


