#! /bin/sh

set -e

# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

DESC="Hardware init"

case "$1" in
	start)
		echo -n "Starting $DESC: "
		# Symlink for legacy GPS
		ln -sf /dev/ttyTX0 /dev/gps

		# Set pps symlink for ntpd
		ln -sf /dev/pps0 /dev/gpspps0

		echo_success
		echo
	;;
	stop)
		echo -n "Stopping $DESC: "
		echo_success
		echo
      ;;
	restart|force-reload)
        echo "Restarting $DESC: "
        $0 stop
        sleep 1
        $0 start
        echo ""
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0
