Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Need Assistance with Bash Script

    Hello All,

    This is my first post and would like to say hello and hi to all. Here is the dilemma that i'm currently facing:

    I am sweating and struggling in creating a script that would automate the rebuilding process of my gentoo servers. I currently have a USB Rescuedisk that works perfect and allows me to automate scripts after boot in which case i would need help doing the following (Hold onnnn!!!! it's alot )

    0) run to following command to check 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/ restart

    once network is running i will need to copy a tarball:
    4) Copy .tgz file from local master node (scp /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

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

    Then Reboot the machine to test process.

    Thank you all and let me know if you have any questions.

  2. #2
    Just Joined!
    Join Date
    Apr 2007

    What exactly is your problem?

    You seem to know what you would like to do. What exactly is the problem that prevents you to compose a script that does what you want it to do?

    Paul Huygen.

  3. #3
    composing the script...that's the issue. I'm not a genius at scripting and just seeing if there is someone who could at least guide me and let me experiment out and see if any of this works.

  4. $spacer_open
  5. #4
    Pretty much figured out what needs to be done. I'll post what i have so far and see what people think about the structure.

Posting Permissions

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