#!/bin/bash

LOCK_FILE="stocks-lg.flock"
LOCK_DIR="/tmp"
LOCK_FD=200

lock () {
  eval "exec ${LOCK_FD}>${LOCK_DIR}/${LOCK_FILE}"

  flock -n ${LOCK_FD} \
    && return 0 \
    || return 1
}

doLgExport () {
  /opt/www/stocks3/lg.sh >/dev/null 2>&1
}

main () {
  lock || exit 1

  doLgExport
}

main
