Find the answer to your Linux question:
Results 1 to 5 of 5
So i just decided to write this a few months ago, took about 5 minutes or so to do....Just like to know what you guys think... Code: #!/bin/bash # GENTOO ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3

    Install Script [Gentoo-Stage 3-Base]


    So i just decided to write this a few months ago, took about 5 minutes or so to do....Just like to know what you guys think...

    Code:
    #!/bin/bash
    # GENTOO INSTALL SCRIPT FROM BASE INSTALL AND DEFAULT CONFIGS
    # Created by: Morpheus (YYC)
    #
    
    # Display Introduction
    echo "Welcome to the GENTOO install script, please note you must be at your system for instructions"
    echo "this script will perform a majority of the configurations for you however certain interaction"
    echo "may be required on your part."
    echo
    echo
    echo "NOTE: THIS WILL RESULT IN DATA LOSS OF THE CURRENT DRIVE"
    echo "Please press enter when your ready to continue."
    read
    
    # Configure hard disk
    echo "The following is a list of found Hard Disk devices (sda/hda):"
    ls /dev/ | grep -E [s:h]da$
    echo
    echo "Please enter the device you would like to install to:"
    read HD_DEVICE
    HDD="/dev/${HD_DEVICE}"
    
    # warn user last time
    echo
    echo "THIS IS YOUR LAST CHANCE TO CANCEL, Press CTRL+C to cancel this install or ENTER to continue"
    read
    echo "p" | fdisk $HDD
    echo "Please specifiy the total number of partitions:"
    read PARTS
    
    #TODO: add integer checking
    echo -n "Generating fdisk operation file"
     # Create fdisc auto file
    ((i = 1))
    while (( i < PARTS ))
    do
    echo "d" >> fdisc.in
    echo "$i" >> fdisc.in
    ((i += 1))
    done
    echo "d" 	>> fdisc.in	# Delete last sector
    echo "n" 	>> fdisc.in	# New Partiton
    echo "p" 	>> fdisc.in	# Primary
    echo "1" 	>> fdisc.in	# Partion 1
    echo "" 	>> fdisc.in	# default
    echo "+32M" 	>> fdisc.in	# 32 MB size
    echo "a" 	>> fdisc.in	# Set flag
    echo "1" 	>> fdisc.in	# bootable
    echo -n "."
    echo "n" 	>> fdisc.in	# New Partion
    echo "p" 	>> fdisc.in	# Primary
    echo "2" 	>> fdisc.in	# Partion 2
    echo "" 	>> fdisc.in	# default
    echo "+512M" 	>> fdisc.in	# 512 MB size
    echo "t" 	>> fdisc.in	# Set partition type
    echo "2" 	>> fdisc.in	# Partition 2
    echo "82" 	>> fdisc.in	# 82 = SWAP
    echo -n "."
    echo "n" 	>> fdisc.in	# New Partition
    echo "p" 	>> fdisc.in	# Primary
    echo "3" 	>> fdisc.in	# Partition 2
    echo "" 	>> fdisc.in	# default
    echo "" 	>> fdisc.in	# new Line
    echo -n "."
    echo "w" 	>> fdisc.in	# Write partion table
    echo "q" 	>> fdisc.in	# Quit
    echo ". Done"
    # Execute file
    echo "Executing fdisk script ..."
    echo
    fdisk $HDD < fdisc.in
    #clean up
    rm -f fdisc.in
    echo ""
    echo "Partions created"
    echo "Applying filesystem to partitions"
    mke2fs /dev/${HD_DEVICE}1
    mke2fs -j /dev/${HD_DEVICE}3
    mkswap /dev/${HD_DEVICE}2
    echo "Activating swap partition"
    swapon /dev/${HD_DEVICE}2
    echo ""
    echo "Mounting partitions"
    mount /dev/${HD_DEVICE}3 /mnt/gentoo
    mkdir /mnt/gentoo/boot
    mount /dev/${HD_DEVICE}1 /mnt/gentoo/boot
    echo "Starting STAGE 3 Install"
    echo ""
    cd /mnt/gentoo
    wget http://gentoo.osuosl.org/releases/x86/current/stages/stage3-x86-2006.1.tar.bz2
    tar xvjpf stage3-*.tar.bz2
    echo ""
    echo "Installing portage..."
    cd /mnt/gentoo
    wget http://gentoo.osuosl.org/snapshots/portage-latest.tar.bz2
    tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr
    echo "Cleaning up..."
    rm -f portage-latest.tar.bz2
    rm -f stage3-x86-2006.1.tar.bz2
    echo ""
    echo "Getting ready to CHROOT"
    cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
    mount -t proc none /mnt/gentoo/proc
    mount -o bind /dev /mnt/gentoo/dev
    echo "Chrooted"
    echo "Updating portage..."
    sleep 2
    chroot /mnt/gentoo emerge --sync
    echo "Patching portage..."
    chroot /mnt/gentoo emerge portage
    echo "Portage updated, downloading kernel source..."
    sleep 2
    
    echo "#!/bin/bash" > /mnt/gentoo/portage
    echo 'USE="-doc symlink" emerge gentoo-sources' >> /mnt/gentoo/portage
    chmod 700 /mnt/gentoo/portage
    chroot /mnt/gentoo ./portage
    rm -f /mtn/gentoo/portage
    
    echo "#!/bin/bash" > /mnt/gentoo/portage
    echo 'cd /usr/src/linux' >> /mnt/gentoo/portage
    echo 'echo ""' >> /mnt/gentoo/portage
    echo 'echo "***************************************************"' >> /mnt/gentoo/portage
    echo 'echo "**            KERNEL CONFIGURATION               **"' >> /mnt/gentoo/portage
    echo 'echo "***************************************************"' >> /mnt/gentoo/portage
    echo 'echo "* You will now be prompted with the linux kernel  *"' >> /mnt/gentoo/portage
    echo 'echo "*menu configurator, please ensure that you specify*"' >> /mnt/gentoo/portage
    echo 'echo "*the right settings, as once you exit this script *"' >> /mnt/gentoo/portage
    echo 'echo "*will compile and install the new kernel          *"' >> /mnt/gentoo/portage
    echo 'echo "***************************************************"' >> /mnt/gentoo/portage
    echo 'echo ""' >> /mnt/gentoo/portage
    echo 'echo "Please press enter to continue"' >> /mnt/gentoo/portage
    echo 'read' >> /mnt/gentoo/portage
    echo 'make menuconfig' >> /mnt/gentoo/portage
    echo 'make && make modules_install' >> /mnt/gentoo/portage
    echo 'cp arch/i386/boot/bzImage /boot/originalKernel' >> /mnt/gentoo/portage
    echo 'echo ""' >> /mnt/gentoo/portage
    chmod 700 /mnt/gentoo/portage
    chroot /mnt/gentoo ./portage
    rm -f /mtn/gentoo/portage
    
    echo "Generating FSTAB"
    #GENERATE FSTAB
    echo "# /etc/fstab: static file system information." > /mnt/gentoo/etc/fstab
    echo "#" >> /mnt/gentoo/etc/fstab
    echo "# noatime turns off atimes for increased performance (atimes normally aren't" >> /mnt/gentoo/etc/fstab
    echo "# needed; notail increases performance of ReiserFS (at the expense of storage" >> /mnt/gentoo/etc/fstab
    echo "# efficiency).  It's safe to drop the noatime options if you want and to" >> /mnt/gentoo/etc/fstab
    echo "# switch between notail / tail freely." >> /mnt/gentoo/etc/fstab
    echo "#" >> /mnt/gentoo/etc/fstab
    echo "# The root filesystem should have a pass number of either 0 or 1." >> /mnt/gentoo/etc/fstab
    echo "# All other filesystems should have a pass number of 0 or greater than 1." >> /mnt/gentoo/etc/fstab
    echo "#" >> /mnt/gentoo/etc/fstab
    echo "# See the manpage fstab(5) for more information." >> /mnt/gentoo/etc/fstab
    echo "#" >> /mnt/gentoo/etc/fstab
    echo "" >> /mnt/gentoo/etc/fstab
    echo "# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>" >> /mnt/gentoo/etc/fstab
    echo "" >> /mnt/gentoo/etc/fstab
    echo "# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts." >> /mnt/gentoo/etc/fstab
    echo "/dev/${HD_DEVICE}1               /boot           ext2            noauto,noatime  1 2" >> /mnt/gentoo/etc/fstab
    echo "/dev/${HD_DEVICE}3               /               ext3            noatime         0 1" >> /mnt/gentoo/etc/fstab
    echo "/dev/${HD_DEVICE}2               none            swap            sw              0 0" >> /mnt/gentoo/etc/fstab
    echo "#/dev/cdroms/cdrom0      /mnt/cdrom      iso9660         noauto,ro       0 0" >> /mnt/gentoo/etc/fstab
    echo "#/dev/fd0               /mnt/floppy     auto            noauto          0 0" >> /mnt/gentoo/etc/fstab
    echo "" >> /mnt/gentoo/etc/fstab
    echo "# NOTE: The next line is critical for boot!" >> /mnt/gentoo/etc/fstab
    echo "proc                    /proc           proc            defaults        0 0" >> /mnt/gentoo/etc/fstab
    echo "" >> /mnt/gentoo/etc/fstab
    echo "# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for" >> /mnt/gentoo/etc/fstab
    echo "# POSIX shared memory (shm_open, shm_unlink)." >> /mnt/gentoo/etc/fstab
    echo "# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will" >> /mnt/gentoo/etc/fstab
    echo "#  use almost no memory if not populated with files)" >> /mnt/gentoo/etc/fstab
    echo "shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0" >> /mnt/gentoo/etc/fstab
    cat /mnt/gentoo/etc/fstab
    echo ""
    echo "Configuring rc scripts"
    chroot /mnt/gentoo rc-update add net.eth0 default
    chroot /mnt/gentoo rc-update add sshd default
    echo "*************** ROOT PASSWORD ********************"
    echo "YOU ARE NOW REQUIRED TO ENTER A NEW ROOT PASSWORD "
    echo "**************************************************"
    chroot /mnt/gentoo passwd
    echo "Installing tools..."
    chroot /mnt/gentoo emerge syslog-ng vixie-cron slocate dhcpcd
    chroot /mnt/gentoo rc-update add syslog-ng default
    chroot /mnt/gentoo rc-update add vixie-cron
    echo ""
    echo ""
    echo "Installing LILO"
    chroot /mnt/gentoo emerge lilo
    echo "boot=/dev/${HD_DEVICE}       # Install LILO in the MBR" >> /mnt/gentoo/etc/lilo.conf
    echo "prompt                    # Give the user the chance to select another section" >> /mnt/gentoo/etc/lilo.conf
    echo "timeout=50                # Wait 5 (five) seconds before booting the default section" >> /mnt/gentoo/etc/lilo.conf
    echo "default=gentoo            # When the timeout has passed, boot the "gentoo" section" >> /mnt/gentoo/etc/lilo.conf
    echo "" >> /mnt/gentoo/etc/lilo.conf
    echo "# For non-genkernel users" >> /mnt/gentoo/etc/lilo.conf
    echo "image=/boot/originalKernel" >> /mnt/gentoo/etc/lilo.conf
    echo "        label=gentoo            # Name we give to this section" >> /mnt/gentoo/etc/lilo.conf
    echo "        read-only               # Start with a read-only root. Do not alter!" >> /mnt/gentoo/etc/lilo.conf
    echo "        root=/dev/${HD_DEVICE}3          # Location of the root filesystem" >> /mnt/gentoo/etc/lilo.conf
    chroot /mnt/gentoo lilo
    cd /
    umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo
    echo "Done"
    echo "****************************"
    echo "****************************"
    echo "** SYSTEM WILL NOW REBOOT **"
    echo "****************************"
    echo "****************************"
    sleep 5
    reboot

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    I think you type pretty fast if you did that in five minutes.

  3. #3
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3
    Quote Originally Posted by likwid
    I think you type pretty fast if you did that in five minutes.
    arround 80-90 WPM

  4. #4
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    That's about the speed I type, anyways, x86 gentoo is still using lilo? I only use gentoo on my Sun workstation, so it uses silo, but I figured they'd have hopped on the grub bandwagon for x86 by now.

  5. #5
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3
    Quote Originally Posted by likwid
    That's about the speed I type, anyways, x86 gentoo is still using lilo? I only use gentoo on my Sun workstation, so it uses silo, but I figured they'd have hopped on the grub bandwagon for x86 by now.
    Well its more of a personal prefrence thing mainly, both grub and lilo are recomended so its really up to the user.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •