diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index e69de29..0000000 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e2bc77 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +shmpps.tar diff --git a/Makefile b/Makefile deleted file mode 100644 index f3d1379..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: shmpps -# $Id$ -NAME := shmpps -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/shmpps.init b/shmpps.init new file mode 100644 index 0000000..e3fac95 --- /dev/null +++ b/shmpps.init @@ -0,0 +1,65 @@ +#!/bin/sh +# +# shmpps This shell script takes care of starting and stopping +# the shared memory PPS driver. +# +# chkconfig: - 58 74 +# description: shm_splc2 is the shared memory PPS driver for NTP + +# Source function library +. /etc/init.d/functions + +prog=shm_splc2 +lockfile=/var/lock/subsys/$prog + +start() { + [ -x /usr/sbin/shm_splc2 ] || exit 5 + + [ -f /etc/sysconfig/shmpps ] || exit 6 + . /etc/sysconfig/shmpps + + echo -n $"Starting $prog: " + daemon $prog $OPTIONS + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && touch $lockfile + return $RETVAL +} + +stop() { + echo -n $"Shutting down $prog: " + killproc $prog + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f $lockfile + return $RETVAL +} + +# See how we were called +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status $prog + ;; + restart|force-reload) + stop + start + ;; + try-restart|condrestart) + if [ -f $lockfile ]; then + stop + start + fi + ;; + reload) + exit 3 + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}" + exit 2 +esac diff --git a/shmpps.spec b/shmpps.spec new file mode 100644 index 0000000..89198d2 --- /dev/null +++ b/shmpps.spec @@ -0,0 +1,68 @@ +Name: shmpps +Version: 1.03 +Release: 1%{?dist} +Summary: Shared Memory driver for PPS time signals + +Group: System Environment/Daemons +License: Public Domain and MIT +URL: http://time.qnan.org/ +Source0: http://time.qnan.org/%{name}.tar +Source1: shmpps.init +Source2: shmpps.sysconfig +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +Requires: ntp +Requires(post): /sbin/chkconfig +Requires(preun): /sbin/chkconfig /sbin/service +Requires(postun): /sbin/service + +%description +Shared memory (SHM) driver to allow high-resolution pulse-per-second +(PPS) time sources to be used with a Network Time Protocol (NTP) server +without a PPS-enabled kernel. The PPS pin of the time source must be +connected to the declared signal pin on a serial or parallel port. + +See /etc/sysconfig/shmpps for configuration. + +%prep +%setup -q -n %{name} +sed -i \ + -e 's/#undef *DOPARALLEL/#define DOPARALLEL/' \ + shm_splc2.c + +%build +make CFLAGS="%{optflags}" LDFLAGS="" + +%install +rm -rf %{buildroot} +install -p -m755 -D shm_splc2 %{buildroot}%{_sbindir}/shm_splc2 +install -p -m755 -D %{SOURCE1} %{buildroot}%{_initrddir}/shmpps +install -p -m644 -D %{SOURCE2} %{buildroot}%{_sysconfdir}/sysconfig/shmpps + +%clean +rm -rf %{buildroot} + +%post +/sbin/chkconfig --add shmpps + +%preun +if [ "$1" -eq 0 ]; then + /sbin/service shmpps stop > /dev/null 2>&1 + /sbin/chkconfig --del shmpps +fi + +%postun +if [ "$1" -ge 1 ]; then + /sbin/service shmpps condrestart > /dev/null 2>&1 +fi + +%files +%defattr(-,root,root,-) +%{_sbindir}/shm_splc2 +%{_initrddir}/shmpps +%config(noreplace) %{_sysconfdir}/sysconfig/shmpps + +%changelog +* Sat Nov 22 2008 Chris Adams 1.03-1 +- initial package + diff --git a/shmpps.sysconfig b/shmpps.sysconfig new file mode 100644 index 0000000..f75f356 --- /dev/null +++ b/shmpps.sysconfig @@ -0,0 +1,26 @@ +######################################################################## +# Usage: +# shm -d/dev/device -s (serial) or -p (parallel) -u (unit) +# -c -l (line) -f -D +# +# -c sets second boundary on hi->lo transition for serial +# -l line defines serial line being sampled: DCD CTS DSR +# -f sets pin 14 flapping on parallel i/f +# +# -D debug level, may be repeated: +# No. of -D +# 0 normal operation: daemonize; no reporting +# 1 + no daemonization; progress reports to stderr +# 2 + out-of-range reports +# 3 + no updating SHM +# +# (wire PPS to parallel pin 10, ground to 18, echo out to 14) +# +# Configure ntpd to use this as a time source in ntp.conf like: +# server 127.127.28.3 minpoll 4 maxpoll 4 prefer +# fudge 127.127.28.3 refid GPS +######################################################################## +# For serial DCD +OPTIONS="-d /dev/gps0 -s -u 0 -l DCD" +# For parallel +#OPTIONS="-d /dev/parport0 -p -u 0 -l DCD" diff --git a/sources b/sources index e69de29..f5d9614 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +a55d2a3c51c7810cfd3e2adb08f55d02 shmpps.tar