#!/bin/sh
echo `google-chrome-stable --version` > /tmp/chroverold
oldversion=`cat /tmp/chroverold`
cd /
urxvt -e wget http://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
yaf-splash -wrap false -bg lightgreen -border false -margin 0 -fg black -placement top -timeout 3 -text "       installing     "
dpkg-deb -x /google-chrome-stable_current_amd64.deb /
rm /google-chrome-stable_current_amd64.deb
rm /opt/google/chrome/google-chrome.bin
mv /opt/google/chrome/google-chrome /opt/google/chrome/google-chrome.bin
   echo '#!/bin/sh
   APP='/opt/google/chrome/google-chrome.bin'
#script to run $APP as spot...
ARGS=""
[ "$1" ] && while [ "$1" ]; do ARGS="$ARGS \"$1\""; shift; done
if [ $(id -u) -eq 0 ]; then
 [ $XAUTHORITY ] && cp $XAUTHORITY /root/spot/.Xauthority 2>/dev/null
 touch /root/spot/.Xauthority
 #following line is mostly there to catch any root:root files that may have got copied in...
 find /root/spot \( -not -user spot -or -not -group spot \) -exec chown -h spot:spot {} \; &
 export XAUTHORITY=/root/spot/.Xauthority  
 export XDG_CONFIG_HOME=/root/spot/.config
 export XDG_CACHE_HOME=/root/spot/.cache
 export XDG_DATA_HOME=/root/spot/.local/share
 exec su spot -s /bin/sh -c "\"$APP\" $ARGS"
else #precaution
 exec "$APP" "$ARGS"
fi' > /opt/google/chrome/google-chrome 
chmod 755 /opt/google/chrome/google-chrome
   echo '[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=Google Chrome web browser
GenericName=Google Chrome
Comment=Google Chrome web browser
Exec=google-chrome-stable
Terminal=false
Type=Application
Icon=/opt/google/chrome/product_logo_128.png
Categories=WebBrowser;' > /usr/share/applications/google-chrome.desktop
chmod 755 /initrd/pup_rw
fixmenus
jwm -restart
echo `google-chrome-stable --version` > /tmp/chrover
version=`cat /tmp/chrover`
yaf-splash -wrap false -bg lightgreen -border false -margin 0 -fg black -placement top -text "                   $oldversion Updated to $version  "