vairous: add in local updates for tasks/images.
[openpandora.oe.git] / recipes / pandora-system / pandora-first-run-wizard / first-boot-wizard.sh
1 #!/bin/sh
2
3 # notice: system dbus must be running
4
5 export LANG=en_GB.UTF-8
6 # for testing set display to something sane
7 if [ "x$DISPLAY" = "x" ]; then
8         export DISPLAY=:0
9 fi
10 export MB_HUNG_APP_HANDLER='/usr/bin/hd-hung-app-handler'
11 export GTK2_RC_FILES=/usr/share/themes/default/gtk-2.0/gtkrc:/usr/share/themes/default/gtk-2.0/gtkrc.maemo_af_desktop
12
13 WALLPAPER=`grep File= /usr/share/backgrounds/default.desktop | cut -d"=" -f2`
14 hsetroot -center $WALLPAPER
15
16 export `dbus-launch --exit-with-session`
17
18 #/usr/bin/maemo-launcher --daemon --booster gtk
19
20 /usr/lib/gconf2/gconfd-2 &
21 #/usr/lib/libgconf2-4/gconfd-2 &
22
23 #/usr/lib/sapwood/sapwood-server &
24
25 SHOW_CURSOR=yes
26
27 #/usr/bin/matchbox-window-manager \
28 #      -theme default \
29 #      -use_titlebar yes \
30 #      -use_desktop_mode plain \
31 #      -use_lowlight no \
32 #      -use_cursor $SHOW_CURSOR \
33 #      -use_super_modal no &
34
35 /usr/bin/x-window-manager
36
37 #maemo-invoker /usr/bin/hildon-input-method.launch &
38
39 #if /usr/bin/lshal | grep info.product | grep -i keyboard ; then
40 #       /usr/bin/gconftool-2 -s -t bool /apps/osso/inputmethod/keyboard_available true 
41 #fi
42
43
44 ##First we regenerate existing ssh keys:
45 #rm -f /etc/ssh/ssh_host*
46 #/usr/bin/ssh-keygen -t dsa -q -N "" -f /etc/ssh/ssh_host_dsa_key | \
47 #       zenity --title="Please wait..." --text="Generating SSH DSA key." \
48 #       --progress --pulsate --auto-close
49 #/usr/bin/ssh-keygen -t rsa -q -N "" -f /etc/ssh/ssh_host_rsa_key |
50 #       zenity --title="Please wait..." --text="Generating SSH RSA key." \
51 #       --progress --pulsate --auto-close
52
53
54 swap_part=$(sfdisk -l /dev/mmcblk? | grep swap | cut -d" " -f1)
55 if [ x$swap_part != x ] ; then
56         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")
57         if [ "$use_swap" = "Use swap on $swap_part" ] ; then
58                 swapon $swap_part
59                 echo "$swap_part none swap sw 0 0" >> /etc/fstab
60         fi
61 fi
62
63 while ! name=$(zenity --title="Type your name" --entry --text "Please type your full name.") || [ "x$name" = "x" ] ; do
64         zenity --title="Error" --error --text="Please try again."
65 done
66
67 username_guess=$(echo "$name" | cut -d" " -f1 | tr A-Z a-z)
68
69 while ! username=$(zenity --title="Type your username" --entry --text "Please choose a short username.
70 It should be all lowercase and
71 contain only letters and numbers." --entry-text "$username_guess") || [ "x$username" = "x" ] ; do
72         zenity --title="Error" --error --text="Please try again."
73 done
74
75 while ! adduser --gecos "$name,,," --disabled-password "$username" ; do
76         username=$(zenity --title="Please check username" --entry --text "Please be sure that your
77 username consists of only
78 letters and numbers." --entry-text "$username")
79 done
80
81 password=""
82 while [ x$password = x ] ; do
83         password1=$(zenity --title=Password --entry --text="Choose a new password." --hide-text)
84         password2=$(zenity --title=Confirm --entry --text="Confirm your new password." --hide-text)
85         if [ $password1 != $password2 ] ; then 
86                 zenity --title="Error" --error --text="Passwords don't match.
87 Please try again."
88         else if [ x$password1 = x ] ; then
89                 zenity --title="Error" --error --text="Password can't be blank!
90 Please try again."
91                 else
92                         password=$password1
93                 fi
94         fi
95 done
96
97 passwd "$username" <<EOF
98 $password
99 $password
100 EOF
101
102 for group in users admin adm audio video netdev plugdev ; do 
103         if ! grep ^$group: /etc/group ; then
104                 addgroup --system "$group"
105         fi
106         adduser "$username" "$group" ; done
107 echo "PREFERED_USER=$username" > /etc/default/autologin
108
109 mkdir -p /etc/sudoers.d && echo '# Members of the admin group may gain root privileges' > /etc/sudoers.d/02ubuntu-admin
110 echo '%admin ALL=(ALL) ALL' >> /etc/sudoers.d/02ubuntu-admin
111 update-sudoers
112 while ! hostname=$(zenity --title="Choose a device name" --entry --text "Please choose a name for
113 your OpenPandora. It should only contain
114 letters, numbers and dashes." --entry-text "$username-pandora") || [ "x$hostname" = "x" ]; do 
115         zenity --title="Error" --error --text="Please try again."
116 done
117
118 echo $hostname > /etc/hostname
119 echo "127.0.0.1 localhost.localdomain localhost $hostname" > /etc/hosts
120 cat /usr/share/first-boot-wizard/hosts-template >> /etc/hosts
121 hostname -F /etc/hostname
122
123 killall maemo-launcher
124 killall gconfd-2