#!/usr/bin/sh
#
# Wrapper for msecperms.py
#

if [ "`whoami`" != "root" ]; then
    echo 'msec: sorry, you must be root !'
    exit 1
fi

LCK=/run/msec.pid

function cleanup() {
    rm -f $LCK
}

if [ -f $LCK ]; then
    if [ -d /proc/`cat $LCK` ]; then
    	exit 0
    else
    	rm -f $LCK
    fi
fi

echo -n $$ > $LCK

trap cleanup 0

MSEC=/usr/share/msec/msecperms.py
OPT="$@"

exec $MSEC $OPT

# msec ends here
