I’ve had Google Desktop for Linux running for a while now; I can’t actually say I’ve used it all that much, but what I did very quickly observe was that the default cronjob (/etc/cron.hourly/gdl-update) that checks for updates had far too much output (I do not want hourly updates telling me “not going to update now”, kthx). And some spelling mistakes.
Here’s an improved version that only sends you email if something of note has happened (update occurred; update failed unexpectedly; can’t create or update timestamp file):
#!/bin/bash
# Copyright 2007 Google Inc. All Rights Reserved.
CACHE_DIR="/var/cache/google/desktop"
PREFIX="/opt/google/desktop"
GDL_UPDATE="/opt/google/desktop/bin/gdl_update"
PKG_FORMAT="deb"
PKG_UPGRADE_CMD="dpkg -i --refuse-downgrade"
TIMESTAMP_FILE="/var/cache/google/desktop/update_timestamp"
ID_FILE="/var/cache/google/desktop/id"
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
if [ ! -x "$GDL_UPDATE" ]; then
echo "gdl_update is not available."
exit 1
fi
# run gdl_update
export PATH
DO_UPDATE=no
if [ ! -e $TIMESTAMP_FILE ]; then
if touch $TIMESTAMP_FILE; then
DO_UPDATE=yes
else
echo "Failed to create timestamp file."
fi
else
LAST=`date -u -r $TIMESTAMP_FILE +%s`
NOW=`date -u +%s`
DELAY=`expr 86400 + $RANDOM % 21600`
DIFF=`expr $NOW - $LAST`
# Update should only be occurred every 24 to 30 (randomly) hours.
if [ $DIFF -gt $DELAY ]; then
if touch $TIMESTAMP_FILE; then
DO_UPDATE=yes
else
echo "Failed to update timestamp file."
fi
fi
fi
if [ "$DO_UPDATE" != "yes" ]; then
exit 0
fi
UUID=""
if [ ! -f "$ID_FILE" ]; then
UUIDGEN=`which uuidgen`
if [ -n "$UUIDGEN" -a -x "$UUIDGEN" ]; then
$UUIDGEN > $ID_FILE
chmod 644 $ID_FILE
fi
fi
UUID=`cat $ID_FILE`
if [ "$UUID" = "" ]; then
UUID="0"
fi
NEW_PKG=`LD_LIBRARY_PATH="/opt/google/desktop/lib:$LD_LIBRARY_PATH" $GDL_UPDATE "$PKG_FORMAT" "$UUID" 2>&1`
# Note spelling error (appears to be in gdl-update binary so can't readily be removed)
if [ "$NEW_PKG" = "unavaliable" ]; then
# echo "Package is not available
exit 0
fi
# update package is successfully downloaded
if [ $? -eq 0 ] && [ -f "$NEW_PKG" ]; then
dpkg -i --refuse-downgrade "$NEW_PKG"
if [ $? -eq 0 ]; then
echo "Updated successfully."
else
echo "Update failed."
fi
rm -f "$NEW_PKG"
fi

