slitaz-tools diff 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 diff
1.1 --- a/tinyutils/slitaz-installer.sh Sun Dec 30 21:46:11 2007 +0100 1.2 +++ b/tinyutils/slitaz-installer.sh Tue Feb 05 23:03:25 2008 +0100 1.3 @@ -1,23 +1,27 @@ 1.4 #!/bin/sh 1.5 -# SliTaz GNU/Linux text mode installer. 1.6 +# slitaz-installer.sh - SliTaz GNU/Linux installer script. 1.7 # 1.8 -VERSION=beta 1.9 +# So this is SliTaz installer all in SHell script compatible Ash from Busybox. 1.10 +# All the comments are in English but displayed messages are in French. The 1.11 +# scrip starts with a few main variables, then all the functions and then 1.12 +# a sequece of functions. 1.13 +# 1.14 +# (C) 2007-2008 SliTaz - GNU General Public License v3. 1.15 +# 1.16 +# Author : Christophe Lincoln <pankso@slitaz.org> 1.17 +# 1.18 +VERSION=0.1 1.19 1.20 +# We need to know cdrom device and kernel version string 1.21 +# to copy files. 1.22 DRIVE_NAME=`cat /proc/sys/dev/cdrom/info | grep "drive name" | cut -f 3` 1.23 CDROM=/dev/$DRIVE_NAME 1.24 +TARGET_ROOT=/mnt/target 1.25 KERNEL=vmlinuz-`uname -r` 1.26 1.27 -# Check if user is root. 1.28 -check_root() 1.29 -{ 1.30 - if test $(id -u) != 0 ; then 1.31 - echo -e " 1.32 -Vous devez être root pour continuer l'installation du système. Arrêt. 1.33 -Vous pouvez utiliser 'su' suivi du mot de passe root pour devenir 1.34 -administarteur.\n" 1.35 - exit 0 1.36 - fi 1.37 -} 1.38 +####################### 1.39 +# Installer functions # 1.40 +####################### 1.41 1.42 # Status function. 1.43 status() 1.44 @@ -32,11 +36,13 @@ 1.45 echo -e "\\033[0;39m ]" 1.46 } 1.47 1.48 -# Basic informations. 1.49 -echo "" 1.50 -echo -e "\033[1mSliTaz GNU/Linux - Installateur mode texte\033[0m" 1.51 -echo "================================================================================" 1.52 -echo " 1.53 +# Start install with basic informations. 1.54 +start_install() 1.55 +{ 1.56 + echo "" 1.57 + echo -e "\033[1mSliTaz GNU/Linux - Installateur mode texte\033[0m" 1.58 + echo "================================================================================" 1.59 + echo " 1.60 Bienvenue dans l'installateur en mode texte de SliTaz GNU/Linux. Il vous 1.61 suffirat de répondre à quelques questions lors des différentes étapes 1.62 d'installation. Avant de commencer, assurer vous de connaître le nom de la 1.63 @@ -47,79 +53,133 @@ 1.64 gestionnaire de démarrage GRUB, si besoin est. A noter que pour continuer 1.65 cette installation, vous devez avoir les droits d'administrateur root, qui 1.66 peuvent s'obtenir via la commande 'su' et le mot de passe 'root'." 1.67 -echo "" 1.68 -echo "================================================================================" 1.69 -echo "" 1.70 - 1.71 -echo -n "Commencer l'installation (oui/Non) ? "; read anser 1.72 -if [ ! "$anser" = "oui" ]; then 1.73 - echo -e "\nArrêt volontaire.\n" 1.74 - exit 0 1.75 -fi 1.76 + echo "" 1.77 + echo "================================================================================" 1.78 + echo "" 1.79 + echo -n "Commencer l'installation (oui/Non) ? "; read anser 1.80 + if [ ! "$anser" = "oui" ]; then 1.81 + echo -e "\nArrêt volontaire.\n" 1.82 + exit 0 1.83 + fi 1.84 +} 1.85 1.86 # Exit install if user is not root. 1.87 -#check_root 1.88 +check_root() 1.89 +{ 1.90 + if test $(id -u) != 0 ; then 1.91 + echo -e " 1.92 +Vous devez être root pour continuer l'installation du système. Arrêt. 1.93 +Vous pouvez utiliser 'su' suivi du mot de passe root pour devenir 1.94 +administarteur.\n" 1.95 + exit 0 1.96 + fi 1.97 +} 1.98 1.99 -# Ask for partitions. 1.100 -echo " 1.101 -Veuilliez indiquer la partition à utiliser pour installer SliTaz, 1.102 -exemple : /dev/hda1." 1.103 -echo "" 1.104 -echo -n "Partition à utiliser ? "; read anser 1.105 -if [ "$anser" == "" ]; then 1.106 - echo -e "\nPas de partition spécifiée. Arrêt.\n" 1.107 - exit 0 1.108 -else 1.109 - TARGET_DEV=$anser 1.110 -fi 1.111 +# We need a partition to install. 1.112 +ask_for_target_dev() 1.113 +{ 1.114 + echo " 1.115 + Veuilliez indiquer la partition à utiliser pour installer SliTaz, 1.116 + exemple : /dev/hda1." 1.117 + echo "" 1.118 + echo -n "Partition à utiliser ? "; read anser 1.119 + if [ "$anser" == "" ]; then 1.120 + echo -e "\nPas de partition spécifiée. Arrêt.\n" 1.121 + exit 0 1.122 + else 1.123 + TARGET_DEV=$anser 1.124 + fi 1.125 +} 1.126 1.127 # Mkfs if needed/wanted. 1.128 -echo " 1.129 -SliTaz va être installé sur la partition : $TARGET_DEV" 1.130 -echo "" 1.131 -echo -n "Faut t'il formater la partition en ext3 (oui/Non) ? "; read anser 1.132 -if [ "$anser" == "oui" ]; then 1.133 - mkfs.ext3 $TARGET_DEV 1.134 -else 1.135 - echo "Le système de fichiers déjà présent sera utilisé..." 1.136 -fi 1.137 +mkfs_target_dev() 1.138 +{ 1.139 + echo " 1.140 + SliTaz va être installé sur la partition : $TARGET_DEV" 1.141 + echo "" 1.142 + echo -n "Faut t'il formater la partition en ext3 (oui/Non) ? "; read anser 1.143 + if [ "$anser" == "oui" ]; then 1.144 + mkfs.ext3 $TARGET_DEV 1.145 + else 1.146 + echo "Le système de fichiers déjà présent sera utilisé..." 1.147 + fi 1.148 +} 1.149 1.150 -# Mount. 1.151 -echo "Montage de la partitions et du cdrom..." 1.152 -mkdir -p /mnt/target /media/cdrom 1.153 -mount $TARGET_DEV /mnt/target 1.154 -mount -t iso9660 $CDROM /media/cdrom 1.155 +# Mount target device and cdrom. 1.156 +mount_devices() 1.157 +{ 1.158 + mkdir -p $TARGET_ROOT /media/cdrom 1.159 + echo "Montage de la partitions et du cdrom..." 1.160 + mount $TARGET_DEV $TARGET_ROOT 1.161 + mount -t iso9660 $CDROM /media/cdrom 1.162 +} 1.163 1.164 -# Copy and install. 1.165 -echo -n "Création du répertoire /boot..." 1.166 -mkdir -p /mnt/target/boot 1.167 -status 1.168 -echo -n "Copie du noyau Linux..." 1.169 -cp /media/cdrom/boot/bzImage /mnt/target/boot/$KERNEL 1.170 -status 1.171 +# Copy and install Kernel. 1.172 +install_kernel() 1.173 +{ 1.174 + echo -n "Création du répertoire /boot..." 1.175 + mkdir -p $TARGET_ROOT/boot 1.176 + status 1.177 + echo -n "Copie du noyau Linux..." 1.178 + cp /media/cdrom/boot/bzImage $TARGET_ROOT/boot/$KERNEL 1.179 + status 1.180 +} 1.181 1.182 -# Copy and extract lzma'ed or gziped rootfs 1.183 -echo -n "Copie du système de fichier racine..." 1.184 -cp /media/cdrom/boot/rootfs.gz /mnt/target 1.185 -status 1.186 -echo "Extraction du système de fichiers racine (rootfs.gz)..." 1.187 -cd /mnt/target 1.188 -(zcat rootfs.gz 2>/dev/null || lzma d rootfs.gz -so) | cpio -id 1.189 -echo -n "Suppression des fichiers copiés..." 1.190 -rm -f rootfs rootfs.cpio rootfs.gz init 1.191 -status 1.192 +# Syslinux/isolinux. 1.193 +copy_bootloaders() 1.194 +{ 1.195 + echo -n "Copie des bootloaders syslinux/isolinux..." 1.196 + if [ -d "/media/cdrom/boot/syslinux" ]; then 1.197 + cp -a /media/cdrom/boot/syslinux $TARGET_ROOT/boot 1.198 + fi 1.199 + if [ -d "/media/cdrom/boot/isolinux" ]; then 1.200 + cp -a /media/cdrom/boot/isolinux $TARGET_ROOT/boot 1.201 + fi 1.202 + status 1.203 +} 1.204 1.205 -# /etc/skel 1.206 -echo -n "Copie des fichiers personnels de hacker dans : /etc/skel..." 1.207 -cp -a /mnt/target/home/hacker /mnt/target/etc/skel 1.208 -status 1.209 +# Copy and extract lzma'ed or gziped rootfs. 1.210 +copy_extract_rootfs() 1.211 +{ 1.212 + echo -n "Copie du système de fichier racine..." 1.213 + cp /media/cdrom/boot/rootfs.gz $TARGET_ROOT 1.214 + status 1.215 + echo "Extraction du système de fichiers racine (rootfs.gz)..." 1.216 + cd $TARGET_ROOT 1.217 + (zcat rootfs.gz 2>/dev/null || lzma d rootfs.gz -so) | cpio -id 1.218 + echo -n "Suppression des fichiers copiés..." 1.219 + rm -f rootfs rootfs.cpio rootfs.gz init 1.220 + status 1.221 +} 1.222 1.223 -# Creat the target GRUB configuration. 1.224 -# 1.225 -if [ ! -f /mnt/target/boot/grub/menu.lst ]; then 1.226 - echo "Création du fichier de configuration de GRUB (menu.lst)..." 1.227 - mkdir -p /mnt/target/boot/grub 1.228 -cat > /mnt/target/boot/grub/menu.lst << EOF 1.229 +# /etc/skel with hacker default personnal files. 1.230 +creat_etc_skel() 1.231 +{ 1.232 + echo -n "Copie des fichiers personnels de hacker dans : /etc/skel..." 1.233 + cp -a $TARGET_ROOT/home/hacker $TARGET_ROOT/etc/skel 1.234 + status 1.235 +} 1.236 + 1.237 +# Determin disk letter, GRUB partition number and GRUB disk number. 1.238 +grub_install() 1.239 +{ 1.240 + DISK_LETTER=${TARGET_DEV#/dev/[h-s]d} 1.241 + DISK_LETTER=${DISK_LETTER%[0-9]} 1.242 + GRUB_PARTITION=$((${TARGET_DEV#/dev/hd[a-z]}-1)) 1.243 + for disk in a b c d e f g h 1.244 + do 1.245 + nb=$(($nb+1)) 1.246 + if [ "$disk" = "$DISK_LETTER" ]; then 1.247 + GRUB_DISK=$(($nb-1)) 1.248 + break 1.249 + fi 1.250 + done 1.251 + GRUB_ROOT="(hd${GRUB_DISK},${GRUB_PARTITION})" 1.252 + 1.253 + # Creat the target GRUB configuration. 1.254 + echo -n "Création du fichier de configuration de GRUB (menu.lst)..." 1.255 + mkdir -p $TARGET_ROOT/boot/grub 1.256 + cat > $TARGET_ROOT/boot/grub/menu.lst << _EOF_ 1.257 # /boot/grub/menu.lst: GRUB boot loader configuration. 1.258 # 1.259 1.260 @@ -135,33 +195,68 @@ 1.261 # For booting SliTaz from : $TARGET_DEV 1.262 # 1.263 title SliTaz GNU/Linux (cooking) (Kernel $KERNEL) 1.264 - root(hd0,0) 1.265 + root $GRUB_ROOT 1.266 kernel /boot/$KERNEL root=$TARGET_DEV 1.267 1.268 -EOF 1.269 - fi 1.270 - 1.271 -# End info 1.272 -echo "" 1.273 -echo -e "\033[1mInstallation terminée\033[0m 1.274 +_EOF_ 1.275 + status 1.276 + # GRUB info with disk name used for grub-install 1.277 + TARGET_DISK=`echo $TARGET_DEV | sed s/"[0-9]"/''/` 1.278 + echo "" 1.279 + echo -e "\033[1mGRUB - Informations et installation\033[0m 1.280 ================================================================================ 1.281 1.282 Avant de redémarrer sur votre nouveau système SliTaz GNU/Linux, veuillez vous 1.283 assurer qu'un gestionnaire de démarrage est bien installé. Si ce n'est pas le 1.284 -cas vous pouvez lancer la commande (en modifiant 'hda' en fonction de votre 1.285 -système) : 1.286 +cas vous pouvez répondre oui et installer GRUB ou lancer la commande : 1.287 1.288 - # grub-install --root-directory=/mnt/target /dev/hda 1.289 + # grub-install --no-floppy --root-directory=$TARGET_ROOT $TARGET_DISK 1.290 1.291 Les lignes suivantes on été ajoutées au fichier de configuration de GRUB 1.292 -/boot/grub/menu.lst de la cible. Elles feront démarrer SliTaz en modifiant 1.293 -la valeure root(hd0,0) en fonction de votre système. Si vous n'installé pas 1.294 -GRUB, vous pouvez utiliser ces même lignes dans un autre fichier menu.lst, 1.295 -situé sur une autre partitions : 1.296 +/boot/grub/menu.lst de la cible. Elles feront démarrer SliTaz en installant 1.297 +GRUB. Si vous n'installez pas GRUB, vous pouvez utiliser ces même lignes dans 1.298 +un autre fichier menu.lst, situé sur une autre partitions : 1.299 1.300 title SliTaz GNU/Linux (cooking) (Kernel $KERNEL) 1.301 - root(hd0,0) 1.302 + root $GRUB_ROOT 1.303 kernel /boot/$KERNEL root=$TARGET_DEV 1.304 1.305 ================================================================================" 1.306 -echo "" 1.307 + echo "" 1.308 + 1.309 + # GRUB install 1.310 + echo -n "Installer GRUB sur le disque : $TARGET_DISK (oui/Non) ? "; read anser 1.311 + if [ "$anser" = "oui" ]; then 1.312 + grub-install --no-floppy --root-directory=$TARGET_ROOT $TARGET_DISK 1.313 + fi 1.314 +} 1.315 + 1.316 +# End of installation 1.317 +end_of_install() 1.318 +{ 1.319 + echo " 1.320 +================================================================================ 1.321 +Installation terminée. Vous pouvez dès maintenant redémarrer sur votre nouveau 1.322 +système SliTaz GNU/Linux et commencer à finement le configurer en fonction de 1.323 +vos besoins et préférences. Vous trouverez un support technique gratuit via 1.324 +la liste de discussion et/ou le forum officiel." 1.325 + echo "" 1.326 +} 1.327 + 1.328 +###################### 1.329 +# Installer sequence # 1.330 +###################### 1.331 + 1.332 +start_install 1.333 +check_root 1.334 +ask_for_target_dev 1.335 +mkfs_target_dev 1.336 +mount_devices 1.337 +install_kernel 1.338 +copy_bootloaders 1.339 +copy_extract_rootfs 1.340 +creat_etc_skel 1.341 +grub_install 1.342 +end_of_install 1.343 + 1.344 +exit 0