pandora-first-run-wizard: Commit latest version with date/time setting.
authorDavid-John Willis <John.Willis@Distant-earth.com>
Mon, 14 Dec 2009 11:44:26 +0000 (11:44 +0000)
committerDavid-John Willis <John.Willis@Distant-earth.com>
Mon, 14 Dec 2009 11:44:26 +0000 (11:44 +0000)
recipes/pandora-system/pandora-first-run-wizard.bb
recipes/pandora-system/pandora-first-run-wizard/first-run-wizard.sh
recipes/pandora-system/pandora-first-run-wizard/op_startup.sh

index d9ae28d..d80e02d 100755 (executable)
@@ -6,7 +6,7 @@ RDEPENDS = "hsetroot zenity dbus pandora-wallpaper-official tslib tslib-calibrat
 
 COMPATIBLE_MACHINE = "omap3-pandora"
 
 
 COMPATIBLE_MACHINE = "omap3-pandora"
 
-PR = "r2"
+PR = "r5"
 
 SRC_URI = " \
           file://first-run-wizard.sh \
 
 SRC_URI = " \
           file://first-run-wizard.sh \
@@ -26,6 +26,8 @@ do_install() {
 
           install -d ${D}${sysconfdir}/init.d/
           install -m 0755 ${WORKDIR}/rc.firstrun ${D}${sysconfdir}/init.d/oprun-init
 
           install -d ${D}${sysconfdir}/init.d/
           install -m 0755 ${WORKDIR}/rc.firstrun ${D}${sysconfdir}/init.d/oprun-init
+
+          install -d ${D}${sysconfdir}/pandora/          
 }
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
 }
 
 PACKAGE_ARCH = "${MACHINE_ARCH}"
index 307de34..32180cb 100644 (file)
@@ -1,10 +1,9 @@
 #!/bin/sh
 
 #!/bin/sh
 
-# Based on the scripts by JohnX/Mer Project - http://wiki.maemo.org/Mer/
+# Initially based on the scripts by JohnX/Mer Project - http://wiki.maemo.org/Mer/
 # Reworked for the OpenPandora - John Willis/Michael Mrozek
 
 # You can start the wizard from the shell using 'xinit ./first-boot-init.sh'
 # Reworked for the OpenPandora - John Willis/Michael Mrozek
 
 # You can start the wizard from the shell using 'xinit ./first-boot-init.sh'
-# Maybe we run it for the first time from rc5.d and delete the symlink at the end of the script?
 
 export LANG=en_GB.UTF-8
 export GTK2_RC_FILES=/usr/share/themes/Xfce/gtk-2.0/gtkrc
 
 export LANG=en_GB.UTF-8
 export GTK2_RC_FILES=/usr/share/themes/Xfce/gtk-2.0/gtkrc
@@ -13,65 +12,97 @@ export GTK2_RC_FILES=/usr/share/themes/Xfce/gtk-2.0/gtkrc
 # TODO: Do this somewhere better.
 groupadd wheel
 
 # TODO: Do this somewhere better.
 groupadd wheel
 
-# We load up a background image here
-export WALLPAPER=/usr/share/xfce4/backdrops/op-firstrun.png
+# We load up a background image here.
+export WALLPAPER='/usr/share/xfce4/backdrops/op-firstrun.png'
 hsetroot -center $WALLPAPER
 
 hsetroot -center $WALLPAPER
 
-# Greet the user
-zenity --info --title="Pandoras Box has been opened." --text "Welcome. This wizard will help you setting up your new OpenPandora handheld before the first use."
+# Default error message (should a user hit cancel, validation fail etc.).
+ERROR_WINDOW='zenity --title="Error" --error --text="Sorry! Please try again." --timeout 6'
 
 
-# Calibrate touchscreen?
-if zenity --question --title="Touchscreen calibration" --text="It is recommended to calibrate the devices touchscreen./nDo you wish to calibrate your touchscreen now?" --ok-label="Calibrate"  --cancel-label="Do not calibrate"; then 
+RESET_ROOT="yes"
+
+# Greet the user.
+
+zenity --info --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 for use." --timeout 45
+
+# ----
+
+# Reset ROOT's password to something random 
+
+# (I know the image build sets the password to something pusdo-random)
+# (ok, urandom is not 100% secure but it's good enough for our needs)
+
+if [ $RESET_ROOT == "yes" ]; then
+       rootpwd=$(cat /dev/urandom|tr -dc "a-zA-Z0-9-_\$\?"|fold -w 30|head -n 1)
+passwd "root" <<EOF
+$rootpwd
+$rootpwd
+EOF
+       rootpwd=""
+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
        # 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
        # rm /etc/pointercal
+       # Spawn the ts_* tools as subprocesses that will return to the script.
+       echo Running ts_calibrate       
        /usr/bin/ts_calibrate
        /usr/bin/ts_calibrate
+       wait
+       echo Running ts_test
+       /usr/bin/ts_test
+       wait
 fi
 
 fi
 
-# Should we really enable SWAP?
+# ----
+
+# 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
 #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. Would you like to use it?" --list --radiolist --column " " --column "Answer" TRUE "Use swap on $swap_part" FALSE "Do not use swap")
+#      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
 #      if [ "$use_swap" = "Use swap on $swap_part" ] ; then
 #              swapon $swap_part
-#              echo "$swap_part none swap sw 0 0" >> /etc/fstab
+#                      echo "$swap_part none swap sw 0 0" >> /etc/fstab
 #      fi
 #fi
 
 #      fi
 #fi
 
-# First, setup the full name and username.
+# ----
 
 
-while ! name=$(zenity --title="Enter your name" --entry --text "Please enter your full name.") || [ "x$name" = "x" ] ; do
-       zenity --title="Error" --error --text="Please try again."
+# 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
+       zenity --title="Error" --error --text="Please try again." --timeout 6
 done
 
 username_guess=$(echo "$name" | cut -d" " -f1 | tr A-Z a-z)
 
 done
 
 username_guess=$(echo "$name" | cut -d" " -f1 | tr A-Z a-z)
 
-while ! username=$(zenity --title="Enter your username" --entry --text "Please choose a short username.
-It should be all lowercase and
-contain only letters and numbers." --entry-text "$username_guess") || [ "x$username" = "x" ] ; do
-       zenity --title="Error" --error --text="Please try again."
+while ! username=$(zenity --title="Enter your username" --entry --text "Please choose a short username.\n\nIt should be all lowercase and contain only letters and numbers." --entry-text "$username_guess") || [ "x$username" = "x" ] ; do
+       zenity --title="Error" --error --text="Please try again." --timeout 6
 done
 
 while ! useradd -c "$name,,," -G adm,audio,video,netdev,wheel,plugdev "$username" ; do
 done
 
 while ! useradd -c "$name,,," -G adm,audio,video,netdev,wheel,plugdev "$username" ; do
-       username=$(zenity --title="Please check username" --entry --text "Please be sure that your
-username consists of only
-letters and numbers." --entry-text "$username")
+       username=$(zenity --title="Please check username" --entry --text "Please ensure that your username consists of only\nletters and numbers and is not already in use on the system." --entry-text "$username")
 done
 
 done
 
-sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
+# ----
 
 
-# Password setup.
+# Setup the users password.
 
 password=""
 while [ x$password = x ] ; do
 
 password=""
 while [ x$password = x ] ; do
-       password1=$(zenity --title=Password --entry --text="Choose a new password." --hide-text)
+       password1=$(zenity --title=Password --entry --text="Please choose a new password." --hide-text)
        password2=$(zenity --title=Confirm --entry --text="Confirm your new password." --hide-text)
        if [ $password1 != $password2 ] ; then 
        password2=$(zenity --title=Confirm --entry --text="Confirm your new password." --hide-text)
        if [ $password1 != $password2 ] ; then 
-               zenity --title="Error" --error --text="Passwords don't match.
-Please try again."
-       else if [ x$password1 = x ] ; then
-               zenity --title="Error" --error --text="Password can not be blank!
-Please try again."
+               zenity --title="Error" --error --text="The passwords do not match.\n\nPlease try again." --timeout 6
+       else 
+               if [ x$password1 = x ] ; then
+                       zenity --title="Error" --error --text="Password cannot be blank!\n\nPlease try again." --timeout 6
                else
                        password=$password1
                fi
                else
                        password=$password1
                fi
@@ -83,37 +114,99 @@ $password
 $password
 EOF
 
 $password
 EOF
 
-# Name our little baby
+# ----
 
 
-while ! hostname=$(zenity --title="Name your Pandora" --entry --text "Please choose a name for
-your Pandora. It should only contain
-letters, numbers and dashes." --entry-text "$username-pandora") || [ "x$hostname" = "x" ]; do 
+# Pick a name for the OpenPandora.
+
+while ! hostname=$(zenity --title="Name your Pandora" --entry --text "Please choose a name for your OpenPandora.\n\nIt should only contain letters, numbers and dashes." --entry-text "$username-openpandora") || [ "x$hostname" = "x" ]; do 
        zenity --title="Error" --error --text="Please try again."
 done
 
 echo $hostname > /etc/hostname
 echo "127.0.0.1 localhost.localdomain localhost $hostname" > /etc/hosts
        zenity --title="Error" --error --text="Please try again."
 done
 
 echo $hostname > /etc/hostname
 echo "127.0.0.1 localhost.localdomain localhost $hostname" > /etc/hosts
-#cat /usr/share/first-boot-wizard/hosts-template >> /etc/hosts
 hostname -F /etc/hostname
 
 hostname -F /etc/hostname
 
-
 # Set the correct user for Autologin and enable / disable it.
 
 # Set the correct user for Autologin and enable / disable it.
 
-if zenity --question --title="Autologin" --text="Do you want to automatically login on startup?\n\nSecurity warning: This skips the password check on startup" --ok-label="Yes, enable Autologin" --cancel-label="Do not enable Autologin"; then       
-     # echo "PREFERED_USER=$username" > /etc/default/autologin
-      sed -i 's/.*auto_login.*/auto_login yes/g' /etc/slim.conf
-      else
-      sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
+if zenity --question --title="Autologin" --text="Do you wish to automatically login at startup?\n\nSecurity warning: This skips the password check on startup" --ok-label="Yes" --cancel-label="No"; then              
+       # echo "PREFERED_USER=$username" > /etc/default/autologin
+       sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
+       sed -i 's/.*auto_login.*/auto_login yes/g' /etc/slim.conf
+else
+       if zenity --question --title="User" --text="Do you wish to have your username automatically populated in the login screen?\n\nNote: This is ideal if your the only user of the OpenPandora but wish to disable autologin and use a password." --ok-label="Yes" --cancel-label="No"; then 
+               sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
+               sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
+       else
+               sed -i "s/.*default_user.*/default_user/g" /etc/slim.conf
+               sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
+       fi
 fi
 
 fi
 
-# Change the default session in SLiM.
+# ----
+
+# Select the default interface and setup SLiM to pass that as a sesion to ~./.xinitrc
+
+while ! launcher=$(zenity --list --title="Default User Interface" --text="Please choose your default application launcher.\n\nYou can always change this setting later." --column "return" --print-column=1 --hide-column=1 --column "Pick a launcher" "xfce" "Desktop environment (Xfce)" "pmenu" "Gaming-console like launcher (PMenu)") || [ "x$launcher" = "x" ]; do 
+       zenity --title="Error" --error --text="Please select a default launcher." --timeout 6
+done
 
 
-if zenity --question --title="Default Inteface" --text="Now you can choose whether you want to boot into a full desktop interface or a gaming console-like launcher by default.\n\nYou can always change this setting later." --ok-label="Full Desktop (Xfce)"  --cancel-label="Games console like Launcher (PMenu)"; then 
-       echo Xfce4 > /etc/bootup.cfg
+if [ $launcher == "xfce" ]; then 
        sed -i 's/.*sessions.*/sessions xfce4,pmenu/g' /etc/slim.conf
        sed -i 's/.*sessions.*/sessions xfce4,pmenu/g' /etc/slim.conf
-        else
-       echo PMenu > /etc/bootup.cfg
+       echo Xfce selected as default interface
+else
        sed -i 's/.*sessions.*/sessions pmenu,xfce4/g' /etc/slim.conf
        sed -i 's/.*sessions.*/sessions pmenu,xfce4/g' /etc/slim.conf
+       echo PMenu selected as default interface
 fi
 
 fi
 
-zenity --info --title="Finished" --text "This concludes the First Boot Wizard.\nThanks for buying the OpenPandora. Enjoy the device!"
+# ----
+
+# Set the timezone and date/time
+
+while ! timezone=$(zenity --list --title "Select your timezone" --text="Please select your timezone" --column="Select your timezone" --print-column=1 "GMT" "GMT+1" "GMT+2" "GMT+3" "GMT+4" "GMT+5" "GMT+6" "GMT+7" "GMT+8" "GMT+9" "GMT+10" "GMT+11" "GMT+12" "GMT-1" "GMT-2" "GMT-3" "GMT-4" "GMT-5" "GMT-6" "GMT-7" "GMT-8" "GMT-9" "GMT-10" "GMT-11" "GMT-12" "GMT-13" "GMT-14" "UCT" "UTC" "Universal" --width=250 --height=450) || [ "x$timezone" = "x" ] ; do
+       zenity --title="Error" --error --text="Please select a timezone." --timeout=6
+done
+
+echo $timezone
+echo rm /etc/localtime && ln -s /usr/share/zoneinfo/Etc/$timezone /etc/localtime
+
+#Make sure we clean up any leading zeros in the day (as Zenity freaks out)
+date_d=`date +%d | sed 's/^0//'`
+date_m=`date +%m`
+date_y=`date +%Y`
+
+while ! date=$(zenity --calendar --text="Please select the current date" --title "Please select the current date" --day=$date_d --month=$date_m --year=$date_y --date-format="%Y%m%d" --width=500) || [ "x$date" = "x" ] ; do
+        zenity --title="Error" --error --text="Please select the date." --timeout 6
+done
+
+echo $date
+
+time_h=`date +%H`
+time_m=`date +%M`
+
+while ! time=$(zenity --title="Enter actual time" --entry --text "Please enter the time in 24hour format (HH:MM):" --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 actual time" --entry --text "Please enter the time in 24hour format (HH:MM):" --entry-text "$time_h:$time_m")
+done
+date +%Y%m%d -s $date
+date +%H:%M -s $time
+
+# ----
+
+# Finsh up and boot the system.
+
+zenity --info --title="Finished" --text "This concludes the First Boot Wizard.\n\nYour chosen interface will start in a few seconds\n\nThankyou for buying the OpenPandora. Enjoy using the device!" --timeout 6
+
+# ----
+
+# Write the control file so this script is not run on next boot 
+# (hackish I know but I want the flexability to drop a new script in later esp. in the early firmwares).
+
+touch /etc/pandora/first-boot
+# Make the control file writeable by all to allow the user to delete to rerun the wizard on next boot.
+chmod 0666 /etc/pandora/first-boot
+
+# ----
index 7adc693..86bd9b3 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/sh
 
 #!/bin/sh
 
-OP_CHECKFILE='/etc/bootup.cfg'
+OP_CHECKFILE='/etc/pandora/first-boot'
 OP_FIRSTRUN='xinit /usr/pandora/scripts/first-run-wizard.sh'
 
 OP_FIRSTRUN='xinit /usr/pandora/scripts/first-run-wizard.sh'
 
-
-[ -f $OP_CHECKFILE ] && echo "OP_STARTUP: $OP_CHECKFILE exists, not first boot." || $OP_FIRSTRUN
+[ -f $OP_CHECKFILE ] && echo "\nOP_STARTUP: $OP_CHECKFILE exists, not first boot." || $OP_FIRSTRUN