pandora-first-run-wizard: Update script to add a background to the X window.
[openpandora.oe.git] / recipes / pandora-system / pandora-first-run-wizard / first-run-wizard.sh
1 #!/bin/sh
2
3 # Based on the scripts by JohnX/Mer Project - http://wiki.maemo.org/Mer/
4 # Reworked for the OpenPandora - John Willis/Michael Mrozek
5
6 # You can start the wizard from the shell using 'xinit ./first-boot-init.sh'
7 # Maybe we run it for the first time from rc5.d and delete the symlink at the end of the script?
8
9 export LANG=en_GB.UTF-8
10 export GTK2_RC_FILES=/usr/share/themes/Xfce/gtk-2.0/gtkrc
11
12 # We will load up a background image here as soon as we have a tool for that :)
13 WALLPAPER=`/usr/share/backgrounds/op_default.png`
14 hsetroot -center $WALLPAPER
15
16 # Greet the user
17 zenity --info --title="Pandoras Box has been opened." --text "Welcome. This Wizard will help you setting up your Pandora before your first use."
18
19 # Should we really enable SWAP?
20 #swap_part=$(sfdisk -l /dev/mmcblk? | grep swap | cut -d" " -f1)
21 #if [ x$swap_part != x ] ; then
22 #       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")
23 #       if [ "$use_swap" = "Use swap on $swap_part" ] ; then
24 #               swapon $swap_part
25 #               echo "$swap_part none swap sw 0 0" >> /etc/fstab
26 #       fi
27 #fi
28
29 # First, setup the full name and username.
30
31 while ! name=$(zenity --title="Enter your name" --entry --text "Please enter your full name.") || [ "x$name" = "x" ] ; do
32         zenity --title="Error" --error --text="Please try again."
33 done
34
35 username_guess=$(echo "$name" | cut -d" " -f1 | tr A-Z a-z)
36
37 while ! username=$(zenity --title="Enter your username" --entry --text "Please choose a short username.
38 It should be all lowercase and
39 contain only letters and numbers." --entry-text "$username_guess") || [ "x$username" = "x" ] ; do
40         zenity --title="Error" --error --text="Please try again."
41 done
42
43 # Note: Group wheel doesn't exist in the current image! Should be created for easy sudo!
44
45 while ! useradd -c "$name,,," -G adm,audio,video,netdev,wheel,plugdev "$username" ; do
46         username=$(zenity --title="Please check username" --entry --text "Please be sure that your
47 username consists of only
48 letters and numbers." --entry-text "$username")
49 done
50
51 # Password setup.
52
53 password=""
54 while [ x$password = x ] ; do
55         password1=$(zenity --title=Password --entry --text="Choose a new password." --hide-text)
56         password2=$(zenity --title=Confirm --entry --text="Confirm your new password." --hide-text)
57         if [ $password1 != $password2 ] ; then 
58                 zenity --title="Error" --error --text="Passwords don't match.
59 Please try again."
60         else if [ x$password1 = x ] ; then
61                 zenity --title="Error" --error --text="Password can't be blank!
62 Please try again."
63                 else
64                         password=$password1
65                 fi
66         fi
67 done
68
69 # Setting the password doesn't work yet (permission issues)
70
71 passwd "$username" <<EOF
72 $password
73 $password
74 EOF
75
76
77 # Name our little baby
78
79 while ! hostname=$(zenity --title="Name your Pandora" --entry --text "Please choose a name for
80 your Pandora. It should only contain
81 letters, numbers and dashes." --entry-text "$username-pandora") || [ "x$hostname" = "x" ]; do 
82         zenity --title="Error" --error --text="Please try again."
83 done
84
85 echo $hostname > /etc/hostname
86 echo "127.0.0.1 localhost.localdomain localhost $hostname" > /etc/hosts
87 #cat /usr/share/first-boot-wizard/hosts-template >> /etc/hosts
88 hostname -F /etc/hostname
89
90
91 # Set the correct user for Autologin and enable / disable it.
92
93 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        
94      # echo "PREFERED_USER=$username" > /etc/default/autologin
95       sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
96       sed -i 's/.*auto_login.*/auto_login yes/g' /etc/slim.conf
97       else
98       sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
99 fi
100
101 # I don't know yet how to setup which GUI will run as default. At the moment, it just creates a small file and puts XFCE or cpasjuste into it :)
102
103 if zenity --question --title="Default GUI" --text="Now you can choose whether you want to boot into a full desktop or a gaming console-like launcher as default.\n\nYou can always change that setting later." --ok-label="Full Desktop (XFCE)"  --cancel-label="Gaming 
104 console-like Launcher"; then 
105         echo XFCE > /etc/bootup.cfg
106         else
107         echo cpasjuste > /etc/bootup.cfg
108 fi
109
110 zenity --info --title="Finished" --text "This concludes the First Boot Wizard.\nThanks for buying the Pandora. Enjoy the device!"
111