#!/bin/bash
LOCK="/home/${USER}/dlrn.lock"
set -e

exec 200>$LOCK
flock -n 200 || exit 1

if [ ! -d /home/${USER}/dlrn-logs ]
then
    mkdir -p /home/${USER}/dlrn-logs
fi

source ~/.venv/bin/activate
LOGFILE=/home/${USER}/dlrn-logs/dlrn-run.$(date +%s).log
cd ~/dlrn

echo `date` "Starting DLRN run." >> $LOGFILE
dlrn --config-file /usr/local/share/dlrn/${USER}/projects.ini --info-repo /home/rdoinfo/rdoinfo/ 2>> $LOGFILE
echo `date` "DLRN run complete." >> $LOGFILE

#!/bin/bash
LOCK="/home/${USER}/dlrn.lock"
set -e

# if any arguments are given, assume console foreground execution
ARG=$1

exec 200>$LOCK
if !  flock -n 200
then
    if [ -n "$ARG" ]
    then
        echo "DLRN ${USER} running, please try again after disabling it."
    fi
    exit 1
fi

if [ ! -d /home/${USER}/dlrn-logs ]
then
    mkdir -p /home/${USER}/dlrn-logs
fi

source ~/.venv/bin/activate
if [ -n "$ARG" ]
then
    LOGFILE=/home/${USER}/dlrn-logs/dlrn-run.console.$(date +%s).log
else
    LOGFILE=/home/${USER}/dlrn-logs/dlrn-run.$(date +%s).log
fi
cd ~/dlrn

set +e
echo `date` "Starting DLRN run." >> $LOGFILE
dlrn --config-file /usr/local/share/dlrn/${USER}/projects.ini --info-repo /home/rdoinfo/rdoinfo/ "$@" 2>> $LOGFILE
RET=$?
echo `date` "DLRN run complete." >> $LOGFILE

if [ -n "$ARG" ]
then
    echo Arguments: "$@"
    cat $LOGFILE
fi
exit $RET

Support for standalone console use-case
Support for standalone console use-case

e.g. running with --recheck

Implements https://github.com/rdo-infra/puppet-dlrn/issues/18
