slitaz-tools view tinyutils/slitaz-installer.sh @ rev 48

Add *box desktop files
author Christophe Lincoln <pankso@slitaz.org>
date Tue Feb 05 23:03:25 2008 +0100 (2008-02-05)
parents ea7bf0fd9f96
children e55103647df6
line source
1 #!/bin/sh
2 # slitaz-installer.sh - SliTaz GNU/Linux installer script.
3 #
4 # So this is SliTaz installer all in SHell script compatible Ash from Busybox.
5 # All the comments are in English but displayed messages are in French. The
6 # scrip starts with a few main variables, then all the functions and then
7 # a sequece of functions.
8 #
9 # (C) 2007-2008 SliTaz - GNU General Public License v3.
10 #
11 # Author : Christophe Lincoln <pankso@slitaz.org>
12 #
13 VERSION=0.1
15 # We need to know cdrom device and kernel version string
16 # to copy files.
17 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3`
18 CDROM=/dev/$DRIVE_NAME
19 TARGET_ROOT=/mnt/target
20 KERNEL=vmlinuz-`uname -r`
22 #######################
23 # Installer functions #
24 #######################
26 # Status function.
27 status()
28 {
29 local CHECK=$?
30 echo -en "\\033[70G[ "
31 if [ $CHECK = 0 ]; then
32 echo -en "\\033[1;33mOK"
33 else
34 echo -en "\\033[1;31mFailed"
35 fi
36 echo -e "\\033[0;39m ]"
37 }
39 # Start install with basic informations.
40 start_install()
41 {
42 echo ""
43 echo -e "\033[1mSliTaz GNU/Linux - Installateur mode texte\033[0m"
44 echo "================================================================================"
45 echo "
46 Bienvenue dans l'installateur en mode texte de SliTaz GNU/Linux. Il vous
47 suffirat de répondre à quelques questions lors des différentes étapes
48 d'installation. Avant de commencer, assurer vous de connaître le nom de la
49 partitions sur laquelle vous désirez installer SliTaz. L'installateur va
50 commencer par vous proposer de formater la partition cible et la monter.
51 Ensuite il va monter le cdrom, décompresser les fichiers et les installer
52 sur la cible. Pour finir, vous aurez aussi la possibilité d'installer le
53 gestionnaire de démarrage GRUB, si besoin est. A noter que pour continuer
54 cette installation, vous devez avoir les droits d'administrateur root, qui
55 peuvent s'obtenir via la commande 'su' et le mot de passe 'root'."
56 echo ""
57 echo "================================================================================"
58 echo ""
59 echo -n "Commencer l'installation (oui/Non) ? "; read anser
60 if [ ! "$anser" = "oui" ]; then
61 echo -e "\nArrêt volontaire.\n"
62 exit 0
63 fi
64 }
66 # Exit install if user is not root.
67 check_root()
68 {
69 if test $(id -u) != 0 ; then
70 echo -e "
71 Vous devez être root pour continuer l'installation du système. Arrêt.
72 Vous pouvez utiliser 'su' suivi du mot de passe root pour devenir
73 administarteur.\n"
74 exit 0
75 fi
76 }
78 # We need a partition to install.
79 ask_for_target_dev()
80 {
81 echo "
82 Veuilliez indiquer la partition à utiliser pour installer SliTaz,
83 exemple : /dev/hda1."
84 echo ""
85 echo -n "Partition à utiliser ? "; read anser
86 if [ "$anser" == "" ]; then
87 echo -e "\nPas de partition spécifiée. Arrêt.\n"
88 exit 0
89 else
90 TARGET_DEV=$anser
91 fi
92 }
94 # Mkfs if needed/wanted.
95 mkfs_target_dev()
96 {
97 echo "
98 SliTaz va être installé sur la partition : $TARGET_DEV"
99 echo ""
100 echo -n "Faut t'il formater la partition en ext3 (oui/Non) ? "; read anser
101 if [ "$anser" == "oui" ]; then
102 mkfs.ext3 $TARGET_DEV
103 else
104 echo "Le système de fichiers déjà présent sera utilisé..."
105 fi
106 }
108 # Mount target device and cdrom.
109 mount_devices()
110 {
111 mkdir -p $TARGET_ROOT /media/cdrom
112 echo "Montage de la partitions et du cdrom..."
113 mount $TARGET_DEV $TARGET_ROOT
114 mount -t iso9660 $CDROM /media/cdrom
115 }
117 # Copy and install Kernel.
118 install_kernel()
119 {
120 echo -n "Création du répertoire /boot..."
121 mkdir -p $TARGET_ROOT/boot
122 status
123 echo -n "Copie du noyau Linux..."
124 cp /media/cdrom/boot/bzImage $TARGET_ROOT/boot/$KERNEL
125 status
126 }
128 # Syslinux/isolinux.
129 copy_bootloaders()
130 {
131 echo -n "Copie des bootloaders syslinux/isolinux..."
132 if [ -d "/media/cdrom/boot/syslinux" ]; then
133 cp -a /media/cdrom/boot/syslinux $TARGET_ROOT/boot
134 fi
135 if [ -d "/media/cdrom/boot/isolinux" ]; then
136 cp -a /media/cdrom/boot/isolinux $TARGET_ROOT/boot
137 fi
138 status
139 }
141 # Copy and extract lzma'ed or gziped rootfs.
142 copy_extract_rootfs()
143 {
144 echo -n "Copie du système de fichier racine..."
145 cp /media/cdrom/boot/rootfs.gz $TARGET_ROOT
146 status
147 echo "Extraction du système de fichiers racine (rootfs.gz)..."
148 cd $TARGET_ROOT
149 (zcat rootfs.gz 2>/dev/null || lzma d rootfs.gz -so) | cpio -id
150 echo -n "Suppression des fichiers copiés..."
151 rm -f rootfs rootfs.cpio rootfs.gz init
152 status
153 }
155 # /etc/skel with hacker default personnal files.
156 creat_etc_skel()
157 {
158 echo -n "Copie des fichiers personnels de hacker dans : /etc/skel..."
159 cp -a $TARGET_ROOT/home/hacker $TARGET_ROOT/etc/skel
160 status
161 }
163 # Determin disk letter, GRUB partition number and GRUB disk number.
164 grub_install()
165 {
166 DISK_LETTER=${TARGET_DEV#/dev/[h-s]d}
167 DISK_LETTER=${DISK_LETTER%[0-9]}
168 GRUB_PARTITION=$((${TARGET_DEV#/dev/hd[a-z]}-1))
169 for disk in a b c d e f g h
170 do
171 nb=$(($nb+1))
172 if [ "$disk" = "$DISK_LETTER" ]; then
173 GRUB_DISK=$(($nb-1))
174 break
175 fi
176 done
177 GRUB_ROOT="(hd${GRUB_DISK},${GRUB_PARTITION})"
179 # Creat the target GRUB configuration.
180 echo -n "Création du fichier de configuration de GRUB (menu.lst)..."
181 mkdir -p $TARGET_ROOT/boot/grub
182 cat > $TARGET_ROOT/boot/grub/menu.lst << _EOF_
183 # /boot/grub/menu.lst: GRUB boot loader configuration.
184 #
186 # By default, boot the first entry.
187 default 0
189 # Boot automatically after 20 secs.
190 timeout 20
192 # Change the colors.
193 color yellow/brown light-green/black
195 # For booting SliTaz from : $TARGET_DEV
196 #
197 title SliTaz GNU/Linux (cooking) (Kernel $KERNEL)
198 root $GRUB_ROOT
199 kernel /boot/$KERNEL root=$TARGET_DEV
201 _EOF_
202 status
203 # GRUB info with disk name used for grub-install
204 TARGET_DISK=`echo $TARGET_DEV | sed s/"[0-9]"/''/`
205 echo ""
206 echo -e "\033[1mGRUB - Informations et installation\033[0m
207 ================================================================================
209 Avant de redémarrer sur votre nouveau système SliTaz GNU/Linux, veuillez vous
210 assurer qu'un gestionnaire de démarrage est bien installé. Si ce n'est pas le
211 cas vous pouvez répondre oui et installer GRUB ou lancer la commande :
213 # grub-install --no-floppy --root-directory=$TARGET_ROOT $TARGET_DISK
215 Les lignes suivantes on été ajoutées au fichier de configuration de GRUB
216 /boot/grub/menu.lst de la cible. Elles feront démarrer SliTaz en installant
217 GRUB. Si vous n'installez pas GRUB, vous pouvez utiliser ces même lignes dans
218 un autre fichier menu.lst, situé sur une autre partitions :
220 title SliTaz GNU/Linux (cooking) (Kernel $KERNEL)
221 root $GRUB_ROOT
222 kernel /boot/$KERNEL root=$TARGET_DEV
224 ================================================================================"
225 echo ""
227 # GRUB install
228 echo -n "Installer GRUB sur le disque : $TARGET_DISK (oui/Non) ? "; read anser
229 if [ "$anser" = "oui" ]; then
230 grub-install --no-floppy --root-directory=$TARGET_ROOT $TARGET_DISK
231 fi
232 }
234 # End of installation
235 end_of_install()
236 {
237 echo "
238 ================================================================================
239 Installation terminée. Vous pouvez dès maintenant redémarrer sur votre nouveau
240 système SliTaz GNU/Linux et commencer à finement le configurer en fonction de
241 vos besoins et préférences. Vous trouverez un support technique gratuit via
242 la liste de discussion et/ou le forum officiel."
243 echo ""
244 }
246 ######################
247 # Installer sequence #
248 ######################
250 start_install
251 check_root
252 ask_for_target_dev
253 mkfs_target_dev
254 mount_devices
255 install_kernel
256 copy_bootloaders
257 copy_extract_rootfs
258 creat_etc_skel
259 grub_install
260 end_of_install
262 exit 0