#!/bin/sh
# log_shipper - tail /dump/*.log and push them to Loki (see shipper/README.md).
# Config comes from the environment; defaults in the binary match the machine.
# The shipper's own complaints land in /dump/logshipper.log (a few lines a boot).

case "$1" in
  start)
    start-stop-daemon -S -b -m -p /run/logshipper.pid -x /bin/sh \
        -- -c 'exec /usr/local/bin/logshipper >>/dump/logshipper.log 2>&1'
    ;;
  stop)
    start-stop-daemon -K -p /run/logshipper.pid
    ;;
  restart)
    "$0" stop
    sleep 1
    "$0" start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
    exit 1
    ;;
esac
