Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shart.sh bug #49

Closed
VAllens opened this issue Sep 20, 2017 · 5 comments
Closed

shart.sh bug #49

VAllens opened this issue Sep 20, 2017 · 5 comments

Comments

@VAllens
Copy link

VAllens commented Sep 20, 2017

1.Path error

export PATH="$PATH:/mnt/c/Program Files (x86)/VMware/VMware Workstation"
should be changed to
export PATH="$PATH:/c/Program Files (x86)/VMware/VMware Workstation"

2.Syntax error

vmrun.exe list | grep \""${VM}"\" &> /dev/null
should be changed to
vmrun.exe list | grep "${VM}" &> /dev/null

This full code:

    #!/bin/bash

    export PATH="$PATH:/c/Program Files (x86)/VMware/VMware Workstation"

    trap '[ "$?" -eq 0 ] || read -p "Looks like something went wrong in step ´$STEP´... Press any key to continue..."' EXIT

    VM=${DOCKER_MACHINE_NAME-default}
    DOCKER_MACHINE=./docker-machine.exe

    BLUE='\033[1;34m'
    GREEN='\033[0;32m'
    NC='\033[0m'


    if [ ! -f "${DOCKER_MACHINE}" ]; then
      echo "Docker Machine is not installed. Please re-run the Toolbox Installer and try again."
      exit 1
    fi

    vmrun.exe list | grep "${VM}" &> /dev/null
    VM_EXISTS_CODE=$?

    set -e

    STEP="Checking if machine $VM exists"
    if [ $VM_EXISTS_CODE -eq 1 ]; then
      "${DOCKER_MACHINE}" rm -f "${VM}" &> /dev/null || :
      rm -rf ~/.docker/machine/machines/"${VM}"
      #set proxy variables if they exists
      if [ -n ${HTTP_PROXY+x} ]; then
        PROXY_ENV="$PROXY_ENV --engine-env HTTP_PROXY=$HTTP_PROXY"
      fi
      if [ -n ${HTTPS_PROXY+x} ]; then
        PROXY_ENV="$PROXY_ENV --engine-env HTTPS_PROXY=$HTTPS_PROXY"
      fi
      if [ -n ${NO_PROXY+x} ]; then
        PROXY_ENV="$PROXY_ENV --engine-env NO_PROXY=$NO_PROXY"
      fi  
      "${DOCKER_MACHINE}" create -d vmwareworkstation $PROXY_ENV "${VM}"
    fi

    STEP="Checking status on $VM"
    VM_STATUS="$(${DOCKER_MACHINE} status ${VM} 2>&1)"
    if [ "${VM_STATUS}" != "Running" ]; then
      "${DOCKER_MACHINE}" start "${VM}"
      yes | "${DOCKER_MACHINE}" regenerate-certs "${VM}"
    fi

    STEP="Setting env"
    eval "$(${DOCKER_MACHINE} env --shell=bash ${VM})"

    STEP="Finalize"
    clear
    cat << EOF


                            ##         .
                      ## ## ##        ==
                   ## ## ## ## ##    ===
               /"""""""""""""""""\___/ ===
          ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
               \______ o           __/
                 \    \         __/
                  \____\_______/

    EOF
    echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}${VM}${NC} machine with IP ${GREEN}$(${DOCKER_MACHINE} ip ${VM})${NC}"
    echo "For help getting started, check out the docs at https://docs.docker.com"
    echo
    cd

    docker () {
      MSYS_NO_PATHCONV=1 docker.exe "$@"
    }
    export -f docker

    if [ $# -eq 0 ]; then
      echo "Start interactive shell"
      exec "$BASH" --login -i
    else
      echo "Start shell with command"
      exec "$BASH" -c "$*"
    fi
    ```
@VAllens
Copy link
Author

VAllens commented Sep 20, 2017

Now, this sh script is running pretty well on my machine

@pecigonzalo
Copy link
Owner

Please submit a PR with it, thanks!

@VAllens
Copy link
Author

VAllens commented Sep 20, 2017

I submitted a PR

@ghost
Copy link

ghost commented Oct 20, 2017

This is probably a symptom of WSL (Windows Subsystem for Linux) bash vs git bash. If you have WSL installed on Windows 10 then the WSL bash is first in the path and the mountpoint for the C drive is different than what git bash has. I don't know why we can't all get along: /c /mnt/c /cygdrive/c 🙄

If you use:
export PATH="$PATH:/c/Program Files (x86)/VMware/VMware Workstation:/mnt/c/Program Files (x86)/VMware/VMware Workstation"
then it will work with both (ugly kluge, but oh well) -- and if VMware workstation is installed in D: or soemwhere else then even that won't work. But that is a topic for another day and another issue.

@VAllens
Copy link
Author

VAllens commented Nov 22, 2017

Your script code, run with WSL (Windows Subsystem for Linux) bash, no problem.
There's a problem running in git bash.
You can close this issue, thank you so much.

@VAllens VAllens closed this as completed Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants