updater.sh: Final Hotfix 3 script
authorMichael Mrozek <EvilDragon@openpandora.de>
Sun, 4 Jul 2010 22:47:46 +0000 (00:47 +0200)
committerMichael Mrozek <EvilDragon@openpandora.de>
Sun, 4 Jul 2010 22:47:46 +0000 (00:47 +0200)
hotfix_updater/updater.sh

index dc2c8cc..9c4e5a0 100755 (executable)
@@ -26,6 +26,7 @@ currmmenu=$(md5sum /usr/bin/mmenu | cut -d" " -f1)
 currmmenuconf=$(md5sum /etc/pandora/conf/mmenu.conf | cut -d" " -f1)
 
 rm /tmp/updater.log
+rm /tmp/updreboot
 
 log()
 {
@@ -40,9 +41,9 @@ err()
   echo "$@" >> /tmp/updater_err.log
 }
 
-if zenity --question --title="Update Package 2" --text="\
+if zenity --question --title="Update Package 3" --text="\
 This PND updates your Pandora OS. You can safely delete it after it has finished.\n\
-This pack includes all updates from Hotfix 1 as well.\n\n\
+This pack includes all updates from previous Hotfix Packs as well.\n\n\
 Do you want to start the upgrade now? " --ok-label="Start now" --cancel-label="Don't do it" ; then
 
 (
@@ -91,6 +92,7 @@ update_kernel()
 
      if ! $have_error; then
        log "Kernel successfully updated"
+       echo "The kernel has been updated. You need to restart your system." > /tmp/updreboot
      fi
      sync
 }
@@ -136,40 +138,42 @@ update_uboot()
   fi
 }
 
-rm /tmp/u-boot.bin.nand 2> /dev/null
-nanddump -o -b -q -f /tmp/u-boot.bin.nand /dev/mtd1
-uboot_nand_ver=`strings /tmp/u-boot.bin.nand | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'`
-uboot_ver=`strings u-boot.bin | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'`
-uboot_size=`stat -c %s u-boot.bin`
-
-dd if=/tmp/u-boot.bin.nand of=/tmp/u-boot.bin.nand.cmp bs=$uboot_size count=1
-if ! cmp u-boot.bin /tmp/u-boot.bin.nand.cmp
-then
-  uboot_need_to_ask=true
-  for oldver in $oldubootvers; do
-    if [ "$oldver" = "$uboot_nand_ver" ]; then
-      uboot_need_to_ask=false
-      break
-    fi
-  done
-
-  if $uboot_need_to_ask; then
-    if zenity --question --title="Custom u-boot?" --text="\
-You seem to have custom or newer u-boot in flash.\n\n\
-Update it anyway?\n\
-(if unsure, select Yes)" --ok-label="Yes" --cancel-label="No" ; then
-      update_uboot
+if [ -f u-boot.bin ]; then
+
+  rm /tmp/u-boot.bin.nand 2> /dev/null
+  nanddump -o -b -q -f /tmp/u-boot.bin.nand /dev/mtd1
+  uboot_nand_ver=`strings /tmp/u-boot.bin.nand | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'`
+  uboot_ver=`strings u-boot.bin | grep 'U-Boot 20' | head -n 1 | sed 's/ /_/g'`
+  uboot_size=`stat -c %s u-boot.bin`
+
+  dd if=/tmp/u-boot.bin.nand of=/tmp/u-boot.bin.nand.cmp bs=$uboot_size count=1
+  if ! cmp u-boot.bin /tmp/u-boot.bin.nand.cmp
+  then
+    uboot_need_to_ask=true
+    for oldver in $oldubootvers; do
+      if [ "$oldver" = "$uboot_nand_ver" ]; then
+       uboot_need_to_ask=false
+       break
+      fi
+    done
+
+    if $uboot_need_to_ask; then
+      if zenity --question --title="Custom u-boot?" --text="\
+      You seem to have custom or newer u-boot in flash.\n\n\
+      Update it anyway?\n\
+      (if unsure, select Yes)" --ok-label="Yes" --cancel-label="No" ; then
+       update_uboot
+      else
+       log "u-boot update skipped\n(nand has $uboot_nand_ver)"
+      fi
     else
-      log "u-boot update skipped\n(nand has $uboot_nand_ver)"
+      update_uboot
     fi
   else
-    update_uboot
+    log "u-boot already up-to-date\n($uboot_nand_ver)"
   fi
-else
-  log "u-boot already up-to-date\n($uboot_nand_ver)"
 fi
 
-
 # Libraries and Programs
   
 echo "20"
@@ -184,7 +188,7 @@ fi
 
 # Libraries and programs
 
-echo "30"
+echo "35"
 echo "# Installing Boost Library"
 if [ "`opkg list-installed | grep boost-system`" ]; then
   log "Boost library was already installed"
@@ -204,7 +208,7 @@ else
   sync
 fi
 
-echo "60"
+echo "65"
 echo "# Installing Evince"
 if [ "`opkg list-installed | grep evince`" ]; then
   log "Evince was already installed"
@@ -216,7 +220,7 @@ fi
 
 # MiniMenu Update
 
-echo "70"
+echo "80"
 echo "# Installing updated MiniMenu"
 
 update_mmenu()
@@ -224,7 +228,6 @@ update_mmenu()
      bad_mmenu=false
      mmenu_error=false
      rm /usr/bin/mmenu.old 
-     rm /etc/pandora/conf/mmenu.conf.old
      cp 3/mmenu /usr/bin/mmenu.new 
      cp 3/mmenu.conf /etc/pandora/conf/mmenu.conf.new 
         sync
@@ -286,10 +289,9 @@ fi
 
 # Bugfixes in Scripts
 
-echo "80"
+echo "85"
 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/ 
@@ -319,7 +321,7 @@ if [ ! -f /usr/bin/stopmmenu ]; then
   cp 2/thunar.pnd /usr/pandora/mmenu/
   cp 2/xchat.pnd /usr/pandora/mmenu/
   
-  log "The scripts have been updated"
+  log "The HotFix 2 scripts have been updated"
   sync
   chmod 666 /etc/pointercal 
   log "Permissions updated"
@@ -329,9 +331,11 @@ fi
 
 echo "90"
 echo "# Installing updated scripts"
-if [ -f /etc/init.d/pandora-lcd-state ]; then
+mountmd5=$(md5sum /usr/pandora/scripts/op_storage.sh | cut -d" " -f1)
+if [  "23c0cd2ef0197e1a1e512ce48014311e" != "$mountmd5" ]; then
   update-rc.d -f pandora-lcd-state remove
   rm /etc/init.d/pandora-lcd-state
+  cp 3/op_bluetooth.sh /usr/pandora/scripts/ 
   cp 3/rc.pandora-state /etc/init.d/pandora-state
   cp 3/50_openpandora /etc/sudoers.d/ 
   cp 3/mount.sh /etc/udev/scripts/mount.sh
@@ -340,12 +344,49 @@ if [ -f /etc/init.d/pandora-lcd-state ]; then
   cp 3/pandorascripts.pnd /usr/pandora/apps/
   cp 3/dirty_expire_centisecs /etc/pandora/conf/
   cp 3/service.conf /etc/pandora/conf/
+  cp 3/eventmap /etc/pandora/conf/
+  cp 3/op_runfbapp /usr/bin/
+  cp 3/pnd_run.sh /usr/pandora/scripts/
   update-rc.d -f pandora-state start 39 S . stop 31 0 1 6 .
+  log "The HotFix 3 scripts have been updated"
+  sync
 else
  log "HotFix 3 scripts were already installed."
 fi
 
+echo "94"
+echo "# Installing new Modules"
+if [ ! -f /lib/modules/2.6.27.46-omap1/kernel/drivers/net/tun.ko  ]; then
+  cp 3/snd-usb-audio.ko /lib/modules/2.6.27.46-omap1/kernel/sound/usb/
+  cp 3/snd-usb-lib.ko /lib/modules/2.6.27.46-omap1/kernel/sound/usb/
+  cp 3/snd-hwdep.ko /lib/modules/2.6.27.46-omap1/kernel/sound/core/
+  cp 3/snd-rawmidi.ko /lib/modules/2.6.27.46-omap1/kernel/sound/core/
+  cp 3/tun.ko /lib/modules/2.6.27.46-omap1/kernel/drivers/net/
+  depmod
+  log "New modules installed"
+  sync
+else
+ log "All Modules were already installed."
+fi
 
+echo "95"
+echo "# Disabling unneeded services"
+if [ -f /etc/rc5.d/S20apmd ]; then
+  update-rc.d -f samba remove
+  update-rc.d -f xinetd
+  update-rc.d -f avahi-daemon
+  update-rc.d -f apmd
+  update-rc.d -f usb-gadget
+  update-rc.d -f banner
+  update-rc.d -f portmap
+  update-rc.d -f mountnfs
+  update-rc.d -f blueprobe
+  update-rc.d -f dropbear
+  log "Unneeded services have been disabled"
+  sync
+else
+  log "Unneeded sevices were already disabled"
+fi
 
 echo "100"
 echo "# Update finished"
@@ -365,3 +406,9 @@ update=$(cat /tmp/updater.log)
 zenity --info --title="Update finished" --text "$err\n\n${update}"
 
 fi
+
+if [ -f /tmp/updreboot ]; then
+  reboot=`cat /tmp/updreboot`
+  zenity --info --title="You need to reboot" --text "${reboot}"
+  rm /tmp/updreboot
+fi
\ No newline at end of file