pandora-scripts: fix echo redirect
[openpandora.oe.git] / recipes / pandora-system / pandora-first-run-wizard / first-run-wizard.sh
index f30b80e..806df0d 100755 (executable)
@@ -17,18 +17,50 @@ groupadd wheel
 export WALLPAPER='/usr/share/xfce4/backdrops/op-firstrun.png'
 hsetroot -center $WALLPAPER
 
+# Find out what unit the user has.
+pnd_version=$(dmesg | grep OMAP3 | grep ES | awk '{print $3}')
+es_version=$(dmesg | grep OMAP3 | grep ES | awk '{print $4}')
+if [ "$pnd_version" == "OMAP3630" ]; then
+    pnd_version="1GHz"
+fi
+  if [ "$pnd_version" == "OMAP3430/3530" ]; then
+    pnd_version="Rebirth"
+  if [ "$es_version" == "ES2.1" ]; then
+    pnd_version="Classic"
+  fi
+fi
+
+# Enable TV Out
+/usr/pandora/scripts/op_tvout.sh
+
 # Default error message (should a user hit cancel, validation fail etc.).
 ERROR_WINDOW='zenity --title="Error" --error --text="Sorry! Please try again." --timeout 6'
 
 RESET_ROOT="yes"
 
-DISPLAY=:0 xset s off
+xset s off
+xset -dpms
+
+#Stop WiFi
+rmmod board_omap3pandora_wifi wl1251_sdio wl1251
 
 # Greet the user.
 
-if zenity --question --title="Pandoras Box has been opened." --text="Welcome!\n\nPandora's Box has been opened.\n\nThis wizard will help you setting up your new OpenPandora handheld before the first use.\n\nYou will be asked a few simple questions to personalise and configure your device.\n\nDo you want to set up your unit now or shut the unit down and do it later?" --ok-label="Start now" --cancel-label="Shutdown" ; then
+if zenity --question --title="Pandoras Box has been opened." --text="Welcome!\n\nPandora's Box has been opened.\n\nThis wizard will help you setting up your $pnd_version OpenPandora handheld before the first use.\n\nYou will be asked a few simple questions to personalise and configure your device.\n\nDo you want to set up your unit now or shut the unit down and do it later?" --ok-label="Start now" --cancel-label="Shutdown" ; then
 # ----
 
+# Calibrate touchscreen.
+
+if zenity --question --title="Calibrate Touchscreen" --text="It is recommended to calibrate the touchscreen to make sure it accurately works.\n\nIf you do so, you will see a moving crosshair.\nUse the stylus to press the crosshair as accurate as possible.\n\nYou can always (re-)calibrate it from the Settings-Menu later in the OS as well." --ok-label="Calibrate Touchscreen" --cancel-label="Don't calibrate it"; then
+  . /etc/profile
+  TSLIB_CONSOLEDEVICE=none op_runfbapp ts_calibrate
+  /usr/pandora/scripts/op_touchinit.sh
+while ! zenity --question --title="Check Calibration" --text="Your new calibration setting has been applied.\n\nPlease check if the touchscreen is now working properly.\nIf not, you might want to try a recalibration.\n\n(Hint: use the nubs to press the button if the touchscreen is way off)" --ok-label="The touchscreen is fine" --cancel-label="Recalibrate"; do
+      TSLIB_CONSOLEDEVICE=none op_runfbapp ts_calibrate
+  /usr/pandora/scripts/op_touchinit.sh  
+done
+fi
+
 # Reset ROOT's password to something random 
 
 # (I know the image build sets the password to something pusdo-random)
@@ -45,37 +77,6 @@ fi
 
 # ----
 
-# Ask the user to calibrate the touchscreen.
-
-#if zenity --question --title="Touchscreen calibration" --text="It is recommended to calibrate and test the device touchscreen.\n\nDo you wish to calibrate the touchscreen now?" --ok-label="Yes" --cancel-label="No"; then 
-#      # Make sure we have a sane environment as this script will be run long before any /etc/profile stuff.
-#      . /etc/profile.d/tslib.sh
-#      # Delete the pointercal file (do we want to do that?)
-#      # rm /etc/pointercal
-#      # Spawn the ts_* tools as subprocesses that will return to the script.
-#      echo Running ts_calibrate       
-#      /usr/bin/ts_calibrate
-#      wait
-#      echo Running ts_test
-#      /usr/bin/ts_test
-#      wait
-#fi
-
-# ----
-
-# Setup swap partition if the user has placed an SD with a swap partition on it.
-
-#swap_part=$(sfdisk -l /dev/mmcblk? | grep swap | cut -d" " -f1)
-#if [ x$swap_part != x ] ; then
-#      use_swap=$(zenity --title="Enable swap?" --text "Swap partition found on SD card. Would you like to use it?\n\nWarning: This SD must remain in the system to use the swap." --list --radiolist --column " " --column "Answer" TRUE "Use swap on $swap_part" FALSE "Do not use swap")
-#      if [ "$use_swap" = "Use swap on $swap_part" ] ; then
-#              swapon $swap_part
-#                      echo "$swap_part none swap sw 0 0" >> /etc/fstab
-#      fi
-#fi
-
-# ----
-
 # Setup the full name and username.
 
 while ! name=$(zenity --title="Please enter your full name" --entry --text "Please enter your full name.") || [ "x$name" = "x" ] ; do
@@ -188,6 +189,7 @@ done
 
 echo $timezone
 rm /etc/localtime && ln -s /usr/share/zoneinfo/$area/$timezone /etc/localtime
+echo "$area/$timezone" > /etc/timezone
 
 #Make sure we clean up any leading zeros in the day (as Zenity freaks out)
 date_d=`date +%d | sed 's/^0//'`
@@ -203,16 +205,109 @@ echo $date
 time_h=`date +%H`
 time_m=`date +%M`
 
-while ! time=$(zenity --title="Enter current time" --entry --text "Please enter the time in 24hour format (HH:MM).\n\nThe screen might blank out after you changed the time.\nDon't panic. Simply press a button on the keyboard.\n" --entry-text "$time_h:$time_m") || [ "x$time" = "x" ] ; do
+while ! time=$(zenity --title="Enter current time" --entry --text "Please enter the time in 24hour format (HH:MM).\n" --entry-text "$time_h:$time_m") || [ "x$time" = "x" ] ; do
         zenity --title="Error" --error --text="Please input the time." --timeout 6
 done
 
 while ! date -d $time ; do
-       time=$(zenity --title="Enter current time" --entry --text "Please enter the time in 24hour format (HH:MM).\n\nThe screen might blank out after you changed the time.\nDon't panic. Simply press a button on the keyboard.\n" --entry-text "$time_h:$time_m")
+       time=$(zenity --title="Enter current time" --entry --text "Please enter the time in 24hour format (HH:MM).\n" --entry-text "$time_h:$time_m")
 done
  
 date +%Y%m%d -s $date
 date +%H:%M -s $time
+hwclock -u -w
+
+
+# Let the user choose his desired clockspeed.
+
+if [ "$pnd_version" == "1GHz" ]; then 
+      cpusel=$(zenity --title="Optional settings" --width="400" --height="300" --list --column "id" --column "Please select" --hide-column=1 --text="The CPU of the Pandora supports different speed settings.\nHigher speeds might make some units unstable and decrease the lifetime of your CPU.\n\nBelow are some quick profiles which will help you to configure your system the way you like it.\n" "1200" "Clockspeed: 1,2Ghz, OPP4 (probably unstable)" "1100" "Clockspeed: 1,1Ghz, OPP4 (should be stable)" "1000" "Clockspeed: 1GHz, OPP4 (Default Speed)" --ok-label="Select CPU Profile" )
+    else
+      cpusel=$(zenity --title="Optional settings" --width="400" --height="300" --list --column "id" --column "Please select" --hide-column=1 --text="The CPU of the Pandora supports different speed settings.\nHigher speeds might make some units unstable and decrease the lifetime of your CPU.\n\nBelow are some quick profiles which will help you to configure your system the way you like it.\n" "900" "Clockspeed: 900Mhz, OPP5 (probably unstable)" "800" "Clockspeed: 800Mhz, OPP5 (should be stable)" "600" "Clockspeed: 600MHz, OPP3 (Default Speed)" --ok-label="Select CPU Profile" )
+    fi
+    
+    case $cpusel in
+       "1200")
+       echo 4 > /proc/pandora/cpu_opp_max
+       sed -i "s/.*maxopp.*/maxopp:4/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*max:.*/max:1300/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*default.*/default:1200/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*safe.*/safe:1200/g" /etc/pandora/conf/cpu.conf
+       sync
+       /usr/pandora/scripts/op_cpuspeed.sh -n 1200
+       zenity --info --title="CPU Speed set" --text "The maximum CPU Speed has been set to 1,2GHz." --timeout 6
+       ;;
+    
+        "1100")
+       echo 4 > /proc/pandora/cpu_opp_max
+       sed -i "s/.*maxopp.*/maxopp:4/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*max:.*/max:1200/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*default.*/default:1100/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*safe.*/safe:1100/g" /etc/pandora/conf/cpu.conf
+       sync
+       /usr/pandora/scripts/op_cpuspeed.sh -n 1100
+       zenity --info --title="CPU Speed set" --text "The maximum CPU Speed has been set to 1,1GHz." --timeout 6
+       ;;
+
+       "1000")
+       echo 4 > /proc/pandora/cpu_opp_max
+       sed -i "s/.*maxopp.*/maxopp:4/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*max:.*/max:1100/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*default.*/default:1000/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*safe.*/safe:1000/g" /etc/pandora/conf/cpu.conf
+       sync
+       /usr/pandora/scripts/op_cpuspeed.sh -n 1000
+       zenity --info --title="CPU Speed set" --text "The maximum CPU Speed has been set to 1GHz." --timeout 6
+       ;;      
+
+       "900")
+       echo 5 > /proc/pandora/cpu_opp_max
+       sed -i "s/.*maxopp.*/maxopp:5/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*max:.*/max:950/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*default.*/default:900/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*safe.*/safe:900/g" /etc/pandora/conf/cpu.conf
+       sync
+       /usr/pandora/scripts/op_cpuspeed.sh -n 900
+       zenity --info --title="CPU Speed set" --text "The maximum CPU Speed has been set to 900MHz." --timeout 6
+       ;;
+       
+       "800")
+       echo 5 > /proc/pandora/cpu_opp_max
+       sed -i "s/.*maxopp.*/maxopp:5/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*max:.*/max:900/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*default.*/default:800/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*safe.*/safe:800/g" /etc/pandora/conf/cpu.conf
+       sync
+       /usr/pandora/scripts/op_cpuspeed.sh -n 800
+       zenity --info --title="CPU Speed set" --text "The maximum CPU Speed has been set to 800MHz." --timeout 6
+       ;;
+
+
+       "600")
+       echo 3 > /proc/pandora/cpu_opp_max
+       sed -i "s/.*maxopp.*/maxopp:3/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*max:.*/max:700/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*default.*/default:600/g" /etc/pandora/conf/cpu.conf
+       sed -i "s/.*safe.*/safe:600/g" /etc/pandora/conf/cpu.conf
+       sync
+       /usr/pandora/scripts/op_cpuspeed.sh -n 600
+       zenity --info --title="CPU Speed set" --text "The maxmimum CPU Speed has been set to 600Mhz." --timeout 6
+       ;;
+
+esac
+
+#Enable / Disable TV Out on Startup
+
+if zenity --question --title="TV Out on startup" --text="Do you want to enable the TV Output on startup?\n(Note: This needs a bit more power)" --ok-label="Enable TV Out" --cancel-label="Disable TV Out"; then 
+         touch /etc/pandora/conf/tvout.state
+         zenity --info --title="TV Out" --text "TV Out will be switched on with the last saved settings on bootup." --timeout 6
+       else
+       /usr/pandora/scripts/op_tvout.sh -d
+         if [ -f /etc/pandora/conf/tvout.state ]; then
+               rm /etc/pandora/conf/tvout.state
+         fi
+         zenity --info --title="TV Out" --text "TV Out will not be switched on on bootup." --timeout 6
+fi     
 
 # ----
 
@@ -221,13 +316,29 @@ update-rc.d -f samba remove
 update-rc.d -f xinetd remove
 update-rc.d -f avahi-daemon remove
 update-rc.d -f apmd remove
-update-rc.d -f usb-gadget remove
 update-rc.d -f banner remove
 update-rc.d -f portmap remove
 update-rc.d -f mountnfs remove
 update-rc.d -f blueprobe remove
 update-rc.d -f dropbear remove
 update-rc.d -f wl1251-init remove
+# leave this one alone, needed for OTG host mode, powersaving should be ok on 3.2.39 at least
+#update-rc.d -f usb-gadget remove
+
+# prevent wifi from being autoloaded on later kernels, let wl1251-init script do it
+if ! grep -q 'blacklist wl1251_sdio' /etc/modprobe.conf 2> /dev/null; then
+  echo 'blacklist wl1251_sdio' >> /etc/modprobe.conf
+fi
+# we don't ship firmware for rtl8192cu, and it was reported not to work
+# with the right firmware anyway (not verified though)
+# vendor 8192cu is compiled instead for now
+if ! grep -q 'blacklist rtl8192cu' /etc/modprobe.conf 2> /dev/null; then
+  echo 'blacklist rtl8192cu' >> /etc/modprobe.conf
+fi
+
+# add Midi Module and zram
+echo snd-seq>>/etc/modules
+echo zram>>/etc/modules
 
 # get rid of some dirs in /media that OE creates but are unlikely to be used
 rmdir /media/card /media/cf /media/mmc1 /media/net /media/realroot /media/union 2> /dev/null
@@ -240,9 +351,12 @@ touch /etc/pandora/first-boot
 chmod 0666 /etc/pandora/first-boot
 
 
+
+
+
 # Let the user run optional config stuff.
 
-while mainsel=$(zenity --title="Optional settings" --width="400" --height="300" --list --column "id" --column "Please select" --hide-column=1 --text="This concludes the mandatory part of the First Boot Wizard.\n\nYou can now either continue to boot the system or change some more settings.\n\n\nThank you for buying the OpenPandora. Enjoy using the device." "speed" "CPU-Speed and Overclocking-Settings" "startup" "Startup-Settings" "lcd" "LCD-Settings" --ok-label="Change selected Setting" --cancel-label="Continue to Boot"); do
+while mainsel=$(zenity --title="Optional settings" --width="400" --height="300" --list --column "id" --column "Please select" --hide-column=1 --text="This concludes the mandatory part of the First Boot Wizard.\n\nYou can now either continue to boot the system or change some more settings.\n\n\nThank you for buying the OpenPandora. Enjoy using the device." "speed" "Advanced CPU-Speed and Overclocking-Settings" "startup" "Advanced Startup-Settings" "video" "Video Settings" --ok-label="Change selected Setting" --cancel-label="Finish Setup"); do
 
 case $mainsel in
   "speed")
@@ -254,16 +368,15 @@ case $mainsel in
   /usr/pandora/scripts/op_startupmanager.sh
   ;;
 
-   "lcd")
+   "video")
   /usr/pandora/scripts/op_lcdsettings.sh
   ;;
 
 esac
 done
-
 # ----
 
-
+rm /tmp/nocleanwarn
 # ----
 else
 poweroff