# -*- Mode: sh; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; coding: utf-8-unix; -*-
# @version $Id: begin.sh 74 2009-02-05 05:26:55Z yamaura $
# @revision $Revision: 1876 $
# @author $Author: mmiyoshi $
# @date $Date: 2008-02-24 10:05:06 +0900 (Sun, 24 Feb 2008) $

GLIBCXX_FORCE_NEW=1
__GL_SYNC_TO_VBLANK=1
pushd /home/disk0

# -----------------------------------------------------------------------------------------
function repartion {
    parted -s /dev/hdb rm 8 > /dev/null 
    parted -s /dev/hdb rm 7 > /dev/null 
    parted -s /dev/hdb rm 6 > /dev/null 
    parted -s /dev/hdb rm 5 > /dev/null 
    range=$(parted -s /dev/hdb p | awk "/^4/{print int(\$2) \" \" int(\$2)+4096}") 
    parted -s /dev/hdb mkpart logical ext3 $range > /dev/null 
    mkfs.ext3 -L SBST /dev/hdb5 
}


function remount {
    mount -t ext3 -o data=journal -o sync /dev/hdb5 /home/disk9 
}



# -----------------------------------------------------------------------------------------
if [ ! -e /dev/hdb5 ]; then
    repartion
    echo "not found dev hdb5 partion division"
fi

gameid=$(dumpe2fs -h /dev/hdb5 | awk "/^Filesystem volume name/{print \$NF}") 

echo $gameid

#if [ $gameid != "SBST" ];then
#    repartion
#   echo "partion division"
#else
#    echo "not partion division"
#fi

remount
echo "mount ok"

CHK_DIR="/home/disk9/ghost"
if [ ! -d ${CHK_DIR} ];then
     mkdir ${CHK_DIR}
     echo "ghost directory make"
fi


