Results 1 to 7 of 7

Thread: Bash Scripting

  1. #1
    Join Date
    Nov 2007
    Location
    England
    Posts
    239

    Bash Scripting

    I am trying to automate the installation of YUM, cPanel/WHM and CSF.

    I have written a script that works perfectly all the way down to installing CSF...

    It gives me the following error when moving onto the CSF installation;

    Code:
    --05:03:37--  http://www.configserver.com/free/csf.tgz
    Resolving www.configserver.com... 85.13.195.235
    Connecting to www.configserver.com|85.13.195.235|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 433358 (423K) [application/x-tar]
    Saving to: `csf.tgz'
    
    100%[=======================================>] 433,358      338K/s   in 1.3s
    
    05:03:39 (338 KB/s) - `csf.tgz' saved [433358/433358]
    
    --05:03:39--  http://%0D/
    Resolving \015... failed: Name or service not known.
    FINISHED --05:03:39--
    Downloaded: 1 files, 423K in 1.3s (338 KB/s)
    tar: \r: Not found in archive
    tar: Error exit delayed from previous errors
    ./cPanelServer.sh: line 9: cd: csf: No such file or directory
    sh: install.sh: No such file or directory
    ./cPanelServer.sh: line 13: unexpected EOF while looking for matching `"'
    ./cPanelServer.sh: line 18: syntax error: unexpected end of file
    Script Contents;

    Code:
    ./yum.sh \
    cd /home \
    wget layer1.cpanel.net/latest \
    sh latest \
    cd / \
    rm -fv csf.tgz \
    wget http://www.configserver.com/free/csf.tgz \
    tar -xzf csf.tgz \
    cd /csf \
    sh install.sh \
    echo -n "TESTING = "1"
    read word
    sed "s/$word/TESTING = "0"/g" /etc/file.conf > /etc/file.conf.new
    mv /etc/file.conf.new /etc/file.conf \
    service csf restart
    
    done
    It's seems the script is having issues extracting "csf.tgz", but I have no clue.

    TBH, this is my first ever script and I'm surprised any of it works!

    Any help will be appreciated!

  2. #2
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    are you able to successfully run "sh install.sh"? Its some command that needs to resolve. Tar doesn't need to resolve anything
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    http://xieles.com

  3. #3
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    Your script is screwed up at "wget" line... why do you want to put a slash at the end of each command?
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    http://xieles.com

  4. #4
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    At a guess, those are the remnants of windoze \r\n line endings. Check your script for those and other invisible characters. dos2unix might fix it, or if necessary just retype the entire script on the server.
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  5. #5
    Join Date
    Nov 2007
    Location
    England
    Posts
    239
    @fabin: It is just a script I was experimenting with that install's YUM, trying to incorporate the cPanel installation and the CSF installation. YUM and cPanel go through perfectly without any issues, it just gets stuck when it arrives down to installing CSF.

    @foobic: I searched dos2unix on Google, and found - http://www.dos2unix.org/ - It fixed up the script and it now install's CSF - PRAISE YOU - haha.

    The only thing it is stuck with now it changing the TESTING="1" to TESTING="0" in the csf.conf.

    Any idea's how I could fix that?

    Thank's for all the help contributed thus far!

  6. #6
    Join Date
    Mar 2009
    Location
    Gods Own Country
    Posts
    681
    use sed command to search and replace it

    something like this...
    sed 's/<old>/<new>/g' <filename>
    Fabin Mundattil @ Xieles Support
    High Quality Server Management | support @ xieles.com
    http://xieles.com

  7. #7
    Join Date
    Nov 2007
    Location
    England
    Posts
    239
    After a few, I finally gave up trying to incorporate all the commands into one file and tried an alternative method which works perfectly!

    Now what I need to try and do is shoot off a command that will ask for a container ID;

    Code:
    vzctl set (CTID) --iptables ipt_REJECT --iptables ipt_tos --iptables ipt_TOS --iptables ipt_LOG --iptables ip_conntrack --iptables ipt_limit --iptables ipt_multiport --iptables iptable_filter --iptables iptable_mangle --iptables ipt_TCPMSS --iptables ipt_tcpmss --iptables ipt_ttl --iptables ipt_length --iptables ipt_state --iptables iptable_nat --iptables ip_nat_ftp--save
    I want the script to shoot out a question like "Please Specify CT-ID:" at which point you would enter the container ID and hit enter and it would continue with the command.

    Would this be possible?

    Also, the sed command given above didn't edit the csf.conf.

    Any ideas?

Similar Threads

  1. Need some bash scripting help
    By ThatScriptGuy in forum Programming Discussion
    Replies: 3
    Last Post: 04-08-2007, 04:48 PM
  2. Bash scripting question
    By EviL_SmUrF in forum Hosting Security and Technology
    Replies: 1
    Last Post: 02-24-2005, 03:26 PM
  3. Need Help With Bash/SSH Scripting
    By WWTSLarry in forum Running a Web Hosting Business
    Replies: 0
    Last Post: 02-13-2005, 10:15 PM
  4. bash scripting - need help
    By BMurtagh in forum Programming Discussion
    Replies: 1
    Last Post: 02-22-2003, 08:45 PM

Posting Permissions

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