Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8429083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:14:10+00:00 2026-06-10T05:14:10+00:00

I keep getting errors when debugging my script and I’m at a loss for

  • 0

I keep getting errors when debugging my script and I’m at a loss for what it is the cause.
Error I’m getting are below thanks in advance for your help
line 29: syntax error near unexpected token else'
line 29:
else if [ [“$VERSION” = “5” ] && [“$ARCH” = “64” ] ];’

    #!/bin/bash
    if [ $USER != 'root' ]
    then
    echo "REQUIRES ROOT"
    exit 0
    fi

    ###Determine OS Version and Architecture
    read -p "What version of Centos are you Running? [5,6]?" VERSION
    echo $VERSION
    ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')


    IP=$(hostname -i)
    ###Installing OpenVpn Dependicies
    echo Installing OpenVpn Dependicies
    yum install gcc make wget rpm-build autoconf.noarch zlib-devel pam-devel        openssl-devel -y

    ###Download LZO RPM and Configure RPMForge Repo
    wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm
    echo Downloaded LZO RPM

    ##Download RPMForge Repo
    if [ ["$VERSION" = "5" ] && ["$ARCH" = "32" ] ];
    then
  wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
    fi

    else if [ ["$VERSION" = "5" ] && ["$ARCH" = "64" ] ];
    then
          wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
    fi

    else if [ ["$VERSION" = "6" ] && ["$ARCH" = "32" ] ];
    then
          wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-1.el6.rf.i686.rpm
    fi

    else if [ ["$VERSION" = "6" ] && ["$ARCH" = "64" ] ];
    then
          wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
    fi
    echo Downloaded Centos $VERSION $ARCH Rpmforge RPM

    ###Build the rpm packages
    rpmbuild --rebuild lzo-1.08-4.rf.src.rpm
    rpm -Uvh lzo-*.rpm
    rpm -Uvh rpmforge-release*
    echo rpm packages built

    ###Install OpenVPN
    yum install openvpn
    echo Openvpn installed

    ###Copy the easy-rsa folder to /etc/openvpn/
    cp -R /usr/share/doc/openvpn-2.2.2/easy-rsa/ /etc/openvpn/
    echo easy-rsa copied to /etc/openvpn/

    ###CentOS 6 patch for /etc/openvpn/easy-rsa/2.0/vars
    if [ ["$VERSION" = "6" ];
    then 
    sed -i bak -e s/export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`/export KEY_CONFIG=/etc/openvpn/easy-rsa/2.0/openssl-1.0.0.cnf/g /etc/openvpn/easy-rsa/2.0/vars

    ###Now let’s create the certificate
    cd /etc/openvpn/easy-rsa/2.0
    chmod 755 *
    source ./vars
    ./vars
    ./clean-all

    ###Build CA
    ./build-ca
    echo certificate built

    ###Build key Server
    ./build-key-server server
    echo key Server built

    ###Build Diffie Hellman
    echo Build Diffie Hellman
    ./build-dh
    echo Diffie Hellman built

    ###Create OpenVPN server conf
    touch /etc/openvpn/server.conf
    echo OpenVPN Server conf created /etc/openvpn/server.conf

    echo "local 123.123.123.123 #- your_server_ip goes here
    port 1194 #- port
    proto udp #- protocol
    dev tun
    tun-mtu 1500
    tun-mtu-extra 32
    mssfix 1450
    ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
    cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
    key /etc/openvpn/easy-rsa/2.0/keys/server.key
    dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem
    plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so /etc/pam.d/login
    client-cert-not-required
    username-as-common-name
    server 10.8.0.0 255.255.255.0
    push "redirect-gateway def1"
    push "dhcp-option DNS 8.8.8.8"
    push "dhcp-option DNS 8.8.4.4"
    keepalive 5 30
    comp-lzo
    persist-key
    persist-tun
    status 1194.log
    verb 3" > '/etc/openvpn/server.conf'
    sed -i bak -e s/123.123.123.123/$IP/g /etc/openvpn/server.conf
    echo default server copied to /etc/openvpn/server.conf please


    ###Save it and start OpenVPN
    service openvpn start

    ###enable IP forwarding
    sed -i bak -e s/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g /etc/sysctl.conf
    sysctl -p
    echo ip forwarding enabled

    ###Route Iptables
    echo iptables setup
    iptables -F
    read -p "What type of Virtualization are you using? [openvz,xen,kvm]?" VMVIRTTYPE
    echo $VMVIRTTYPE

    if [ "$VMVIRTTYPE" = "openvz" ];
    then
          iptables -t nat -A POSTROUTING -o venet0 -j SNAT --to-source $IP
    fi

    else [ "$VMVIRTTYPE" = "xen" ];
    then
          iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
    fi

    else [ "$VMVIRTTYPE" = "kvm" ];
    then
          iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
    fi
    service iptables save
    echo iptables configured and saved

    ###Create Server.opvn
    touch /etc/openvpn/server.ovpn
    echo "client
    dev tun
    proto udp
    remote 123.123.123.123 1194 # - Your server IP and OpenVPN Port
    resolv-retry infinite
    nobind
    tun-mtu 1500
    tun-mtu-extra 32
    mssfix 1450
    persist-key
    persist-tun
    ca ca.crt
    auth-user-pass
    comp-lzo
    verb 3" > '/etc/openvpn/server.ovpn'
    sed -i bak -e s/123.123.123.123/$IP/g /etc/openvpn/server.ovpn
    echo server.opvn saved to /etc/openvpn/server.ovpn
    exit 0
    fi
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:14:11+00:00Added an answer on June 10, 2026 at 5:14 am

    You aren’t using the appropriate if constructs (you’re closing them too early). Here’s what you’re doing:

    if {tests}
    then
    {code}
    fi                     <== Problem #1
    else if {more tests}   <== Problem #2
    {code}
    fi
    

    And here’s what it should be:

    if {tests}
    then
    {code}
    elif {more tests}
    {code}
    fi
    

    In other words, there should only be one fi for a whole if block (this includes the else clauses). Note that you should also be using elif instead of else if.

    You can read more about if statements in the Bash Guide for Beginners.

    Update: So here’s a modification of your block that should (hopefully) work. Note that I’ve also simplified your test blocks, which had some unnecessary square brackets in them.

    if [[ "$VERSION" = "5" && "$ARCH" = "32" ]]
    then
        wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
    elif [[ "$VERSION" = "5" && "$ARCH" = "64" ]]
    then
        wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
    elif [[ "$VERSION" = "6" && "$ARCH" = "32" ]]
    then
        wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-1.el6.rf.i686.rpm
    elif [[ "$VERSION" = "6" && "$ARCH" = "64" ]]
    then
        wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this php code and keep on getting errors upon fixing each error.
I keep getting these 2 errors in my code In function 'int main()': error:
Here's the response I keep getting when trying to create a new activity: {error:{errors:[{message:Unknown
I keep getting the following error when debugging. Cross-thread operation not valid: Control 'richTextBoxReceivedMsg'
New to vba, trying an 'on error goto' but, I keep getting errors 'index
I keep getting errors that my functions have been defined multiple times. Of course
In testing an app, I keep getting errors that occur sporadically on only one
I want to include validates_confirmation_of :password in a module but i keep getting errors
I use __autoload to load classes, and I keep getting errors that no class
I am attempting to link my program executable, but I keep getting errors. Having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.