Copy Files From Target Via NFS

Discussion in 'General Linux' started by NorthStar, Aug 18, 2014.

  1. NorthStar

    NorthStar New Member

    Messages:
    4
    Likes Received:
    1
    Trophy Points:
    3
    Hello I need some assistance with a script I am writing. Below is what I have so far:

    Ideally, I would like to ask the user for an IP address and append that IP to the beginning of the (rw,async,no_root_squash) in etc/exports. I also created a menu to be able to run the commands but I keep receiving syntax error unexpected token. Any guidance would be appreciated.

    #!/bin/bash

    ####################################################################
    # This script allows user to grap coredump files for Developers
    #
    #
    #
    # Developed by:
    # Version: Beta 3
    #
    # Aug 18,2014
    ####################################################################

    function creatdir()

    {

    mkdir /nfsdir

    }

    function getip

    {

    read -p "Enter IP Address: " IP_ADDRESS

    #ile=/etc/exports

    file="/coredumps *(rw,async,no_root_squash)"


    if [ -f "$file" ]

    then

    echo "$file already exists."

    else

    echo `echo "/coredumps *(rw,async,no_root_squash)"`>>/etc/exports

    fi
    }


    function nfsrestart()

    {

    cd /etc/rc.d/init.d/

    ./nfs stop

    ./nfs start

    }

    function tnet
    {

    telnet -a $IP_ADDRESS

    cd /initrd/

    mkdir mountpt

    }

    show_menu(){
    NORMAL="\033[m"
    MENU="\033[36m" #Blue
    NUMBER="\033[33m" #yellow
    RED_TEXT="\033[31m"
    ENTER_LINE="\033[33m"
    echo -e "Mount and copy core dump to the NFS Hosted Directory"
    echo -e "${MENU}***********************************************"
    echo -e "${MENU}**${NUMBER} 1)${MENU} Mount for Sell 11 and earlier Os'es"
    echo -e "${MENU}**${NUMBER} 2)${MENU} Mount for Aloha OS"
    echo -e "${MENU}***********************************************"
    echo -e "${ENTER_LINE} Please enter a menu option ${RED_TEXT}"
    read opt

    }
    clear
    show_menu

    if [[ $opt = "" ]]; then
    exit;

    else
    case $opt in
    1)#clear;
    echo "Enter IP Address of Target Machine:"
    read IP_ADDRESS
    # function tnet();
    #mount $IP_ADDRESS:/nfsdir /initrd/mountpt
    #cd /var/coredumps/
    #cp multigameapp-12345 /initrd/mountpt
    #cp multigameapp-12345.stk /initrd/mountpt/
    ;;

    2) clear;
    option_picked "Option 2 picked";
    mount -o,tcp,nolock "$IP_ADDRESS":/nfsdir /initrd/mountpt
    cd /var/coredumps/
    cp multigameapp-12345 /initrd/mountpt
    cp multigameapp-12345.stk /initrd/mountpt/
    ;;

    *)clear;
    option_picked "Pick an option from the menu";
    show_menu;
    ;;
    esac
    fi
    done
  2. WharfRat

    WharfRat New Member

    Messages:
    28
    Likes Received:
    10
    Trophy Points:
    3
    I don't see any matching do, while, for or until for the done at the end of the script.

    2) clear;
    option_picked "Option 2 picked";

    I don't see function for this.

Share This Page