BashScripts.org
http://bashscripts.org/forum/

Assistance with building script --my first one
http://bashscripts.org/forum/viewtopic.php?f=8&t=426
Page 1 of 1

Author:  osobh [ Wed Sep 26, 2007 10:39 am ]
Post subject:  Assistance with building script --my first one

I have been working on this script as of today and needed some input. I'm trying to automate my install process since i have about 200 servers (Gentoo) that i have to rebuild, and whenever they go down it's taking forever to rebuild. I have a USB rescuedisk created that runs automated scripts after the boot process. So basically to automate the process, this would be the order after boot is completed that i would need a script for :

0) run to following command to check and see if partitions are still there ( cat /proc/partitions | grep sda | wc -l and also the same but cat /proc/partitions | grep sdb | wc -l )

Once that has been completed, and if partitions are not there then i will have to run Fdisk (and i will post the sequence that i will need), otherwise i can continue below:

1) Assemble the RAID disks (mdadm -A /dev/md1 /dev/sda1 /dev/sdb1 , mdadm -A /dev/md2 /dev/sda2 /dev /sdb2 , mdadm -A /dev/md3 /dev/sda3 /dev/sdb3)
2) Create the Filesystems (mke2fs /dev/md1; mkswap /dev/md2; swapon /dev/md2; mke2fs -j /dev/md3)

Now i have issued the following command and was able to get the MACAddresses, Hostname, and IP of every machine my network.

arp -a | gawk '{print $4, $1, $2}'

I took the results and output them to text file called Macaddreses. Basically i would need a way to check the macaddress listing to match the MAC address of the current machine i'll be working on, once that is a match i'll know eactly which IP it will be the i will need the script to also:

3) Configure network: nano /etc/conf.d/net; fill in two lines (ip, gateway) , change the hostname (/etc/conf.d/hostname )-->change to the right name)

then network needs to be restarted using /etc/init.d/eth0.net restart

once network is running i will need to copy a tarball:
4) Copy .tgz file from local master node (scp xx.xx.xxx.xx:/all.tgz /mnt/gentoo)
5) Utar it : tar -xzvf all.tgz
6) Create some empty directories once untar is finished and soft link (mkdir home, mkdir proc, mkdir sys, mkdir mnt; ln -s lib64 lib)

Run following commands:
mount -t proc none /mnt/gentoo/proc;
mount -o bind /dev /mnt/gentoo/dev;
chroot /mnt/gentoo /bin/bash
env-update

install grub:
grub --no-foppy;
root (hd0,0);
setup (hd0);
quit

Then Reboot the machine to test process.

If anyone could assist me with ideas for each section so i can test this would be much appreciated.

best regards,
osobh

Author:  osobh [ Fri Sep 28, 2007 5:33 am ]
Post subject: 

Figured out the process......

will post results soon..

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group • http://www.phpbb.com