first-run-wizard.sh: Fixed timezone selection (now based on location)
[openpandora.oe.git] / recipes / pandora-system / pandora-first-run-wizard / first-run-wizard.sh
old mode 100644 (file)
new mode 100755 (executable)
index 32180cb..ad81fdc
@@ -7,6 +7,7 @@
 
 export LANG=en_GB.UTF-8
 export GTK2_RC_FILES=/usr/share/themes/Xfce/gtk-2.0/gtkrc
+xmodmap /etc/skel/.pndXmodmap
 
 # Ensure there is a wheel group for sudoers to be put into.
 # TODO: Do this somewhere better.
@@ -23,8 +24,7 @@ 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
-
+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
 # ----
 
 # Reset ROOT's password to something random 
@@ -45,19 +45,19 @@ 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
+#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
 
 # ----
 
@@ -86,7 +86,7 @@ while ! username=$(zenity --title="Enter your username" --entry --text "Please c
        zenity --title="Error" --error --text="Please try again." --timeout 6
 done
 
-while ! useradd -c "$name,,," -G adm,audio,video,netdev,wheel,plugdev "$username" ; do
+while ! useradd -c "$name,,," -G adm,audio,video,netdev,wheel,plugdev,users "$username" ; do
        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
 
@@ -118,10 +118,13 @@ EOF
 
 # 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 
+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, no spaces." --entry-text "$username-openpandora") || [ "x$hostname" = "x" ]; do 
        zenity --title="Error" --error --text="Please try again."
 done
 
+
+echo $hostname > /etc/hostname
+hostname =$(sed 's/ /_/g' /etc/hostname)
 echo $hostname > /etc/hostname
 echo "127.0.0.1 localhost.localdomain localhost $hostname" > /etc/hosts
 hostname -F /etc/hostname
@@ -133,7 +136,7 @@ if zenity --question --title="Autologin" --text="Do you wish to automatically lo
        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 
+       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 you're 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
@@ -146,32 +149,47 @@ fi
 
 # 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
+selection=""
+while [ x$selection = x ]; do
+selection=$(cat /etc/pandora/conf/gui.conf | awk -F\; '{print $1 "\n" $2 }' | zenity --width=500 --height=300 --title="Select the Default GUI" --list --column "Name" --column "Description" --text "Please select the Default GUI" )
+if [ x$selection = x ]; then
+  zenity --title="Error" --error --text="Please select a GUI." --timeout=6
+fi
 done
 
-if [ $launcher == "xfce" ]; then 
-       sed -i 's/.*sessions.*/sessions xfce4,pmenu/g' /etc/slim.conf
-       echo Xfce selected as default interface
+echo $selection
+
+gui=$(grep $selection /etc/pandora/conf/gui.conf | awk -F\; '{print $3}')
+stopcommand=$(grep $selection /etc/pandora/conf/gui.conf | awk -F\; '{print $4}')
+
+echo $gui
+
+if [ $gui ]; then 
+  sed -i "s/.*DEFAULT_SESSION=.*/DEFAULT_SESSION=$gui/g" /home/$username/.xinitrc
+  echo $selection selected as default interface
+  zenity --info --title="Selected session" --text "You selected $selection as default setting. You can always change your default GUI later." --timeout 6
 else
-       sed -i 's/.*sessions.*/sessions pmenu,xfce4/g' /etc/slim.conf
-       echo PMenu selected as default interface
+  sed -i 's/.*DEFAULT_SESSION=.*/DEFAULT_SESSION=startxfce4/g' /home/$username/.xinitrc
 fi
 
 # ----
 
 # 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
+while ! area=$(zenity --list --title "Select your time zone" --text="Please select your area" --column="Select your area" --print-column=1 "Africa" "America" "Asia" "Australia" "Europe" "Pacific" --width=500 --height=260) || [ "x$area" = "x" ] ; do
+       zenity --title="Error" --error --text="Please select your area." --timeout=6
+done
+
+while ! timezone=$(ls -1 /usr/share/zoneinfo/$area | zenity ---width=500 --height=200 --title="Select your closest location" --list --column "Closest Location" --text "Please select the location closest to you") || [ "x$timezone" = "x" ] ; do
+       zenity --title="Error" --error --text="Please select your location." --timeout=6
 done
 
 echo $timezone
-echo rm /etc/localtime && ln -s /usr/share/zoneinfo/Etc/$timezone /etc/localtime
+rm /etc/localtime && ln -s /usr/share/zoneinfo/$area/$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_m=`date +%m | sed 's/^0//'`
 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
@@ -202,6 +220,20 @@ zenity --info --title="Finished" --text "This concludes the First Boot Wizard.\n
 
 # ----
 
+# NOTE: This is just a temporary fix! These daemons should be removed from startup in the OE recipes. Until the time is found, we'll do it from here.
+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
+
+
 # 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).
 
@@ -210,3 +242,6 @@ touch /etc/pandora/first-boot
 chmod 0666 /etc/pandora/first-boot
 
 # ----
+else
+poweroff
+fi
\ No newline at end of file