#!/bin/sh
cd /var/lib/cpm/run
while true; do
  # load any server arguments
  [ -r /etc/cpm/config ] && source /etc/cpm/config
  SERVERARGS="${SERVERARGS:--v 0}"
  # run the server
  gdb /usr/bin/CSserverd.bin << __EOF
    handle SIGPIPE nostop
    r ${SERVERARGS}
    bt
    q
    y
__EOF
  # wait a little before restarting it
  sleep 5
done
