#!/bin/bash # Copyright info will go here eventually # #February 11th 2010 INSTALL="1.34" VERSION="0.7.1" StartInstall(){ echo "| |" echo "| Which installation method do you wish to use? 1/2 |" echo "|______________________________________________________________________________|" echo read -n1 p1_quickcompile case $p1_quickcompile in 1) clear Quick ;; 2) clear Compile ;; *) clear echo "| Response not understood, please type '1' or '2' |" StartInstall ;; esac } StartQuick(){ echo "| |" echo "| Do you wish to proceed with the installation of FLY? y/n |" echo "|______________________________________________________________________________|" echo read -n1 q_p1_yn case $q_p1_yn in y) clear ;; n) exit ;; *) clear echo "| Response not understood, please type 'y' or 'n' |" StartQuick ;; esac } StartCompile(){ echo "| |" echo "| Do you wish to proceed with the installation of FLY? y/n |" echo "|______________________________________________________________________________|" echo read -n1 c_p1_yn case $c_p1_yn in y) clear ;; n) exit ;; *) clear echo "| Response not understood, please type 'y' or 'n' |" StartCompile ;; esac } AutoInteractiveManual(){ echo "Please choose:" echo " 1) Automatic -- deletes partition data" echo " 2) Interactive -- deletes partition data" echo " 3) Manual (experts only) -- preserves partition data" read -n1 p2_part clear case $p2_part in 1) echo "All partitions on "$p2_hdd" will be deleted." echo "ALL DATA ON THE DRIVE WILL BE LOST." echo "Press 'c' to continue, any other key to quit." read -n1 del_q if [ "${del_q}" != "c" ]; then echo "Exiting ..." sleep 1 exit fi echo echo "Deleting all partitions on target device ..." sleep 1 dd if=/dev/zero of=$p2_hdd count=1 bs=512 > /dev/null 2>&1 echo "Creating partitions ..." echo -e "n\np\n1\n\n+16M\na\n1\nn\np\n2\n\n+512M\nt\n2\n82\nn\np\n3\n\n\nw\nq\n" | fdisk $p2_hdd > /dev/null 2>&1 echo "Creating swap space ..." mkswap "$p2_hdd"2 > /dev/null 2>&1 echo "Formating "$p2_hdd"3 partition with ext3 file system ..." mke2fs -j "$p2_hdd"3 > /dev/null 2>&1 echo "Mounting "$p2_hdd"3 partition to /tmp/installer ..." mount "$p2_hdd"3 /tmp/installer echo "Making /boot directory ..." mkdir /tmp/installer/boot echo "Formating "$p2_hdd"1 partition with ext2 file system ..." mke2fs "$p2_hdd"1 > /dev/null 2>&1 echo "Mounting "$p2_hdd"1 partition to /tmp/installer/boot ..." mount "$p2_hdd"1 /tmp/installer/boot ;; 2) echo "All partitions on "$p2_hdd" will be deleted." echo "ALL DATA ON THE DRIVE WILL BE LOST." echo "Press 'c' to continue, any other key to quit." read -n1 del_q if [ "${del_q}" != "c" ]; then echo "Exiting ..." sleep 1 exit fi echo "Deleting all partitions on target device ..." sleep 1 dd if=/dev/zero of=$p2_hdd count=1 bs=512 > /dev/null 2>&1 echo "The installer will create three partitions on the device:" echo " 1) A /boot partition" echo " 2) A SWAP partition" echo " 3) A / (root) partition" echo echo "The /boot partition is recommended to be 16M (megabytes)" echo "How large do you wish to make the /boot partition?" echo -n " :" read p2_boot_size sleep 1 echo "The SWAP partition is used as additional RAM on your hard drive" echo "And (if applicable) as save space for system hibernation." echo "The recommended size for SWAP is 1.5 times your system RAM" echo "How large do you wish to make the SWAP partition?" echo -n " :" read p2_swap_size sleep 1 echo "The / (root) partition is where FLY will be installed. The minimum" echo "size for the / (root) partition should be 5G (gigabytes)." echo "If you do not plan on creating any other partitions, you should" echo "use the full remainder of the disk for this partition." echo "How large do you wish to make the / (root) partition?" echo "Leave blank to use the remainder of the disk" echo -n " :" read p2_root_size sleep 1 clear echo "Creating partitions ..." echo -e "n\np\n1\n\n+"$p2_boot_size"\na\n1\nn\np\n2\n\n+"$p2_swap_size"\nt\n2\n82\nn\np\n3\n\n+"$p2_root_size"\nw\nq\n" | fdisk $p2_hdd > /dev/null 2>&1 echo "Creating swap space ..." mkswap "$p2_hdd"2 > /dev/null 2>&1 echo "Formating "$p2_hdd"3 partition with ext3 file system ..." mke2fs -j "$p2_hdd"3 > /dev/null 2>&1 echo "Mounting "$p2_hdd"3 partition to /tmp/installer ..." mount "$p2_hdd"3 /tmp/installer echo "Making /boot directory ..." mkdir /tmp/installer/boot echo "Formating "$p2_hdd"1 partition with ext2 file system ..." mke2fs "$p2_hdd"1 > /dev/null 2>&1 echo "Mounting "$p2_hdd"1 partition to /tmp/installer/boot ..." mount "$p2_hdd"1 /tmp/installer/boot ;; 3) gparted $p2_hdd echo -n "Enter the SWAP partition for FLY: " read p2_swap echo "Creating swap space ..." mkswap p2_swap > /dev/null 2>&1 echo -n "Enter the root partition for FLY: " read p2_root echo "Formating $p2_root with ext3 file system ..." mke2fs -j $p2_root > /dev/null 2>&1 echo "Mounting $p2_root to /tmp/installer ..." mount $p2_root /tmp/installer echo -n "Enter the boot partition for FLY: " read p2_boot NewExisting ;; *) clear echo "Response not understood, please select '1' or '2'" InteractiveManual ;; esac } NewExisting(){ echo "Is this a new or existing /boot partition?" echo " 1) new" echo " 2) existing" read -n1 p2_boot_12 echo case $p2_boot_12 in 1) echo "Making /boot directory ..." mkdir /tmp/installer/boot echo "Formating $p2_boot with ext2 file system ..." mke2fs $p2_boot > /dev/null 2>&1 echo "Mounting $p2_boot to /tmp/installer/boot ..." mount $p2_boot /tmp/installer/boot ;; 2) echo "Mounting existing boot directory $p2_boot to /tmp/installer/boot ..." mount $p2_boot /tmp/installer/boot ;; *) clear echo "Response not understood, please select '1' or '2'" echo "You have selected $p2_boot as your boot partition." NewExisting ;; esac } TimeZoneSelection(){ clear echo " ______________________________________________________________________________" echo "| 3604 04|" echo "| SELECT YOUR TIMEZONE |" echo "|______________________________________________________________________________|" echo echo " Displaying the directory contents of /usr/share/zoneinfo ..." cd /usr/share/zoneinfo ls -d */ sleep 1 echo echo -n " Type in a directory to navigate to: " read TZSfile1 TZSwc1=`ls -1d $TZSfile1 2> /dev/null | wc | awk '{print $1}'` if [ "$TZSwc1" != "1" ];then echo " Invalid directory, restarting ..." sleep 1 TimeZoneSelection fi cd $TZSfile1 echo " Displaying the contents of $TZSfile1" sleep 1 ls echo echo " If you wish to choose a timezone here, enter it below." echo " If you wish to change directories, type 'restart'" echo -n " Select your desired timezone: " read TZSfile2 TZSwc2=`ls -1d $TZSfile2 2> /dev/null | wc | awk '{print $1}'` if [ "$TZSfile2" = "restart" ];then TimeZoneSelection elif [ "$TZSwc2" != "1" ];then echo " Invalid timezone, restarting ..." sleep 1 TimeZoneSelection fi echo " You have chosen to use the $TZSfile1/$TZSfile2 timezone" echo " Is this correct? y/n" read -n1 TZSyn echo case $TZSyn in y) ;; n) TimeZoneSelection ;; *) echo " Response not understood, restarting section ..." sleep 1 TimeZoneSelection ;; esac echo " Copying $TZSfile1/$TZSfile2 to /etc/localtime ..." cp $TZSfile2 /etc/localtime if [ "$?" != "0" ]; then echo " Copying failed. Restarting timezone selection ..." TimeZoneSelection fi } Quick(){ echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| Welcome to the QUICK install. This method of installation will run |" echo "| through the following phases: |" echo "| |" echo "| 1) Partitioning and formating your hard drive |" echo "| 2) Copying the contents of the LiveCD to your hard drive |" echo "| 3) Installing Grub to your hard drive's MBR |" echo "| |" echo "| This installation method is very quick and simple. No applications |" echo "| will be recompiled and therefore may not function as expected. |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" StartQuick echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| PARTITIONING AND FORMATING YOUR HARD DRIVE |" echo "| |" echo "| During this section of the installer, you will be asked several questions |" echo "| regarding your hard drive(s) and partitioning, this script assumes you |" echo "| have an understanding of Linux drive naming, and drive partitioning. |" echo "| |" echo "| The following steps will be taken: |" echo "| |" echo "| 1) Selecting the target hard drive for FLY installation |" echo "| 2a) Automatic partitioning of the target hard drive (quick) |" echo "| 2b) Interactive partitioning of the target hard drive |" echo "| 2c) Manual partitioning of the target hard drive (experts only) |" echo "| 3) Formating FLY partitions |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 clear qinstdir=`ls -1 /tmp/ | grep installer` if [ "$qinstdir" = "installer" ]; then echo "Previous installation directory found. Deleting ..." rm -rf /tmp/installer fi mkdir /tmp/installer echo "Displaying all detected hard drives:" echo fdisk -l | grep 'Disk.*hd\|Disk.*sd' echo echo -n "Enter target device: " read p2_hdd echo AutoInteractiveManual echo "Displaying new partition layout for $p2_hdd ..." echo "================================================================================" echo " Device Boot Start End Blocks Id System" fdisk $p2_hdd -l | grep -v Disk | grep $p2_hdd echo "--------------------------------------------------------------------------------" echo "Filesystem Size Used Avail Use% Mounted on" df -h 2> /dev/null | grep $p2_hdd echo "================================================================================" echo "Ready to copy data to hard disk. Press any key to continue ..." read -n1 echo echo "Copying contents of LiveCD to /tmp/installer ..." sleep 1 rsync -aqzdrhP --exclude={/proc/*,/sys/*,/dev/*,/tmp/installer,/mnt/*} / /tmp/installer/ echo "Copy complete ..." sleep 1 echo "Downloading extra data ..." wget -q http://linuxfly.net/data/installdata/installdata-$VERSION.tar.bz2 -O /tmp/installer/tmp/installdata.tar.bz2 if [ "$?" = "0" ]; then echo "Download completed successfully ..." else echo "Download FAILED. Did you check network connectivity?" echo "Check your settings and press any key to try again ..." read -n1 wget http://linuxfly.net/data/installdata/installdata-$VERSION.tar.bz2 -O /tmp/installer/tmp/installdata.tar.bz2 if [ "$?" = "0" ]; then echo "Download completed successfully ..." else echo "Download FAILED again." echo "Please post in the forums about this issue." echo "Installer aborting ..." sleep 1 echo "Unmounting partitions ..." umount /tmp/installer/boot umount /tmp/installer echo "Press any key to quit ..." read -n1 exit fi fi sleep 1 echo "Extracting tarball ..." mkdir -p /tmp/installer/{usr/lib/portage,etc/portage,usr/portage/profiles} tar xfp /tmp/installer/tmp/installdata.tar.bz2 -C /tmp/installer/ echo "Extraction complete ..." echo "Fixing menu ..." grep -v 360404 /home/fly/.fluxbox/menu > /tmp/installer/home/fly/.fluxbox/menu sleep 1 TimeZoneSelection sleep 1 echo "Mounting /dev, /sys and /proc ..." mount --bind /dev /tmp/installer/dev mount --bind /sys /tmp/installer/sys mount -t proc none /tmp/installer/proc echo "Ready to chroot to new install. Press any key to continue ..." read -n1 echo echo "Chrooting to new install ..." chroot /tmp/installer /root/.FLYinstaller/grub echo "Installation completed ..." sleep 1 echo "Press any key to continue ..." read -n1 clear echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| CONGRATULATIONS! FLY is installed on your computer |" echo "| |" echo "| The installer will now unmount the installation directories and close. |" echo "| Be aware that this installation did not configure any user accounts. |" echo "| The only account on this installation is the 'root' account with the |" echo "| password you set during this installation. |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 umount /tmp/installer/{boot,proc,dev,sys} umount /tmp/installer exit } Compile(){ echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| Welcome to the COMPILE install. This method of installation will run |" echo "| through the following phases: |" echo "| |" echo "| 1) Partitioning and formating your hard drive |" echo "| 2) Downloading extra FLY content for installation |" echo "| 3) Downloading the Portage tree and required distfiles |" echo "| 4) Configuring your new FLY environment |" echo "| 5) Configuring user accounts |" echo "| 6) Recompiling FLY with your new configurations |" echo "| |" echo "| The installation time will vary depending on hardware and selected options. |" echo "| Since FLY is based on Gentoo, which compiles mostly everything from source, |" echo "| the final phase of the installation can take several hours to complete. |" echo "| Your processor(s) will be working at 100% for the duration of phase 6, |" echo "| please ensure your computer is in a well ventilated area. |" echo "| |" StartCompile echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| PARTITIONING AND FORMATING YOUR HARD DRIVE |" echo "| |" echo "| During this section of the installer, you will be asked several questions |" echo "| regarding your hard drive(s) and partitioning, this script assumes you |" echo "| have an understanding of Linux drive naming, and drive partitioning. |" echo "| |" echo "| The following steps will be taken: |" echo "| |" echo "| 1) Selecting the target hard drive for FLY installation |" echo "| 2a) Automatic partitioning of the target hard drive (quick) |" echo "| 2b) Interactive partitioning of the target hard drive |" echo "| 2c) Manual partitioning of the target hard drive (experts only) |" echo "| 3) Formating FLY partitions |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 clear qinstdir=`ls -1 /tmp/ | grep installer` if [ "$qinstdir" = "installer" ]; then echo "Previous installation directory found. Deleting ..." rm -rf /tmp/installer fi mkdir /tmp/installer echo "Displaying all detected hard drives:" echo fdisk -l | grep 'Disk.*hd\|Disk.*sd' echo echo -n "Enter target device: " read p2_hdd echo AutoInteractiveManual echo "Displaying new partition layout for $p2_hdd ..." echo "================================================================================" echo " Device Boot Start End Blocks Id System" fdisk $p2_hdd -l | grep -v Disk | grep $p2_hdd echo "--------------------------------------------------------------------------------" echo "Filesystem Size Used Avail Use% Mounted on" df -h 2> /dev/null | grep $p2_hdd echo "================================================================================" echo "Ready to copy data to hard disk. Press any key to continue ..." read -n1 echo echo "Copying contents of LiveCD to /tmp/installer ..." sleep 1 rsync -aqzdrhP --exclude={/proc/*,/sys/*,/dev/*,/tmp/installer,/mnt/*} / /tmp/installer/ echo echo "Copy complete ..." sleep 1 echo "Downloading extra data ..." wget -q http://linuxfly.net/data/installdata/installdata-$VERSION.tar.bz2 -O /tmp/installer/tmp/installdata.tar.bz2 if [ "$?" = "0" ]; then echo "Download completed successfully ..." else echo "Download FAILED. Did you check network connectivity?" echo "Check your settings and press any key to try again ..." read -n1 wget http://linuxfly.net/data/installdata/installdata-$VERSION.tar.bz2 -O /tmp/installer/tmp/installdata.tar.bz2 if [ "$?" = "0" ]; then echo "Download completed successfully ..." else echo "Download FAILED again." echo "Please post in the forums about this issue." echo "Installer aborting ..." sleep 1 echo "Unmounting partitions ..." umount /tmp/installer/boot umount /tmp/installer echo "Press any key to quit ..." read -n1 exit fi fi echo "Extracting tarball ..." mkdir -p /tmp/installer/{usr/lib/portage,etc/portage,usr/portage/profiles} tar xfp /tmp/installer/tmp/installdata.tar.bz2 -C /tmp/installer/ echo "Extraction complete ..." echo "Fixing menu ..." grep -v 360404 /home/fly/.fluxbox/menu > /tmp/installer/home/fly/.fluxbox/menu sleep 1 TimeZoneSelection sleep 1 echo "Mounting /dev, /sys and /proc ..." mount --bind /dev /tmp/installer/dev mount --bind /sys /tmp/installer/sys mount -t proc none /tmp/installer/proc echo "Press any key to continue ..." read -n1 clear echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| DOWNLOADING THE PORTAGE TREE |" echo "| |" echo "| This step requires no user interaction. The installer will chroot to your |" echo "| FLY installation, download a Portage snapshot, and sync the tree with |" echo "| Gentoo servers. |" echo "| |" echo "| While this step is underway, the installer will move onto the next step |" echo "| so you may configure your new FLY environment without having to wait for |" echo "| the Portage to finish downloading. |" echo "| |" echo "| If you complete the configurations before Portage is updated, the installer |" echo "| will pause and wait for this task to finish before proceeding to the final |" echo "| phase of the installation process. |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 xterm -bg black -fg white -e "chroot /tmp/installer /root/.FLYinstaller/portage" & clear echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| CONFIGURING YOUR NEW FLY ENVIRONMENT |" echo "| |" echo "| During this step, you will be prompted to configure several config files |" echo "| essential to the proper functioning of FLY and the Gentoo base on your |" echo "| hardware. |" echo "| |" echo "| The following files will be configured: |" echo "| |" echo "| 1) /etc/make.conf 6) /etc/portage/package.keywords |" echo "| 2) /etc/fstab 7) /etc/portage/package.unmask |" echo "| 3) /etc/conf.d/hostname 8) /etc/portage/package.use |" echo "| 4) /boot/grub/menu.lst |" echo "| 5) /etc/kismet.conf |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 clear cp /proc/config.gz /tmp/installer/tmp/ echo "Editing /etc/make.conf ..." sleep 1 nano /tmp/installer/etc/make.conf echo "Editing /etc/fstab ..." sleep 1 nano /tmp/installer/etc/fstab echo "Editing /etc/conf.d/hostname ..." sleep 1 nano /tmp/installer/etc/conf.d/hostname echo "Editing /boot/grub/menu.lst ..." sleep 1 nano /tmp/installer/boot/grub/menu.lst echo "Editing /etc/kismet.conf ..." sleep 1 nano /tmp/installer/etc/kismet.conf echo "Editing /etc/portage/package.keywords ..." sleep 1 nano /tmp/installer/etc/portage/package.keywords echo "Editing /etc/portage/package.unmask ..." sleep 1 nano /tmp/installer/etc/portage/package.unmask echo "Editing /etc/portage/package.use ..." sleep 1 nano /tmp/installer/etc/portage/package.use clear echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| RECOMPILING FLY WITH YOUR NEW CONFIGURATIONS |" echo "| |" echo "| This is the final step in the installer. All of the FLY packages will be |" echo "| recompiled so that FLY may take full advantage of your hardware. |" echo "| |" echo "| This process will open in a new terminal window with verbose output so |" echo "| that you may monitor it's progress. Once completed, you will be prompted |" echo "| to continue with the installation. DO NOT CLOSE THE NEW WINDOW. |" echo "| |" echo "| During this time, your computer's processor will be extremely loaded. |" echo "| This may degrade the functionality of other processes. This is normal. |" echo "| Ensure your computer is well ventilated. |" echo "| |" echo "| NOTE: this process can take several hours, depending upon your processor |" echo "| speed and amount of recompiling required. |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 portagePID=`cat /tmp/installer/portage.pid` PIDalive=`ps -p $portagePID -o comm=` clear if [ "$PIDalive" = "portage" ]; then echo "Portage has not finished downloading required distfiles yet!" echo "Waiting for Portage to finish ..." while [ "$PIDalive" = "portage" ]; do sleep 30 PIDalive=`ps -p $portagePID -o comm=` done fi echo "Chrooting to your new FLY installation ..." sleep 1 touch /tmp/installer/tmp/compile xterm -bg black -fg white -e "tail -f /tmp/installer/tmp/compile" & chroot /tmp/installer /root/.FLYinstaller/compile env-update && source /etc/profile clear echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| CONFIGURING USER ACCOUNTS |" echo "| |" echo "| This step will allow you to create a normal user account for everyday |" echo "| usage. You will also be asked to change the password for the root account. |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 clear echo "Chrooting to FLY installation ..." chroot /tmp/installer /root/.FLYinstaller/users env-update && source /etc/profile clear echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| CONGRATULATIONS! FLY is installed on your computer |" echo "| |" echo "| The installer will now unmount the installation directories and close. |" echo "| |" echo "| Please ensure any windows that opened during the install process are now |" echo "| closed. Else the installer will be unable to umount your hard drive. |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| |" echo "| Press any key to continue... |" echo "|______________________________________________________________________________|" read -n1 umount /tmp/installer/{boot,dev,sys,proc} umount /tmp/installer exit } echo " ______________________________________________________________________________" echo "|FLYinstaller version: $INSTALL 3604 04|" echo "| |" echo "| Welcome to the FLY installer script. This will install FLY onto your |" echo "| computer. This script has two installation methods: |" echo "| |" echo "| 1) Quick install |" echo "| This will copy the contents of the LiveCD, download package |" echo "| data and other required files. Grub will be installed onto |" echo "| the hard drive. |" echo "| |" echo "| 2) Compile install (Gentoo installation knowledge required) |" echo "| This will copy the contents of the liveCD, download additional |" echo "| install data, and allow you to modify the kernel, and USE flags |" echo "| and recompile world. Depending on the level of modification, |" echo "| this process may take a few hours and can involve downloading |" echo "| several hundred megabytes of source code. |" echo "| |" echo "| |" StartInstall