#!/bin/bash #set -x # #gia - version 2 df 2> /dev/null | grep -q newroot if [ $? = 0 ]; then ls /mnt/gentoo/boot/*kernel* &> /dev/null if [ $? = 0 ]; then echo "-Detected you have already left the chroot and are finishing up." echo "Only thing left to do now is type 'reboot'" exit fi echo "-Detected you are currently on the LIVE CD, with no chroot setup." echo " " if [ `date -d 04\06\01 +%s` -gt `date +%s` ] || [ `date -d 07\01\01 +%s` -lt `date +%s` ]; then echo "FAIL: Date and time appear to be off." echo "# date MMDDhhmmCCYY"; echo "" fi ifconfig | grep -q eth if [ $? != 0 ]; then echo "FAIL: No network device detected. This is a non critical error." echo "The dhcpcd command can help you get an ip address via dhcp." echo "or" echo "ifconfig eth0 x.x.x.x netmask 255.255.255.0" echo "route add default gw x.x.x.x" echo "echo nameserver x.x.x.x > /etc/resolv.conf" else ping -c 1 google.com &>/dev/null if [ $? != 0 ]; then echo "FAIL: Net access ping test failed." echo "You can still continue the install if you don't need the Internet to finish it." fi fi df | grep -q /mnt/gentoo if [ $? != 0 ]; then echo "You need to partition your HD." echo "Use fdisk or cfdisk." echo " " echo "Your hard drives are:" dmesg | grep hd | grep DISK echo " -reboot after partitioning- " echo " " echo "Format your partitions." echo "Use mkswap, mke2fs, mke2fs -j, mkreiserfs, mkfs.xfs, or mkfs.jfs" echo " " echo "After the above is done, mount your root partition to /mnt/gentoo" echo "# mount /dev/hda? /mnt/gentoo" exit else if [ ! -e /mnt/gentoo/gia ]; then cp ./gia /mnt/gentoo fi fi ls /mnt/gentoo/usr &> /dev/null if [ $? != 0 ]; then echo "Next, you need to get a stage file and extract it." echo "# cd /mnt/gentoo" echo "# tar xvjpf /mnt/cdrom/stages/stage" echo " " echo "Alternatively, you could download the latest stage file if you have net access." echo "# links http://www.gentoo.org/main/en/mirrors.xml" fi ls /mnt/gentoo/usr/portage &> /dev/null if [ $? != 0 ]; then echo "Next, extract your portage tree." echo "# tar xvjf /mnt/cdrom/snapshots/portage-*.tar.bz2 -C /mnt/gentoo/usr" echo "TIP: You can use a ; to queue up multiple commands." exit fi if [ ! -e /mnt/gentoo/etc/resolv.conf ]; then echo "FAIL: resolv.conf needs to be copied." echo " CMD: cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf" echo "AUTOFIX: I will now do the above command for you." cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf echo "Done." fi df -a | grep -q /mnt/gentoo/proc # maybe a df -ahs /mnt/gentoo/proc might work better here. if [ $? != 0 ]; then echo "FAIL: /mnt/gentoo/proc not detected." echo " CMD: mount -t proc none /mnt/gentoo/proc" echo "AUTOFIX: I will now mount your proc for you." mount -t proc none /mnt/gentoo/proc echo "Done." fi echo "Next, do your chroot." echo "# chroot /mnt/gentoo" else echo "--Post chroot install detected--" echo " " if [ ! -h /etc/localtime ]; then echo "FAIL: /etc/localtime doesn't exist!" echo "You need to set your timezone information." echo "# ln -sf /usr/share/zoneinfo/ /etc/localtime" echo "TIP: Use the TAB key to show the choices inside of the zoneinfo directory."; echo "" exit fi if [ ! -e /etc/resolv.conf ]; then echo "FAIL: /etc/resolv.conf does not exist!" echo "# echo nameserver x.x.x.x > /etc/resolv.conf" exit fi if [ ! -e /etc/hostname ]; then echo "FAIL: /etc/hostname does not exist!" echo "# echo mymachine > /etc/hostname" exit fi if [ ! -e /etc/dnsdomainname ]; then echo "FAIL: /etc/dnsdomainname does not exist!" echo "# echo localdomain > /etc/dnsdomainname" exit fi if [ -e /var/cache/edb/virtuals ]; then grep -q virtual/cron /var/cache/edb/virtuals if [ $? != 0 ]; then echo "FAIL: Need to install a CRON service." echo "# emerge vixie-cron (or dcron, fcron)" fi fi if [ -e /var/cache/edb/virtuals ]; then grep -q virtual/bootloader /var/cache/edb/virtuals if [ $? != 0 ]; then echo "FAIL: Need to install a BOOTLOADER. aka grub/lilo." echo "# emerge grub" fi fi if [ -e /var/cache/edb/virtuals ]; then grep -q virtual/logger /var/cache/edb/virtuals if [ $? != 0 ]; then echo "FAIL: Need to install a LOGGER service." echo "# emerge syslog-ng" fi fi if [ -e /var/cache/edb/world ]; then grep -q sys-apps/hotplug /var/cache/edb/world if [ $? != 0 ]; then echo "FAIL: You don't have hotplug emerged." echo "# emerge hotplug" fi fi if [ ! -e /etc/runlevels/default/net.eth0 ]; then echo "FAIL: net.eth0 is not set to start on bootup!" echo "# rc-update add net.eth0 default" fi if [ ! -e /etc/runlevels/default/domainname ]; then echo "FAIL: domainname is not set to start on bootup!" echo "# rc-update add domainname default" fi if [ ! -e /etc/runlevels/default/hotplug ]; then echo "FAIL: hotplug is not set to start on bootup!" echo "# rc-update add hotplug default" fi ls /etc/runlevels/default/*cron* &> /dev/null if [ $? != 0 ]; then echo "FAIL: A cron service is not set to start on bootup!" echo "# rc-update add vixie-cron default" fi ls /etc/runlevels/default/*log* &> /dev/null if [ $? != 0 ]; then echo "FAIL: A logger service is not set to start on bootup!" echo "# rc-update add syslog-ng default" fi cat /etc/fstab | grep -q /dev/ROOT if [ $? = 0 ]; then echo "You still need to edit your fstab." echo "# nano -w /etc/fstab" exit fi cat /etc/passwd | grep -q 1000 if [ $? != 0 ]; then echo "You still need to setup a user." echo "# useradd myuser -m -G users,wheel" echo "# passwd myuser" fi cat /etc/shadow | grep -q Snoq if [ $? = 0 ]; then echo "Looks like you might still need to set your root passwd." echo "# passwd" exit fi cat /etc/conf.d/net | grep -q 192.168.0.2 if [ $? = 0 ]; then cat /etc/conf.d/net | grep -q "#gateway" if [ $? = 0 ]; then cat /etc/conf.d/net | grep -q "#iface_dhcp" if [ $? = 0 ]; then echo "You still need to edit your /etc/conf.d/net file." echo "This file is for controling your network interfaces." echo "#nano -w /etc/conf.d/net" fi fi fi cat /etc/fstab | grep -q reiserfs if [ $? = 0 ]; then cat /var/cache/edb/world | grep -q reiserfs if [ $? != 0 ]; then echo "Detected reiserfs being used. You need reiserfsprogs." echo "# emerge reiserfsprogs" exit fi fi cat /var/cache/edb/world | grep -q sources if [ $? != 0 ]; then echo "You need to emerge some linux kernel sources." echo "# emerge development-sources (or whatever sources you want.)" fi cat /var/cache/edb/world | grep -q genkernel if [ $? != 0 ]; then echo "You need to emerge genkernel." echo "# emerge genkernel" fi ls /boot/*kernel* &> /dev/null if [ $? != 0 ]; then echo "You need to compile a kernel still." echo "Either do it manually or use genkernel." echo "# genkernel --menuconfig all" exit fi if [ -e /boot/grub/ ] && [ ! -e /boot/grub/grub.conf ]; then echo "No grub.conf found." echo "Creating a basic one for you..." cat >/boot/grub/grub.conf <<. default 0 timeout 4 color blue/black blue/light-gray title=Gentoo Linux root (hd0,1) # genkernel users: kernel /kernel- root=/dev/ram0 init=/linuxrc real_root=/dev/hda3 initrd /initrd- # non-genkernel users: kernel /kernel- root=/dev/hda3 . echo "...done." fi if [ -e /boot/grub/ ]; then cat /boot/grub/grub.conf | grep -q "kernel version" if [ $? = 0 ]; then echo "Now go edit your grub.conf" echo "Your kernel version is:" ls /boot/*kernel* echo "# nano -w /boot/grub/grub.conf" echo " " echo "And lastely run 'grub' and do these commands." echo " root (hdx,x) ...drive, parition" echo " setup (hdx) ...drive" echo "Obviously more verbose instructions should be added here." exit fi fi echo "You can now type 'exit' to leave the chroot." fi #-Other things to add- #Check critical system files have been edited to non-default values. make.conf,fstab,hosts,rc.conf,net #Check that atleast 1 system users has been created. #check /proc for any hardware hints and recommendations during install. #Ideally, gia should have two modes. # 1) verbose only..shows directions # 2) auto does all that is possible. #If gia is run from an already setup gentoo install, it should do standard checks on the system.