View previous topic :: View next topic |
Author |
Message |
kb3o n00b

Joined: 05 Jun 2006 Posts: 2
|
Posted: Mon Jun 05, 2006 4:57 pm Post subject: Gentoo Installer Script |
|
|
Hi there,
I've written this small bash script, which helps with installing Gentoo.
The main reason of existence of this script is to: get rid of boring work and commands. Not to make this installation automatic. Its up to you to choose the best choice, etc. ..Please test it, and send bugs, negative critic to mail or reply to this "add".
ps> Sorry for my english.
so,...
Code: |
# Patched on 06-07-2006
# 2006 Jakub Roman < jakub.roman(at)gmail.com >
C_RED='\E[31;40m';
C_GREEN='\E[32;40m';
C_YELLOW='\E[33;40m';
C_BLUE='\E[34;40m';
C_MAGENTA='\E[35;40m';
C_CYAN='\E[36;40m';
C_WHITE='\E[37;40m';
# Need to be added part with connecting to internet and downloading all the files and synchronizing portage tree
# Need to be added regognition of bz2 of gz archives
# Need to be added support for more disk partitions such as /var on /dev/hda3, /tmp on /dev/hda6 and /home on /dev/hdb
cecho ()
{
local DEFAULT_MSG="No message passed.";
message=${1:-$DEFAULT_MSG};
color=${2:-$C_WHITE};
echo -e "$color" "$message";
tput sgr0;
return
}
echo "Gentoo Linux Installation System ";
echo "2006 Jakub Roman < jakub.roman(at)gmail.com >"
echo;
LINUX_DISK="/dev/hda";
cecho " >> LINUX HardDisk & Partitions Settings" $C_GREEN
echo ") Which one would you like to use?"
echo " (default is $LINUX_DISK): "
read pom0;
if [ "$pom0" ]
then
LINUX_DISK=$pom0
fi
cecho "@@ Now make all slices with fdisk." $C_CYAN
fdisk /dev/hda;
BOOT_PART="$LINUX_DISK"1;
SWAP_PART="$LINUX_DISK"5;
ROOT_PART="$LINUX_DISK"6;
echo ") Which partition would you like to use as Boot Partition?"
echo " (default is $BOOT_PART): "
read pom0;
if [ "$pom0" ]
then
BOOT_PART=$pom0
fi
echo ") Which partition would you like to use as Swap Partition?"
echo " (default is $SWAP_PART): "
read pom0;
if [ "$pom0" ]
then
SWAP_PART=$pom0
fi
echo ") Which partition would you like to use as Root Partition?"
echo " (default is $ROOT_PART): "
read pom0;
if [ "$pom0" ]
then
ROOT_PART=$pom0
fi
new_boot_part="no";
cecho " >> BOOT Partition & Filesystem" $C_GREEN
echo " ) Would you like to format Boot Partition?";
echo " (default is no): ";
read new_boot_part;
if [ "$new_boot_part" = yes ]
then
echo ") Which filesystem would you like to use with Boot Partition?"
echo "@@ Available are -->"
echo " ext2, ext3, ReiserFS, JFS, XFS"
echo " (default is ext3): "
read pom0;
if [ "$pom0" = reiserfs ]
then
cecho "++ReiserFS was choosed." $C_MAGENTA
mkreiserfs -v $BOOT_PART;
else if [ "$pom0" = xfs ]
then
cecho "++XFS was choosed." $C_MAGENTA
mkfs.xfs -v $BOOT_PART;
else if [ "$pom0" = jfs ]
then
cecho "++JFS was choosed." $C_MAGENTA
mkfs.jfs -v $BOOT_PART;
else if [ "$pom0" = ext2 ]
then
cecho "++ext2 was choosed." $C_MAGENTA
mke2fs -v $BOOT_PART;
else
cecho "++ext3 was choosed." $C_MAGENTA
mke2fs -jv $BOOT_PART;
fi
fi
fi
fi
fi
cecho " >> SWAP Partition & Swapping" $C_GREEN
mkswap $SWAP_PART && swapon -v $SWAP_PART;
cecho " >> ROOT Partition & Filesystem" $C_GREEN
echo ") Which filesystem would you like to use with Root Partition?"
echo "@@ Available are -->"
echo " ext2, ext3, ReiserFS, JFS, XFS"
echo " (default is ext3): "
read pom0;
if [ "$pom0" = reiserfs ]
then
cecho "++ReiserFS was choosed." $C_MAGENTA
mkreiserfs -v $ROOT_PART;
else if [ "$pom0" = xfs ]
then
cecho "++XFS was choosed." $C_MAGENTA
mkfs.xfs -v $ROOT_PART;
else if [ "$pom0" = jfs ]
then
cecho "++JFS was choosed." $C_MAGENTA
mkfs.jfs -v $ROOT_PART;
else if [ "$pom0" = ext2 ]
then
cecho "++ext2 was choosed." $C_MAGENTA
mke2fs -v $ROOT_PART;
else
cecho "++ext3 was choosed." $C_MAGENTA
mke2fs -jv $ROOT_PART;
fi
fi
fi
fi
ROOT_MOUNTPOINT_NOTCHROOT="/mnt/gentoo";
BOOT_MOUNTPOINT_NOTCHROOT="/mnt/gentoo/boot";
BOOT_MOUNTPOINT="/boot";
cecho " >> MOUNTING Root & Boot Partitions" $C_GREEN
mount -v $ROOT_PART $ROOT_MOUNTPOINT_NOTCHROOT;
mkdir -v $BOOT_MOUNTPOINT_NOTCHROOT;
mount -v $BOOT_PART $BOOT_MOUNTPOINT_NOTCHROOT;
cecho " >> STAGE Tarballs & PORTAGE Snapshots & DISTFILES" $C_GREEN
STAGES_LOC="/mnt/cdrom/stages";
SNAPSHOTS_LOC="/mnt/cdrom/snapshots";
KERNEL_DISTFILES_LOC="/mnt/cdrom/distfiles";
GRUB_DISTFILES_LOC="/mnt/cdrom/distfiles";
KERNEL_SOURCES_LOC="/usr/src/linux";
echo ") Your location with Stage Tarballs?"
echo " (default is $STAGES_LOC): "
read pom0;
if [ "$pom0" ]
then
STAGES_LOC=$pom0
fi
echo ") Your location with Portage Snapshots?"
echo " (default is $SNAPSHOTS_LOC): "
read pom0;
if [ "$pom0" ]
then
SNAPSHOTS_LOC=$pom0
fi
echo ") Your location with Kernel Sources distfiles?"
echo " (default is $KERNEL_DISTFILES_LOC): "
read pom0;
if [ "$pom0" ]
then
KERNEL_DISTFILES_LOC=$pom0
fi
if [ "$new_boot_part" = yes ]
then
echo ") Your location with GRUB Sources distfiles?"
echo " (default is $GRUB_DISTFILES_LOC): "
read pom0;
if [ "$pom0" ]
then
GRUB_DISTFILES_LOC=$pom0
fi
fi
cecho " >> ARCHITECTURE & PORTAGE Install" $C_GREEN
STAGE_ARCH="amd64";
KERNEL_ARCH="x86_64";
PORTAGE_INSTALL_DIR="$ROOT_MOUNTPOINT_NOTCHROOT/usr";
PORTAGE_DATE="20060123"
echo ") Your Stage3 architecture?"
echo " (default is $STAGE_ARCH): "
read pom0;
if [ "$pom0" ]
then
STAGE_ARCH=$pom0
fi
echo ") Your Kernel Sources architecture?"
echo " (default is $KERNEL_ARCH): "
read pom0;
if [ "$pom0" ]
then
KERNEL_ARCH=$pom0
fi
echo ") Where to extract Portage Snapshot?"
echo " (default is $PORTAGE_INSTALL_DIR): "
read pom0;
if [ "$pom0" ]
then
PORTAGE_INSTALL_DIR=$pom0
fi
echo "@@ Available Portage Snapshots in $SNAPSHOTS_LOC -->"
ls $SNAPSHOTS_LOC;
echo ") Date of your Portage Snapshot? "
echo " (default is $PORTAGE_DATE): "
read pom0;
if [ "$pom0" ]
then
PORTAGE_DATE=$pom0
fi
cecho " Hold on now. Please don't Ctrl-C this, even if it take more minutes." $C_YELLOW;
cecho " Performing installation of Stage & Portage..." $C_YELLOW;
cecho " The list of currently processing files is not displayed, because it is slowing down the installation." $C_YELLOW;
cecho " Make some drink now. " $C_YELLOW;
cecho " >> EXTRACTING Stage Tarball" $C_GREEN
tar xjpf $STAGES_LOC/stage3-$STAGE_ARCH-2006.0.tar.bz2 -C $ROOT_MOUNTPOINT_NOTCHROOT;
cecho " >> EXTRACTING Portage Snapshot" $C_GREEN
tar xjf $SNAPSHOTS_LOC/portage-$PORTAGE_DATE.tar.bz2 -C $PORTAGE_INSTALL_DIR;
cecho " >> COPYING Needed Configuration Files: resolv.conf" $C_GREEN
cp -Lv /etc/resolv.conf $ROOT_MOUNTPOINT_NOTCHROOT/etc/resolv.conf;
cecho " >> MOUNTING Proc & Dev" $C_GREEN
mount -t proc none $ROOT_MOUNTPOINT_NOTCHROOT/proc;
mount -o bind /dev $ROOT_MOUNTPOINT_NOTCHROOT/dev;
cecho " >> CHROOTING Into The New Environment" $C_GREEN
chroot $ROOT_MOUNTPOINT_NOTCHROOT /bin/bash -i -c "env-update; source /etc/profile;"
echo " ) Chrooted.";
cecho " >> SELECTING THE RIGHT: TIMEZONE & KERNEL Sources" $C_GREEN
TIMEZONE="Europe/Bratislava";
KERNEL_SOURCES_NAME="linux-2.6.15";
PORTAGE_DATE="20060123";
echo "@@ Available Timezones in /usr/share/zoneinfo -->"
ls -RC /usr/share/zoneinfo | more;
echo "Your Local Timezone?"
echo " (default is $TIMEZONE): "
read pom0;
if [ "$pom0" ]
then
TIMEZONE=$pom0
fi
echo "@@ Available Kernel Sources in $KERNEL_DISTFILES_LOC (Maybe there can appear other files, that are not kernel sources. Its up to you to choose the correct one) -->"
cd $KERNEL_DISTFILES_LOC;
ls *linux*
echo "Which file of Kernel Sources do you want? "
echo " (default is $KERNEL_SOURCES_NAME): "
read pom0;
if [ "$pom0" ]
then
KERNEL_SOURCES_NAME=$pom0
fi
cecho " >> SETTING The Timezone" $C_GREEN
cp -v /usr/share/zoneinfo/$TIMEZONE /etc/localtime;
cecho " >> EXTRACTING Kernel Sources" $C_GREEN
tar xvjf $KERNEL_DISTFILES_LOC/$KERNEL_SOURCES_NAME.tar.bz2 -C /usr/src/;
cd /usr/src;
cecho " >> CREATING Symlink to Kernel Sources in /usr/src/" $C_GREEN;
ln -svfn linux-$KERNEL_SOURCES_NAME linux;
if [ "$new_boot_part" != yes ]
then
cecho " >> COPYING Needed Configuration Files: Kernel Configuration File *.config" $C_GREEN
cecho "Do you want to copy your .config file, which include settings of the kernel from $BOOT_MOUNTPOINT to $KERNEL_SOURCES_LOC ?"
echo " (default is yes): "
read pom0;
if [ "$pom0" != no ]
then
cd $BOOT_MOUNTPOINT;
echo "@@ Available .config files -->"
ls *.config;
$KERNEL_CONFIG_FILE="gentoo-linux-2.6.15.config";
echo "Which file you want? "
echo " (default is gentoo-linux-2.6.15.config)"
read $KERNEL_CONFIG_FILE;
cp -v $BOOT_MOUNTPOINT/$KERNEL_CONFIG_FILE $KERNEL_SOURCES_LOC;
fi
fi
cd $KERNEL_SOURCES_LOC;
cecho " >> NOW It is going to make menuconfig. You must load MANUALLY your settings from .config file." $C_YELLOW
make menuconfig;
# You must load manually your settings from .config file ---------NEED TO BE REWRITTEN
cecho " >> COMPILING Kernel Sources & Modules" $C_GREEN
make && make modules_install;
cecho " >> COPYING Kernel Sources & .config File To Boot Partition" $C_GREEN
cp -v arch/$KERNEL_ARCH/boot/bzImage $BOOT_MOUNTPOINT/gentoo-$KERNEL_SOURCES_NAME;
cp -v gentoo-$KERNEL_SOURCES_NAME.config $BOOT_MOUNTPOINT;
cd /;
cecho " >> IMPORTANT CONFIGURATIONS" $C_GREEN
nano -w /etc/fstab;
cecho " >> NET Configuration" $C_GREEN
IP_ADDRESS="192.168.0.1";
NET_MASK="255.255.255.0";
GATEWAY="192.168.0.1";
DNS_SRVR="192.168.0.1";
HOSTNAME="j0pc";
DOMAINNAME="j0pc";
echo ") Your HostName"
echo " (default is $HOSTNAME): "
read pom0;
if [ "$pom0" ]
then
HOSTNAME=$pom0
fi
echo ") Your DNS Domain"
echo " (default is $DOMAINNAME, type 0 if you are not included in domain): "
read pom0;
is_domain="0";
if [ "$pom0" ]
then
if [ "$pom0" != 0 ]
then
DOMAINNAME=$pom0;
is_domain="1";
fi
fi
echo ") Your IP Address"
echo " (default is $IP_ADDRESS): "
read pom0;
if [ "$pom0" ]
then
IP_ADDRESS=$pom0
fi
echo ") Your NetMask"
echo " (default is $NET_MASK): "
read pom0;
if [ "$pom0" ]
then
NET_MASK=$pom0
fi
echo ") Your Default GateWay"
echo " (default is $GATEWAY, type 0 if you don't use any gateway): "
read pom0;
is_gateway=0;
if [ "$pom0" ]
then
if [ "$pom0" != 0 ]
then
GATEWAY=$pom0;
is_gateway=1;
fi
fi
echo ") Your DNS Server"
echo " (default is $DNS_SRVR, type 0 if you have't any DNS server in your network): "
read pom0;
is_dns=0;
if [ "$pom0" ]
then
if [ "$pom0" != 0 ]
then
DNS_SRVR=$pom0;
is_dns=1;
fi
fi
echo "config_eth0=(\"$IP_ADDRESS netmask $NET_MASK\")" >> /etc/conf.d/net;
if [ "$is_gateway" = 1 ]
then
echo "routes_eth0=(\"default gw $GATEWAY\")" >> /etc/conf.d/net;
fi
if [ "$is_dns" = 1 ]
then
echo "nameserver $DNS_SRVR" >> /etc/resolv.conf;
fi
echo "HOSTNAME=\"$HOSTNAME\"" >> /etc/conf.d/hostname;
if [ "$is_domain" = 1 ]
then
echo "DNSDOMAIN=\"$DOMAINNAME\"" >> /etc/conf.d/domainname;
fi
if [ "$new_boot_part" = yes ]
then
GRUB_SOURCES_NAME="grub-0.96"
cecho " >> GRand Unified Bootloader (GRUB) Installation" $C_GREEN
cd $GRUB_DISTFILES_LOC;
ls *grub*
echo "Which fil of GRUB do you want? "
echo " (default is $GRUB_SOURCES_NAME): "
read pom0;
if [ "$pom0" ]
then
GRUB_SOURCES_NAME=$pom0
fi
tar xvf $GRUB_DISTFILES_LOC/$GRUB_SOURCES_NAME.tar.gz -C /root
echo "@@ Available GRUB Sources in $KERNEL_DISTFILES_LOC -->"
cd /root/$GRUB_SOURCES_NAME
.configure
make && make check && make install
cd
echo "default 0" >> /boot/grub/grub.conf
echo "timeout 4" >> /boot/grub/grub.conf
echo "title=Gentoo $KERNEL_SOURCES_NAME located on $ROOT_PART" >> /boot/grub/grub.conf
# NEED TO BE REWRITEN BECAUSE OF (hd0,0) (hd0,2) etc
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
echo "root (hd0,0)" >> /boot/grub/grub.conf
echo "kernel /boot/gentoo-$KERNEL_SOURCES_NAME" >> /boot/grub/grub.conf
else
cecho " >> GRand Unified Bootloader (GRUB) Configuration" $C_GREEN
# NEED TO BE REWRITEN BECAUSE OF (hd0,0) (hd0,2) etc
echo "title=Gentoo $KERNEL_SOURCES_NAME located on $ROOT_PART" >> /boot/grub/grub.conf
echo "root (hd0,0)" >> /boot/grub/grub.conf
echo "kernel /boot/gentoo-$KERNEL_SOURCES_NAME" >> /boot/grub/grub.conf
grep -v rootfs /proc/mounts > /etc/mtab;
grub-install $LINUX_DISK;
rm -rf /root/$GRUB_SOURCES_NAME
fi
cecho " >> UNMOUNTIG & REBOOTING" $C_GREEN
exit
cd
umount $BOOT_MOUNTPOINT_NOTCHROOT $ROOT_MOUNTPOINT_NOTCHROOT/dev $ROOT_MOUNTPOINT_NOTCHROOT/proc $ROOT_MOUNTPOINT_NOTCHROOT
reboot
|
_________________ Jakub Roman.
Last edited by kb3o on Wed Jun 07, 2006 4:55 pm; edited 4 times in total |
|
Back to top |
|
 |
Chaosite Guru


Joined: 13 Dec 2003 Posts: 540 Location: Right over here.
|
Posted: Mon Jun 05, 2006 5:09 pm Post subject: |
|
|
Please use [code] blocks.
Better yet, find some hosting =)
Its not really small... =/ |
|
Back to top |
|
 |
kb3o n00b

Joined: 05 Jun 2006 Posts: 2
|
Posted: Wed Jun 07, 2006 5:22 pm Post subject: |
|
|
Hosting? Do you mean to make some web page with my projectsm including this installer script, etc? _________________ Jakub Roman. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|