diff packaging/linux-installer.inc.in @ 764:5b505acbb2d1

Handle system wide installation for crontab.
author Sascha Wilde <wilde@intevation.de>
date Fri, 04 Jul 2014 18:41:23 +0200
parents 654a8ca9d5b4
children 7c3a8a8d3e52
line wrap: on
line diff
--- a/packaging/linux-installer.inc.in	Fri Jul 04 18:06:23 2014 +0200
+++ b/packaging/linux-installer.inc.in	Fri Jul 04 18:41:23 2014 +0200
@@ -199,15 +199,19 @@
 
 setup_cronjob()
 {
-  # FIXME: handle case of system wide installation.
   local tmpcrontab=`mktemp`
-  crontab -l | grep -vF "${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh" \
-                    >"$tmpcrontab"
+  local crontabopt=''
+  if [ $SYSINST -eq 1 -a "${SUDO_USER+X}" ] ; then
+      crontabopt="-u $SUDO_USER"
+  fi
+  crontab $crontabopt -l | \
+      grep -vF "${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh" \
+           >"$tmpcrontab"
   if [ "$1" != "deinstall" ] ; then
       echo "$(( $RANDOM / 555 )) 12  * * * \"${instcfg[PREFIX]}/bin/trustbridge-tray-starter.sh\"" \
            >>"$tmpcrontab"
   fi
-  crontab "$tmpcrontab"
+  crontab $crontabopt "$tmpcrontab"
   rm "$tmpcrontab"
 }
 

http://wald.intevation.org/projects/trustbridge/