hotfix updater script
authorMichael Mrozek <EvilDragon@openpandora.de>
Wed, 16 Jun 2010 22:34:05 +0000 (01:34 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Wed, 16 Jun 2010 22:35:31 +0000 (01:35 +0300)
hotfix_updater/updater.sh [new file with mode: 0755]

diff --git a/hotfix_updater/updater.sh b/hotfix_updater/updater.sh
new file mode 100755 (executable)
index 0000000..3abcd87
--- /dev/null
@@ -0,0 +1,209 @@
+#!/bin/bash
+
+oldkern2=b00a5d617f11366689488395b19411de
+oldkern1=3112d1782a90c2c87ae17a152a35deae
+newkern=aed218fe59ff93618bddd2b52b020014
+currkern=$(md5sum /boot/uImage | cut -d" " -f1)
+needfree=$(ls -lk uImage | grep uImage | cut -d" " -f5)
+oldinterfaces=23f72750f2f7335b9c2ed3f55aaa5061
+oldrcwl1251=7a6361e842f0f589418218436affbe07
+newmmenu=af66a5118a9bfef8eca5de13ee64c6a1
+oldmmenu1=d15bf3ad29f12fa2325534b8fcd5c1f4
+oldmmenu2=fa45e9bc91c48640a9ea592de5fbeb3c
+currmmenu=$(md5sum /usr/bin/mmenu | cut -d" " -f1)
+currmmenuconf=$(md5sum /etc/pandora/conf/mmenu.conf | cut -d" " -f1)
+err="Your system has been updated without any errors."
+
+rm /tmp/updater.log
+
+if zenity --question --title="Update Package 2" --text="This PND updates your Pandora OS. You can safely delete it after it has finished.\nThis pack includes all updates from Hotfix 1 as well.\n\nDo you want to start the upgrade now? " --ok-label="Start now" --cancel-label="Don't do it" ; then
+
+(
+echo "10"
+echo "# Updating kernel if needed"
+
+
+# Kernel Update
+
+  if [ $oldkern1 = $currkern -o $oldkern2 = $currkern ]; then   
+     rm /boot/uImage.old 
+     currfree=$(df /boot | grep boot | awk '{print $4}')
+     if [ $currfree -lt $needfree ]; then
+        err="There is not enough diskspace on /boot/ to update the kernel.\n\nKernel couldn't be updated."
+        echo "Kernel not updated - not enough diskspace on /boot/" >> /tmp/updater.log
+      else
+        cp uImage /boot/uImage.new 
+        sync
+        currkern=$(md5sum /boot/uImage.new | cut -d" " -f1)
+          if [ $currkern = $newkern ]; then
+            mv /boot/uImage /boot/uImage.old 
+            mv /boot/uImage.new /boot/uImage 
+            currkern=$(md5sum /boot/uImage | cut -d" " -f1)
+            if [ $currkern != $newkern ]; then
+               rm /boot/uImage 
+               mv /boot/uImage.old /boot/uImage 
+               err="There was a checksum error while copying the kernel.\n\nKernel couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
+               echo "Kernel not updated - checksum error" >> /tmp/updater.log
+            fi
+          else
+            rm /boot/uImage.new 
+            err="There was a checksum error while copying the kernel.\n\nKernel couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
+            echo "Kernel not updated - checksum error" >> /tmp/updater.log
+          fi
+     fi
+    echo "Kernel successfully updated" >> /tmp/updater.log
+    sync
+  else
+    echo "Kernel already up-to-date" >> /tmp/updater.log
+  fi
+  
+
+# HotFix 1
+
+# Libraries for HotFix 1
+  
+echo "20"
+echo "# Installing missing Python libraries"
+if [ "`opkg list-installed | grep python-shell`" ]; then
+   echo "Python libraries were already installed." >> /tmp/updater.log
+else 
+  opkg install 1/gnome-vfs-plugin-ftp_2.24.1-r2.5_armv7a.ipk 1/gnome-vfs-plugin-http_2.24.1-r2.5_armv7a.ipk 1/python-pycairo_1.4.0-ml3.5_armv7a.ipk 1/python-pygtk_2.16.0-r1.5_armv7a.ipk 1/python-shell_2.6.4-ml9.1.5_armv7a.ipk 
+  echo "Python libraries installed" >> /tmp/updater.log
+  sync
+fi
+
+# HotFix 2
+# MiniMenu Update
+
+echo "30"
+echo "# Installing updated MiniMenu"
+if [ $oldmmenu1 = $currmmenu -o $oldmmenu2 = $currmmenu ]; then   
+     echo temp
+     rm /usr/bin/mmenu.old 
+     cp 2/mmenu /usr/bin/mmenu.new 
+     cp 2/mmenu.conf /etc/pandora/conf/mmenu.conf.new 
+        sync
+        currmmenu=$(md5sum /usr/bin/mmenu.new | cut -d" " -f1)
+          if [ $currmmenu = $newmmenu ]; then
+            mv /usr/bin/mmenu /usr/bin/mmenu.old 
+            mv /etc/pandora/conf/mmenu.conf /etc/pandora/conf/mmenu.conf.old 
+            mv /usr/bin/mmenu.new /usr/bin/mmenu 
+            mv /etc/pandora/conf/mmenu.conf.new /etc/pandora/conf/mmenu.conf 
+            currmmenu=$(md5sum /usr/bin/mmenu | cut -d" " -f1)
+            if [ $currmmenu != $newmmenu ]; then
+               rm /usr/bin/mmenu 
+              rm /etc/pandora/conf/mmenu.conf 
+               mv /etc/pandora/conf/mmenu.conf.old /etc/pandora/conf/mmenu.conf 
+               mv /usr/bin/mmenu.old /usr/bin/mmenu 
+               err="There was a checksum error while copying MiniMenu.\n\nMiniMenu couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
+               echo "MiniMenu not updated - checksum error" >> /tmp/updater.log
+            fi
+          else
+            rm /usr/bin/mmenu.new 
+            rm /etc/pandora/conf/mmenu.conf.new 
+            err="There was a checksum error while copying MiniMenu.\n\nMiniMenu couldn't be updated. Please check your SD-Card and try to recopy the PND-File."
+            echo "MiniMenu not updated - checksum error" >> /tmp/updater.log
+          fi
+       echo "MiniMenu successfully updated" >> /tmp/updater.log
+       sync
+     else 
+       echo "MiniMenu already up-to-date" >> /tmp/updater.log
+     fi
+
+
+# Libraries and programs for HotFix 2
+
+echo "40"
+echo "# Installing Boost Library"
+if [ "`opkg list-installed | grep boost-system`" ]; then
+  echo "Boost library was already installed" >> /tmp/updater.log
+else  
+  opkg install 2/boost_1.41.0-r8.1.5_armv7a.ipk 2/boost-filesystem_1.41.0-r8.1.5_armv7a.ipk 2/boost-graph_1.41.0-r8.1.5_armv7a.ipk 2/boost-iostreams_1.41.0-r8.1.5_armv7a.ipk 2/boost-program-options_1.41.0-r8.1.5_armv7a.ipk 2/boost-python_1.41.0-r8.1.5_armv7a.ipk 2/boost-regex_1.41.0-r8.1.5_armv7a.ipk 2/boost-serialization_1.41.0-r8.1.5_armv7a.ipk 2/boost-signals_1.41.0-r8.1.5_armv7a.ipk 2/boost-system_1.41.0-r8.1.5_armv7a.ipk 2/boost-test_1.41.0-r8.1.5_armv7a.ipk 
+  echo "Boost library installed" >> /tmp/updater.log
+  sync
+fi
+
+echo "60"
+echo "# Installing Lua5.1"
+if [ "`opkg list-installed | grep lua5.1`" ]; then
+  echo "Lua5.1 was already installed" >> /tmp/updater.log
+else  
+  opkg install 2/lua5.1_5.1.4-r5.5_armv7a.ipk 
+  echo "Lua5.1 installed" >> /tmp/updater.log
+  sync
+fi
+
+# Bugfixes in Scripts
+
+echo "70"
+echo "# Installing updated scripts"
+#if [ ! -f /usr/bin/stopmmenu ]; then
+  cp 2/op_bluetooth.sh /usr/pandora/scripts/ 
+  cp 2/op_calibrate.sh /usr/pandora/scripts/ 
+  cp 2/op_datetime.sh /usr/pandora/scripts/ 
+  cp 2/op_lcdsettings.sh /usr/pandora/scripts/ 
+  cp 2/op_nubmode.sh /usr/pandora/scripts/ 
+  cp 2/op_startupmanager.sh /usr/pandora/scripts/ 
+  cp 2/op_switchgui.sh /usr/pandora/scripts/ 
+  cp 2/op_usermanager.sh /usr/pandora/scripts/ 
+  cp 2/op_lcdrate.sh /usr/pandora/scripts/ 
+  chmod +x /usr/pandora/scripts/op_lcdrate.sh
+  cp 2/gui.conf /etc/pandora/conf/ 
+  cp 2/op_bluetooth.desktop /usr/share/applications/    
+  cp 2/rc.wl1251 /etc/init.d/wl1251-init 
+  cp 2/rc.pandora-lcd-state /etc/init.d/pandora-lcd-state
+  cp 2/interfaces /etc/network/ 
+  cp 2/stopmmenu /usr/bin/stopmmenu 
+  cp 2/50_openpandora /etc/sudoers.d/ 
+  cp 2/mount.sh /etc/udev/scripts/mount.sh
+  mkdir /usr/pandora/mmenu
+  rm /usr/share/applications/op_wifi.desktop
+  cp 2/pandorascripts.pnd /usr/pandora/apps/
+  cp 2/abiword.pnd /usr/pandora/mmenu/
+  cp 2/arora.pnd /usr/pandora/mmenu/
+  cp 2/claws-mail.pnd /usr/pandora/mmenu/
+  cp 2/evince.pnd /usr/pandora/mmenu/
+  cp 2/gigolo.pnd /usr/pandora/mmenu/
+  cp 2/gnumeric.pnd /usr/pandora/mmenu/
+  cp 2/midori.pnd /usr/pandora/mmenu/
+  cp 2/mousepad.pnd /usr/pandora/mmenu/
+  cp 2/pidgin.pnd /usr/pandora/mmenu/
+  cp 2/ristretto.pnd /usr/pandora/mmenu/
+  cp 2/squeeze.pnd /usr/pandora/mmenu/
+  cp 2/thunar.pnd /usr/pandora/mmenu/
+  cp 2/xchat.pnd /usr/pandora/mmenu/
+  
+  echo "The scripts have been updated" >> /tmp/updater.log
+  sync
+  echo "80"
+  echo "# Fixing Touchscreen-Permissions"
+  chmod 666 /etc/pointercal 
+  echo "Permissions updated" >> /tmp/updater.log
+#else
+ # echo "The scripts were up-to-date" >> /tmp/updater.log
+#fi
+
+echo "90"
+echo "# Installing Evince"
+if [ "`opkg list-installed | grep evince`" ]; then
+  echo "Evince was already installed" >> /tmp/updater.log
+else  
+  opkg install 2/libpoppler-glib4_0.12.3-r0.5_armv7a.ipk 2/libpoppler5_0.12.3-r0.5_armv7a.ipk 2/espgs_8.15.3-r1.5_armv7a.ipk 2/poppler-data_0.4.0-r1.5_all.ipk 2/poppler_0.12.3-r0.5_armv7a.ipk 2/libcupsimage_1.4.3-r2.5_armv7a.ipk 2/evince_2.30.0-r0.5_armv7a.ipk
+  echo "Evince installed" >> /tmp/updater.log
+  sync
+fi
+
+echo "100"
+echo "# Update finished"
+
+# Zenity Progress goes here
+) |
+        zenity --progress \
+          --title="Installing Updates..." \
+          --text="Updating System..." \
+          --percentage=0
+update=$(cat /tmp/updater.log)
+zenity --info --title="Update finished" --text "$err\n\n${update}"
+
+fi