task-pandora-*: Commit latest Xfce and Core tasks to build PAM correctly and package...
[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 # Ensure there is a wheel group for sudoers to be put into.
13 # TODO: Do this somewhere better.
14 groupadd wheel
15
16 # We load up a background image here
17 export WALLPAPER=/usr/share/backgrounds/op_default.png
18 hsetroot -center $WALLPAPER
19
20 # Greet the user
21 zenity --info --title="Pandoras Box has been opened." --text "Welcome. This wizard will help you setting up your new OpenPandora handheld before your first use."
22
23 # Should we really enable SWAP?
24 #swap_part=$(sfdisk -l /dev/mmcblk? | grep swap | cut -d" " -f1)
25 #if [ x$swap_part != x ] ; then
26 #       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")
27 #       if [ "$use_swap" = "Use swap on $swap_part" ] ; then
28 #               swapon $swap_part
29 #               echo "$swap_part none swap sw 0 0" >> /etc/fstab
30 #       fi
31 #fi
32
33 # First, setup the full name and username.
34
35 while ! name=$(zenity --title="Enter your name" --entry --text "Please enter your full name.") || [ "x$name" = "x" ] ; do
36         zenity --title="Error" --error --text="Please try again."
37 done
38
39 username_guess=$(echo "$name" | cut -d" " -f1 | tr A-Z a-z)
40
41 while ! username=$(zenity --title="Enter your username" --entry --text "Please choose a short username.
42 It should be all lowercase and
43 contain only letters and numbers." --entry-text "$username_guess") || [ "x$username" = "x" ] ; do
44         zenity --title="Error" --error --text="Please try again."
45 done
46
47 while ! useradd -c "$name,,," -G adm,audio,video,netdev,wheel,plugdev "$username" ; do
48         username=$(zenity --title="Please check username" --entry --text "Please be sure that your
49 username consists of only
50 letters and numbers." --entry-text "$username")
51 done
52
53 # Password setup.
54
55 password=""
56 while [ x$password = x ] ; do
57         password1=$(zenity --title=Password --entry --text="Choose a new password." --hide-text)
58         password2=$(zenity --title=Confirm --entry --text="Confirm your new password." --hide-text)
59         if [ $password1 != $password2 ] ; then 
60                 zenity --title="Error" --error --text="Passwords don't match.
61 Please try again."
62         else if [ x$password1 = x ] ; then
63                 zenity --title="Error" --error --text="Password can not be blank!
64 Please try again."
65                 else
66                         password=$password1
67                 fi
68         fi
69 done
70
71 passwd "$username" <<EOF
72 $password
73 $password
74 EOF
75
76 # Name our little baby
77
78 while ! hostname=$(zenity --title="Name your Pandora" --entry --text "Please choose a name for
79 your Pandora. It should only contain
80 letters, numbers and dashes." --entry-text "$username-pandora") || [ "x$hostname" = "x" ]; do 
81         zenity --title="Error" --error --text="Please try again."
82 done
83
84 echo $hostname > /etc/hostname
85 echo "127.0.0.1 localhost.localdomain localhost $hostname" > /etc/hosts
86 #cat /usr/share/first-boot-wizard/hosts-template >> /etc/hosts
87 hostname -F /etc/hostname
88
89
90 # Set the correct user for Autologin and enable / disable it.
91
92 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        
93      # echo "PREFERED_USER=$username" > /etc/default/autologin
94       sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
95       sed -i 's/.*auto_login.*/auto_login yes/g' /etc/slim.conf
96       else
97       sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
98 fi
99
100 # Setup which GUI will run as default. At the moment, it just creates a small file and puts Xfce or PMenu into it :)
101
102 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="Gaming 
103 console-like Launcher"; then 
104         echo Xfce > /etc/bootup.cfg
105         else
106         echo PMenu > /etc/bootup.cfg
107 fi
108
109 zenity --info --title="Finished" --text "This concludes the First Boot Wizard.\nThanks for buying the OpenPandora. Enjoy the device!"