#!/bin/bash
lockfile=${TMP:-/tmp}/${0##*/}
while true
do
    if ln -s $$ ${lockfile} 2> /dev/null
    then
        # lock gain.
        break
    else
        # get pid from lock file when locked.
        if [ -d /proc/`ls -l ${lockfile} | sed 's!.* !!g'` ]
        then
            # process exists.
            echo "${0##*/}: exist another instance" 1>&2
            exit 1
        else
            # remove lockfile and retry.
            rm -f ${lockfile}
        fi
    fi
done
trap 'rm -f ${lockfile}; exit' 0 1 2 3 11 15
exec python2 /var/www/html/libre10/libre10_exec.py $@
