[PATCH 2 of 5] Handle system wide installation for crontab

Wald Commits scm-commit at wald.intevation.org
Tue Jul 8 11:36:44 CEST 2014


# HG changeset patch
# User Sascha Wilde <wilde at intevation.de>
# Date 1404492083 -7200
# Node ID 5b505acbb2d156892b8ac2cf4b2cefe8abb263b4
# Parent  654a8ca9d5b4b577f16488e2bfe98cf003c6c34c
Handle system wide installation for crontab.

diff -r 654a8ca9d5b4 -r 5b505acbb2d1 packaging/linux-installer.inc.in
--- 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"
 }
 


More information about the Trustbridge-commits mailing list