# -*- upstart -*-
description "lufi"
author "Luc Didry <luc@didry.org>"

start on (networking)
stop on runlevel [!2345]

script
  if [ -f "/etc/default/lufi" ]
  then
    . /etc/default/lufi
    if [ -z $LDIR ]
    then
      echo "LDIR variable is empty, please fill it in /etc/default/lufi"
      exit 0
    fi
    if [ -z $USER ]
    then
      echo "USER variable is empty, please fill it in /etc/default/lufi"
      exit 0
    fi
  else
    echo "Missing /etc/default/lufi file"
    exit 0
  fi
  cd $LDIR
  su $USER -c "carton exec hypnotoad -f script/lufi"
end script
