Index: branches/fc15-dev/server/common/oursrc/tokensys/configure.in
===================================================================
--- branches/fc15-dev/server/common/oursrc/tokensys/configure.in	(revision 2062)
+++ branches/fc15-dev/server/common/oursrc/tokensys/configure.in	(revision 2063)
@@ -24,4 +24,13 @@
 REQUIRE_PATH(aklog)
 
+AC_ARG_WITH(fs,
+[  --with-fs[=PATH]          fs is located at PATH],[
+  if test "$withval" != "no" -a "$withval" != "yes"; then
+    fs_path="$withval"
+  fi
+])
+REQUIRE_PATH(fs)
+
 AC_OUTPUT(Makefile)
 AC_OUTPUT(renew)
+AC_OUTPUT(scripts-afsagent-startup)
Index: branches/fc15-dev/server/common/oursrc/tokensys/crontab
===================================================================
--- branches/fc15-dev/server/common/oursrc/tokensys/crontab	(revision 2062)
+++ 	(revision )
@@ -1,2 +1,0 @@
-@reboot	afsagent /home/afsagent/renew
-0 */3 * * * afsagent /home/afsagent/renew
Index: branches/fc15-dev/server/common/oursrc/tokensys/renew.in
===================================================================
--- branches/fc15-dev/server/common/oursrc/tokensys/renew.in	(revision 2062)
+++ branches/fc15-dev/server/common/oursrc/tokensys/renew.in	(revision 2063)
@@ -2,5 +2,5 @@
 
 # This script renews afsagent's tickets and tokens.
-# It is called by afsagent's crontab every 8 hours.
+# It is called by systemd on a regular schedule.
 
 export KRB5CCNAME=/home/afsagent/krb5cc
Index: branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent-startup.in
===================================================================
--- branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent-startup.in	(revision 2063)
+++ branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent-startup.in	(revision 2063)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+/sbin/sysctl -q afs.GCPAGs=0
+@fs_path@ setcrypt on
+@fs_path@ sysname 'amd64_fedora15_scripts' 'amd64_fedora13_scripts' 'amd64_fedora11_scripts' 'amd64_fedora9_scripts' 'amd64_fedora7_scripts' 'scripts' 'amd64_fedora15' 'amd64_fedora13' 'amd64_fedora11' 'amd64_fedora9' 'amd64_fedora7' 'amd64_linux26' 'i386_deb60' 'i386_deb50' 'i386_deb40' 'i386_rhel4' 'i386_rhel3' 'i386_rh9' 'i386_linux26' 'i386_linux24' 'i386_linux22' 'i386_linux3' 'i386_linux2'
+
+@fs_path@ setcell -nosuid -c athena
Index: branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent-startup.service
===================================================================
--- branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent-startup.service	(revision 2063)
+++ branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent-startup.service	(revision 2063)
@@ -0,0 +1,12 @@
+[Unit]
+Description=Scripts AFS Configuration Service
+After=syslog.target openafs-client.service
+Before=crond.service
+Requires=openafs-client.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/local/libexec/scripts-afsagent-startup
+
+[Install]
+WantedBy=multi-user.target remote-fs.target crond.service
Index: branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent.service
===================================================================
--- branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent.service	(revision 2063)
+++ branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent.service	(revision 2063)
@@ -0,0 +1,13 @@
+[Unit]
+Description=Scripts afsagent Service
+After=syslog.target openafs-client.service
+Before=crond.service
+Requires=openafs-client.service
+
+[Service]
+Type=oneshot
+ExecStart=/home/afsagent/renew
+User=afsagent
+
+[Install]
+WantedBy=multi-user.target remote-fs.target crond.service
Index: branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent.timer
===================================================================
--- branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent.timer	(revision 2063)
+++ branches/fc15-dev/server/common/oursrc/tokensys/scripts-afsagent.timer	(revision 2063)
@@ -0,0 +1,9 @@
+[Unit]
+Description=Scripts afsagent periodic renew
+
+[Timer]
+Unit=scripts-afsagent.service
+OnUnitActiveSec=3h
+
+[Install]
+WantedBy=multi-user.target remote-fs.target
Index: branches/fc15-dev/server/fedora/config/etc/rc.d/rc.local
===================================================================
--- branches/fc15-dev/server/fedora/config/etc/rc.d/rc.local	(revision 2062)
+++ branches/fc15-dev/server/fedora/config/etc/rc.d/rc.local	(revision 2063)
@@ -4,11 +4,2 @@
 
 /bin/mkdir -pm 1773 /tmp/sessions
-
-#### Set the AFS sysname. Ideally, this should go elsewhere, but this
-#### is a horrible hack to clean up after another horrible hack, so...
-
-/sbin/sysctl -q afs.GCPAGs=0
-/usr/bin/fs setcrypt on
-/usr/bin/fs sysname 'amd64_fedora15_scripts' 'amd64_fedora13_scripts' 'amd64_fedora11_scripts' 'amd64_fedora9_scripts' 'amd64_fedora7_scripts' 'scripts' 'amd64_fedora15' 'amd64_fedora13' 'amd64_fedora11' 'amd64_fedora9' 'amd64_fedora7' 'amd64_linux26' 'i386_deb60' 'i386_deb50' 'i386_deb40' 'i386_rhel4' 'i386_rhel3' 'i386_rh9' 'i386_linux26' 'i386_linux24' 'i386_linux22' 'i386_linux3' 'i386_linux2'
-
-/usr/bin/fs setcell -nosuid -c athena
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
