Index: branches/fc15-dev/server/fedora/specs/tokensys.spec
===================================================================
--- branches/fc15-dev/server/fedora/specs/tokensys.spec	(revision 2062)
+++ branches/fc15-dev/server/fedora/specs/tokensys.spec	(revision 2063)
@@ -11,4 +11,8 @@
 %define debug_package %{nil}
 Prereq: /usr/bin/kinit, /usr/bin/aklog
+Requires(post): systemd-units
+Requires(preun): systemd-units
+Requires(postun): systemd-units
+BuildRequires: systemd-units
 
 %description
@@ -17,5 +21,6 @@
 Contains:
  - A shell script for renewing the scripts AFS credentials <renew>
- - A crontab for calling the renew script <crontab>
+ - A shell script for configuring scripts AFS <scripts-afsagent-startup>
+ - systemd units for running the above
 See http://scripts.mit.edu/wiki for more information.
 
@@ -24,10 +29,13 @@
 
 %build
-./configure --with-kinit=/usr/bin/kinit --with-aklog=/usr/bin/aklog
+./configure --with-kinit=/usr/bin/kinit --with-aklog=/usr/bin/aklog --with-fs=/usr/bin/fs
 
 %install
 [ $RPM_BUILD_ROOT != / ] && rm -rf $RPM_BUILD_ROOT
 install -D renew $RPM_BUILD_ROOT/home/afsagent/renew
-install -D crontab $RPM_BUILD_ROOT/etc/cron.d/afsagent
+install -D scripts-afsagent-startup $RPM_BUILD_ROOT/usr/local/libexec/scripts-afsagent-startup
+install -D scripts-afsagent-startup.service $RPM_BUILD_ROOT%{_unitdir}/scripts-afsagent-startup.service
+install -D scripts-afsagent.service $RPM_BUILD_ROOT%{_unitdir}/scripts-afsagent.service
+install -D scripts-afsagent.timer $RPM_BUILD_ROOT%{_unitdir}/scripts-afsagent.timer
 
 %clean
@@ -35,8 +43,10 @@
 
 %files
-%defattr(0600, root, root)
-/etc/cron.d/afsagent
+%defattr(0644,root,root)
+%{_unitdir}/*.service
+%{_unitdir}/*.timer
 %defattr(0755, afsagent, afsagent)
 /home/afsagent/renew
+/usr/local/libexec/scripts-afsagent-startup
 
 %pre
@@ -44,5 +54,32 @@
 useradd -u 101 -g 101 afsagent || [ $? -eq 9 ]
 
+%post
+/bin/systemctl enable scripts-afsagent-startup.service >/dev/null 2>&1 || :
+/bin/systemctl enable scripts-afsagent.service >/dev/null 2>&1 || :
+/bin/systemctl enable scripts-afsagent.timer >/dev/null 2>&1 || :
+
+if [ $1 -eq 1 ] ; then 
+    # Initial installation 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+
+%preun
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable scripts-afsagent-startup.service > /dev/null 2>&1 || :
+    /bin/systemctl --no-reload disable scripts-afsagent.service > /dev/null 2>&1 || :
+    /bin/systemctl --no-reload disable scripts-afsagent.timer > /dev/null 2>&1 || :
+    /bin/systemctl stop scripts-afsagent-startup.service > /dev/null 2>&1 || :
+    /bin/systemctl stop scripts-afsagent.service > /dev/null 2>&1 || :
+    /bin/systemctl stop scripts-afsagent.timer > /dev/null 2>&1 || :
+fi
+
 %postun
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart scripts-afsagent.service >/dev/null 2>&1 || :
+fi
+
 if [ "$1" = "0" ] ; then
    userdel -r afsagent
@@ -50,4 +87,8 @@
 
 %changelog
+* Mon Nov 21 2011  Quentin Smith <quentin@mit.edu>
+- add systemd units
+- remove crontab
+
 * Tue Aug 17 2010  Geoffrey Thomas <geofft@mit.edu>
 - aklog csail as well
