Pages : 1
#1 Le 07/09/2010, à 23:15
- Josepe36
installateur ubuntu alternatif
Bonsoir à tous
comme l'indique le titre je vous présente ici un script que j'ai écris ces derniers jours avec la participation de babdu69.
Bon je vous demanderai d'etre clément avec moi car je sus pas un pro et je reste dans une demarche d'apprentissage
Donc ce script ce lance avec sudo, et à partir d'une livesession.
Le principe :
pour l'instant le script ne prend pas en charge le partitionement ni le formatage donc il est indispensable d'avoir au moins une partition EXT4 et SWAP.
en live session le contenu du cd se trouve dans /cdrom, le systeme de fichier utiliser est un squashfs au doux nom de /cdrom/casper/filesystem.squashfs.
l'idée c'est donc de copié son contenu dans la racine d'installation, de copier le noyau et l'initrd dans le /boot de la nouvelle racine, d'éditer un fstab en consequence.
ensuite bien sur il faut creer un utilisateur, le mettre dans la liste des utilisateurs de sudo, et creer un mot de passe pour root, sans oublier /etc/hosts et /etc/hostname.
j'y ai ajoutter une fonction qui permet de sauvegarder le mbr, des fois qu'un retour sous windows soit voulu plus tard.
bon je papotte pas plus et vous livre le code, vos suggestions, modifications, conseil sur l'eciture des fonctions sont les bienvenue dans la mesure ou je peux améliorer mon bash.
#! /bin/bash
animation()
{
sleep 0.2
echo -e "
"; sleep 0.2
clear ;
echo -e "
x x
x x
x x
x x
x x x
"; sleep 0.1
clear ;
echo -e "
x x x x
x x x x
x x x x x
x x x x
x x x x x x "; sleep 0.1
clear ;
echo -e "
x x x x x x
x x x x x x
x x x x x x x
x x x x x x
x x x x x x x x x "; sleep 0.1
clear ;
echo -e "
x x x x x x x x
x x x x x x xx x
x x x x x x x x x x
x x x x x x x xx
x x x x x x x x x x x "; sleep 0.1
clear ;
echo -e "
x x x x x x x x x x x
x x x x x x xx x x
x x x x x x x x x x x
x x x x x x x xx x
x x x x x x x x x x x x"; sleep 0.1
clear ;
echo -e "
x x x x x x x x x x x x x
x x x x x x xx x x x x
x x x x x x x x x x x x x
x x x x x x x xx x x x
x x x x x x x x x x x x x x x
*_______________________________________________________________
"; sleep 0.1
reset ;
echo -e "
x x x x x x x x x x x x x
x x x x x x xx x x x x
x x x x x x x x x x x x x
x x x x x x x xx x x x
x x x x x x x x x x x x x x x
*_______________________________________________________________
"; sleep 0.1
}
installation()
{
animation ;
echo -e "
CETTE METHODE D'INSTALLATION NE DOIT ETRE UTILISÉ
QU'EN CAS DE DERNIER RECOUR, SI VOUS AVEZ ESSAYÉ
LE LIVECD OFFICIEL, LE LIVEUSB, LE NETINSTALL ET
QUE RIEN N'A DONNÉ DE RESULTAT.
JE VOUS CONSEIL AUSSI UNE VERSION FRANÇAISE
D'UBUNTU AFIN DE VOUS EVITER DES MANIPULATIONS
SUPLÉMENTAIRES.
VEILLEZ A BIEN REPONDRE AUX QUESTIONS DEMANDÉES.
ENTREE POUR CONTINUER, ctrl+c POUR QUITTER";
read a
control=$(ls /cdrom | grep casper)
if [ -z "$control" ]
then echo -e "
*____________________Vous n'étes pas sur une live session !!!
FIN DU SCRIPT" ;sleep 2
exit 0
else
cd;
mkdir racine 2>/dev/null;
PARTITION=$(blkid|grep -i "ext4"|cut -c1-9)
SWAP=$(blkid|grep -i "swap"|cut -c1-9|grep "/dev/sd")
if [ -z "$PARTITION" ]
then
echo -e "
*____________________IL N Y A PAS DE PARTITION EXT4
*____________________FIN DU SCRIPT"
exit 0
else
if [ -z "$SWAP" ]
then
echo -e "
*____________________IL N Y A PAS DE PARTITION DE SWAP
*____________________FIN DU SCRIPT
"
exit 0
else
echo -e "
*____________________VOICI LES PARTITIONS TROUVÉS :
Partitions :
"$PARTITION"
Swap :
$SWAP
===============================================================================
"
echo -e "
*___________________SUR QUELLE PARTITION SOUHAITEZ VOUS INSTALLER UBUNTU ?
"
read -p "
*_______________________/dev/" PARTITION
echo -e "
===============================================================================
*___________________QUELLE PARTITION DE SWAP SOUHAITEZ VOUS UTILISER ?
"
read -p "
*_______________________/dev/" PARTITIONSWAP
uuid=$(tune2fs -l "/dev/$PARTITION" |grep -i uuid|cut -c27-100)
uuid2=$(blkid | grep -i "/dev/$PARTITIONSWAP" | grep -i swap | cut -c18-53)
echo -e "
===============================================================================
*___________________ENTREZ UN NOM D'UTLISATEUR"
read -p "
*_______________________Nom : " NAME
dev2=$(blkid | grep -i "/dev/sd"|cut -c1-8)
echo -e "
===============================================================================
*___________________SUR QUEL DISQUE SOUHAITEZ VOUS INSTALLER GRUB ?
"$dev2"
"
read -p "
*_______________________/dev/" mbr
clear ;
echo -e "
===============================================================================
* VOUS ETES SUR LE POINT D'INSTALLER UBUNTU
* NOM D UTILISATEUR : $NAME
* PARTITION : /dev/$PARTITION UUID="$uuid"
* SWAP : /dev/$PARTITIONSWAP UUID="$uuid2"
* GRUB sur : /dev/$mbr
===============================================================================
Entrée pour continuer
"
read p
mount "/dev/"$PARTITION racine;
echo "
===============================================================================
*___________________________MONTAGE DE /dev/$PARTITION";
sleep 3 ;
mount -t squashfs -o loop /cdrom/casper/filesystem.squashfs /mnt/;
echo "
===============================================================================
*___________________________LA COPIE DU SYSTÉME VA COMMENCER DANS 3 SECONDES";
sleep 3 ;
echo "
===============================================================================
*___________________________COPIE DU MBR DANS /opt/mbr.img";
sleep 3 ;
cp -av /mnt/. racine;
dd if=/dev/$mbr of=racine/opt/mbr.img bs=446 count=1
cat /etc/hosts | sed s/ubuntu/$NAME/ > racine/etc/hosts
cat /etc/"hostname" | sed s/ubuntu/$NAME/ > racine/etc/"hostname"
cp -av /cdrom/casper/initrd.lz racine/boot/initrd.img-2.6.32-21-generic;
cp -av /cdrom/casper/vmlinuz racine/boot/vmlinuz-2.6.32-21-generic;
umount /mnt;
mount --bind /dev/ racine/dev/;
mount --bind /proc racine/proc/;
mount --bind /sys/ racine/sys/;
echo "
#! /bin/bash
export HOME=/root
export LC_ALL=C
mkdir cdrom
echo '
================================================================================
*__________________________ SUPPRESSION D UBUQUITY'
sleep 2
aptitude remove -y ubiquity
echo ' # /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/$PARTITION during installation
UUID=$uuid / ext4 defaults,errors=remount-ro 0 1
# swap was on /dev/$PARTITIONSWAP during installation
UUID=$uuid2 none swap sw 0 0' >> etc/fstab
echo '
================================================================================
*___________________________CONFIGURATION DU CLAVIER'
sleep 2
dpkg-reconfigure console-setup
cp -a usr/lib/grub/i386-pc/* boot/grub/
echo '
================================================================================
*___________________________INSTALLATION DE GRUB '
sleep 2
grub-install /dev/$mbr
update-grub
echo '
================================================================================
*___________________________AJOUT DE L UTILISATEUR $NAME'
sleep 2
adduser $NAME
#nano etc/hosts
echo '
===============================================================================
*___________________________EDITION DE etc/sudoers :'
sleep 2
echo '
# /etc/sudoers
######
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
$NAME ALL=(ALL) ALL
# Allow members of group sudo to execute any command after they have
# provided their password
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d' > etc/sudoers
echo '
================================================================================
*___________________________ENTREZ UN MOT DE PASSE POUR ROOT :
'
passwd root
exit 0" > racine/bin/script-chroot.sh
chroot racine bash /bin/script-chroot.sh
rm racine/bin/script-chroot.sh
umount racine/dev
umount racine/proc
umount racine/sys
umount racine/
echo -e "
================================================================================
*_____________________________________SORTIE DU CHROOT
"
sleep 2
echo -e "
================================================================================
*_____________________________________INSTALLATION D'UBUNTU TERMINÉE
*_____________MERCI A BABDU69"
sleep 3
exit 0
fi
fi
fi
}
installation ;
exit 0
Dernière modification par Josepe36 (Le 08/09/2010, à 00:12)
Développeur distribution Hybryde
www.hybryde.org
Hors ligne
#2 Le 11/09/2010, à 00:21
- Babdu89
Re : installateur ubuntu alternatif
Bonjour a tous...
@ josepe36 .... Bonjour, je me répète...(voir nos mp) Babdu89 pas 69
Je ne t'en veux pas!!!! .... pour ce coup-ci
....
J'attends la suite.....les clé usb ça va chauffer!! ....
@+. Babdu69.... décidément 89 ....
J'ai découvert Ubuntu avec la 07.10.... Et alors?!... Depuis je regarde de temps en temps si Windows marche toujours....
Hors ligne