-
Notifications
You must be signed in to change notification settings - Fork 56
/
setup.sh
executable file
·94 lines (79 loc) · 3.18 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
#---------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License in the project root for license information.
#---------------------------------------------------------------------------------------------
if [ "$(expr substr $(uname -s) 1 5)" != "Linux" ]; then
echo "Unsupported OS. This script is for installing Dev Proxy on Linux. To install Dev Proxy on macOS or Windows use their installers. For more information, visit https://aka.ms/devproxy/start."
exit 1
fi
echo ""
echo "This script installs Dev Proxy on your machine. It runs the following steps:"
echo ""
echo "1. Create the 'devproxy' directory in the current working folder"
echo "2. Download the latest Dev Proxy release"
echo "3. Unzip the release in the devproxy directory"
echo "4. Configure devproxy and its files as executable"
echo "5. Add the devproxy directory to your PATH environment variable in your shell profile"
echo ""
if [ -t 0 ]; then
# Terminal is interactive, prompt the user
read -p "Continue (y/n)? " -n1 -r response
else
# Not interactive, set a default response
response='y'
fi
if [[ "$response" != [yY] ]]; then
echo -e "\nExiting"
exit 1
fi
if [ -t 0 ]; then
echo -e "\n"
fi
mkdir devproxy
cd devproxy
full_path=$(pwd)
set -e # Terminates program immediately if any command below exits with a non-zero exit status
if [ $# -eq 0 ]
then
echo "Getting latest Dev Proxy version..."
version=$(curl -s https://api.github.com/repos/microsoft/dev-proxy/releases/latest | awk -F: '/"tag_name"/ {print $2}' | sed 's/[", ]//g')
echo "Latest version is $version"
else
version=$1
fi
echo "Downloading Dev Proxy $version..."
base_url="https://github.com/microsoft/dev-proxy/releases/download/$version/dev-proxy"
ARCH="$(uname -m)"
if [ "$(expr substr ${ARCH} 1 5)" == "arm64" ] || [ "$(expr substr ${ARCH} 1 7)" == "aarch64" ]; then
curl -sL -o ./devproxy.zip "$base_url-linux-arm64-$version.zip" || { echo "Cannot install Dev Proxy. Aborting"; exit 1; }
elif [ "$(expr substr ${ARCH} 1 6)" == "x86_64" ]; then
curl -sL -o ./devproxy.zip "$base_url-linux-x64-$version.zip" || { echo "Cannot install Dev Proxy. Aborting"; exit 1; }
else
echo "unsupported architecture ${ARCH}"
exit
fi
unzip -o ./devproxy.zip -d ./
rm ./devproxy.zip
echo "Configuring devproxy and its files as executable..."
chmod +x ./devproxy ./libe_sqlite3.so
echo "Adding devproxy to the PATH environment variable in your shell profile..."
if [[ ":$PATH:" != *":$full_path:"* ]]; then
if [[ -e ~/.zshrc ]]; then
echo -e "\n# Dev Proxy\nexport PATH=\$PATH:$full_path" >> $HOME/.zshrc
fileUsed="~/.zshrc"
elif [[ -e ~/.bashrc ]]; then
echo -e "\n# Dev Proxy\nexport PATH=\$PATH:$full_path" >> $HOME/.bashrc
fileUsed="~/.bashrc"
else
echo -e "\n# Dev Proxy\nexport PATH=\$PATH:$full_path" >> $HOME/.bash_profile
fileUsed="~/.bash_profile"
fi
fi
echo "Dev Proxy $version installed!"
echo ""
echo "To get started, run:"
if [[ "$fileUsed" != "" ]]; then
echo " source $fileUsed"
fi
echo " devproxy -h"