#!/bin/sh -e

# The cereal scripts were written by
# Jameson Graef Rollins <jrollins@finestructure.net>
# and
# Daniel Kahn Gillmor <dkg@fifthhorseman.net>.
#
# They are Copyright 2007, and are all released under the GPL, version 3
# or later.

exec 2>./socket 1>&2

SHAREDIR="/usr/share/cereal"
export SHAREDIR

# check the exit code of run, and remove the lock if it's NOT 73
# (which is exit code of lockfile if a lock file already existed).
RUN_EXIT_CODE="$1"
if [ "$RUN_EXIT_CODE" != 73 ] ; then
    exec chpst -e ./env sh -c ". $SHAREDIR/common && remove_lock"
fi
