Ed Warnicke | 3ba4d36 | 2016-09-01 11:54:27 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # Figure out what system we are running on |
| 3 | if [ -f /etc/lsb-release ];then |
| 4 | . /etc/lsb-release |
| 5 | elif [ -f /etc/redhat-release ];then |
| 6 | sudo yum install -y redhat-lsb |
| 7 | DISTRIB_ID=`lsb_release -si` |
| 8 | DISTRIB_RELEASE=`lsb_release -sr` |
| 9 | DISTRIB_CODENAME=`lsb_release -sc` |
| 10 | DISTRIB_DESCRIPTION=`lsb_release -sd` |
| 11 | fi |
| 12 | KERNEL_OS=`uname -o` |
| 13 | KERNEL_MACHINE=`uname -m` |
| 14 | KERNEL_RELEASE=`uname -r` |
| 15 | KERNEL_VERSION=`uname -v` |
| 16 | |
| 17 | echo KERNEL_OS: $KERNEL_OS |
| 18 | echo KERNEL_MACHINE: $KERNEL_MACHINE |
| 19 | echo KERNEL_RELEASE: $KERNEL_RELEASE |
| 20 | echo KERNEL_VERSION: $KERNEL_VERSION |
| 21 | echo DISTRIB_ID: $DISTRIB_ID |
| 22 | echo DISTRIB_RELEASE: $DISTRIB_RELEASE |
| 23 | echo DISTRIB_CODENAME: $DISTRIB_CODENAME |
| 24 | echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION |
| 25 | |
| 26 | # Make sure git is installed |
| 27 | if [ $DISTRIB_ID == "CentOS" ]; then |
| 28 | yum -y install git |
| 29 | elif [ $DISTRIB_ID == "Ubuntu" ]; then |
| 30 | apt-get -y install git |
| 31 | fi |
| 32 | |
| 33 | # Setup the vpp code |
| 34 | cd ~vagrant/ |
| 35 | sudo -u vagrant mkdir git |
| 36 | cd git/ |
| 37 | echo "SSH_AUTH_SOCK $SSH_AUTH_SOCK x" |
| 38 | chmod 777 $SSH_AUTH_SOCK |
| 39 | |
| 40 | CLONE_URL=`cd /vpp;git remote -v | grep origin |grep fetch |awk '{print $2}'` |
| 41 | echo "CLONE_URL $CLONE_URL" |
| 42 | echo $CLONE_URL | grep -q "^ssh:" |
| 43 | if [ $? == 0 ]; then |
| 44 | SSH_HOST=`echo $CLONE_URL| awk -F/ '{print $3}'` |
| 45 | SSH_PORT=`echo $SSH_HOST| awk -F: '{print $2}'` |
| 46 | if [ -n $SSH_PORT ]; then |
| 47 | SSH_PORT="-p $SSH_PORT" |
| 48 | fi |
| 49 | SSH_HOST=`echo $SSH_HOST| awk -F: '{print $1}'` |
| 50 | echo "SSH_HOST $SSH_HOST" |
| 51 | echo "SSH_PORT $SSH_PORT" |
| 52 | sudo -HE -u vagrant ssh -oStrictHostKeyChecking=no -v $SSH_PORT $SSH_HOST |
| 53 | fi |
| 54 | sudo -HE -u vagrant git clone $CLONE_URL |