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