#!/bin/bash

#-----------------------------------------------------------
# $Id: unlock.sh 85 2008-05-14 13:09:48Z rosiere $
#-----------------------------------------------------------

#-----[ usage ]---------------------------------------------
function usage ()
{
    echo "Usage     : ${0} file";
    echo "Arguments : ";
    echo ' * file : you can see the lock at "${MORPHEO_HOME}/lock/$(basename file).lock"';
    echo "Notes     :";
    echo " * Morpheo's environnement must be positionned.";

    exit;
}

#-----[ unlock ]--------------------------------------------
function unlock ()
{
    rm -f ${1};
}

#-----[ main ]----------------------------------------------
function main ()
{
    LOCK_DIRECTORY="${MORPHEO_HOME}/lock";

    if test ${#} -ne 1 -o -z ${MORPHEO_HOME} -o ! -d ${LOCK_DIRECTORY}; then
	usage ${*};
    fi;

    unlock "${LOCK_DIRECTORY}/$(basename ${1}).lock"
}

#-----[ Corps ]---------------------------------------------
main ${*}
