-
Notifications
You must be signed in to change notification settings - Fork 263
Feature/automate install script #667
base: master
Are you sure you want to change the base?
Changes from all commits
ee8ad9a
3c9e49d
a393957
50a4fc6
9071a2f
d802736
934939d
ca959d7
59d1cdd
f778673
24697cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,9 @@ To run the bot in simulation mode, try this command: | |
|
||
_Note for Windows Users: You should use a [Bash Shell][bash] to follow the steps below. This will give you a UNIX environment in which to run your commands and will enable the `./scripts/build.sh` bash script to work correctly._ | ||
|
||
To compile Kelp from source: | ||
_Note for MacOS Users: Running [install-macos.sh][install-macos-script] should automate the steps below. (including cloning the Kelp repo to the correct Go folder) Remember, manual installation of PostgreSQL and Docker are additionally required._ | ||
|
||
## Manual Installation Steps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a section called "Automated Install for MacOS" above this section on "Manual Installation Steps"? |
||
|
||
1. [Download][golang-download] and [setup][golang-setup] Golang _v1.13 or later_. | ||
* Confirm that `$GOPATH` is set, and that `GOBIN=$GOPATH/bin` | ||
|
@@ -131,7 +133,9 @@ To compile Kelp from source: | |
* `./scripts/build.sh` | ||
8. Confirm one new binary file exists with version information. | ||
* `./bin/kelp version` | ||
9. Set up CCXT to use an expanded set of priceFeeds and orderbooks (see the [Using CCXT](#using-ccxt) section for details) | ||
9. Run the GUI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's swap step 9 and 10. we should run ccxt-rest before we run the GUI |
||
* `./bin/kelp server` | ||
10. Set up CCXT to use an expanded set of priceFeeds and orderbooks (see the [Using CCXT](#using-ccxt) section for details) | ||
* `sudo docker run -p 3000:3000 -d franzsee/ccxt-rest:v0.0.4` | ||
|
||
## Running Kelp | ||
|
@@ -416,3 +420,4 @@ See the [Code of Conduct](CODE_OF_CONDUCT.md). | |
[github-bug-report]: https://github.com/stellar/kelp/issues/new?template=bug_report.md | ||
[github-feature-request]: https://github.com/stellar/kelp/issues/new?template=feature_request.md | ||
[github-new-issue]: https://github.com/stellar/kelp/issues/new | ||
[install-macos-script]:https://github.com/stellar/kelp/blob/master/scripts/install-macos.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,268 @@ | ||
#!/bin/bash | ||
# shellcheck disable=SC2016 | ||
set -e | ||
|
||
# Set this machine's dependencies status(es) with the OK flag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add to this comment that this variable is what we use as the return value from functions. we do so by updating the value of the OK variable before we return from the function and the calling code can read the OK variable. |
||
OK=true; | ||
|
||
# Dependency test functions begin here | ||
|
||
function isNode() { | ||
if node -v; then | ||
OK=true; | ||
else | ||
OK=false; | ||
fi | ||
} | ||
|
||
function isYarn() { | ||
if yarn --version; then | ||
OK=true; | ||
else | ||
OK=false; | ||
fi | ||
} | ||
|
||
function isGit() { | ||
if git --version; then | ||
OK=true; | ||
else | ||
OK=false; | ||
fi | ||
} | ||
|
||
function isGo() { | ||
if go version; then | ||
OK=true; | ||
else | ||
OK=false; | ||
fi | ||
} | ||
|
||
function isGlide() { | ||
if glide --version; then | ||
OK=true; | ||
else | ||
OK=false; | ||
fi | ||
} | ||
|
||
# Installation functions begin here | ||
|
||
function installGo() { | ||
echo 'Installing Golang on your machine.' | ||
# Go install script based on https://github.com/canha/golang-tools-install-script | ||
VERSION="1.15.7" | ||
|
||
[ -z "$GOROOT" ] && GOROOT="$HOME/go/go-install-do-not-delete" | ||
[ -z "$GOPATH" ] && GOPATH="$HOME/go" | ||
|
||
OS="$(uname -s)" | ||
ARCH="$(uname -m)" | ||
|
||
case $OS in | ||
"Linux") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will this run on Linux too? |
||
case $ARCH in | ||
"x86_64") | ||
ARCH=amd64\ | ||
;; | ||
"aarch64") | ||
ARCH=arm64 | ||
;; | ||
"armv6" | "armv7l") | ||
ARCH=armv6l | ||
;; | ||
"armv8") | ||
ARCH=arm64 | ||
;; | ||
.*386.*) | ||
ARCH=386 | ||
;; | ||
esac | ||
PLATFORM="linux-$ARCH" | ||
;; | ||
"Darwin") | ||
PLATFORM="darwin-amd64" | ||
;; | ||
esac | ||
|
||
if [ -z "$PLATFORM" ]; then | ||
echo "Your operating system is not supported by the script." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add the name of the OS that is unsupported?
|
||
exit 1 | ||
fi | ||
|
||
if [ '/bin/bash' == `which bash` ]; then | ||
shell_profile="$HOME/.bashrc" | ||
echo "bash is installed" | ||
else | ||
echo "Kelp requires bash" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should exit from there if the user does not have bash. a simple exit 2 should work (keeping in mind that we're using different exit codes for different errors) |
||
fi | ||
|
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can check if GOROOT is defined in the bashrc file before we do this -- so it doesn't repeat it in the bashrc file. we can achieve this by doing a grep for "export GOROOT" on the $shell_profile and seeing if it retuned any result. you may need to do something like this to check that:
we can reuse the condition check for |
||
echo '# GoLang' | ||
echo "export GOROOT=${GOROOT}" | ||
echo 'export PATH=$GOROOT/bin:$PATH' | ||
echo "export GOPATH=$GOPATH" | ||
echo 'export PATH=$GOPATH:$PATH' | ||
} >> "$shell_profile" | ||
|
||
if [ -d "$GOROOT" ]; then | ||
echo "The Go install directory ($GOROOT) already exists." | ||
fi | ||
|
||
PACKAGE_NAME="go$VERSION.$PLATFORM.tar.gz" | ||
TEMP_DIRECTORY=$(mktemp -d) | ||
|
||
echo "Downloading $PACKAGE_NAME ..." | ||
if hash wget 2>/dev/null; then | ||
wget https://storage.googleapis.com/golang/$PACKAGE_NAME -O "$TEMP_DIRECTORY/go.tar.gz" | ||
else | ||
curl -o "$TEMP_DIRECTORY/go.tar.gz" https://storage.googleapis.com/golang/$PACKAGE_NAME | ||
fi | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Download failed! Exiting." | ||
exit 1 | ||
fi | ||
|
||
echo "Extracting File..." | ||
|
||
# sudo chown -R $USER: $HOME # https://github.com/golang/go/issues/27187 | ||
mkdir -p "$GOROOT" | ||
|
||
tar -C "$GOROOT" --strip-components=1 -xzf "$TEMP_DIRECTORY/go.tar.gz" | ||
|
||
# GOROOT=${GOROOT} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we dont need this commented out code then we can remove it |
||
# PATH=$GOROOT/bin:$PATH | ||
# GOPATH=$GOPATH | ||
# PATH=$GOPATH:$PATH | ||
|
||
mkdir -p "${GOPATH}/"{src,pkg,bin} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is pretty cool, didn't know you could do this!! 💯 |
||
echo -e "\nGo $VERSION was installed into $GOROOT.\nMake sure to relogin into your shell or run:" | ||
echo -e "\n\ restart script to update your environment variables." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need them to restart the script to update the environment vars? we can just do |
||
echo "Tip: Opening a new terminal window usually just works. :)" | ||
rm -f "$TEMP_DIRECTORY/go.tar.gz" | ||
} | ||
|
||
# Once we have Golang; finish the install processes inside the development directory to avoid errors (Glide) | ||
function cloneIntoDir() { | ||
echo "Setting up Kelp folders in the Golang working directory" | ||
|
||
# check github.com/stellar/kelp | ||
if [ -d "$GOPATH/github.com/stellar/kelp" ]; then | ||
echo "Kelp dir exists, no need to clone." | ||
else | ||
# pwd | ||
mkdir -p $GOPATH/github.com/stellar/kelp | ||
echo "Cloning Kelp into $GOPATH/src/github.com/stellar/kelp" | ||
git clone https://github.com/stellar/kelp.git $GOPATH/src/github.com/stellar/kelp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that |
||
fi | ||
|
||
cd $GOPATH/src/github.com/stellar/kelp | ||
} | ||
|
||
# After Golang install Glide | ||
function installGlide() { | ||
echo "Installing Glide." | ||
if curl --version; then | ||
curl https://glide.sh/get | sh | ||
elif wget --version; then | ||
wget https://glide.sh/get | sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this won't work because |
||
else | ||
echo "curl and wget are not available, install glide manually https://github.com/Masterminds/glide" | ||
exit | ||
fi | ||
|
||
glide install | ||
} | ||
|
||
# After Glide install Astilectron | ||
function installAstilectron() { | ||
go get -u github.com/asticode/go-astilectron-bundler/... | ||
go install github.com/asticode/go-astilectron-bundler/astilectron-bundler | ||
} | ||
|
||
function postGoInstall() { | ||
cloneIntoDir | ||
isGlide | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to invoke |
||
installAstilectron | ||
|
||
checkDeps | ||
echo "Remember, PostgreSQL must be running to store data." | ||
echo "Remember, Docker and CCXT must be configured for the expanded set of priceFeeds and orderbooks." | ||
echo "Run everything related to Kelp in BASH shell only." | ||
echo "All dependencies successfully installed. Run build script from $GOPATH/src/github.com/stellar/kelp/scripts/build.sh" | ||
} | ||
|
||
# Utility function for checking dependency statuses | ||
function checkDeps(){ | ||
isNode | ||
if [ $OK ]; then | ||
echo "Node `node -v` is installed" | ||
else | ||
echo "Node is not installed" | ||
fi | ||
|
||
isYarn | ||
if [ $OK ]; then | ||
echo "Yarn `yarn -v` is installed" | ||
else | ||
echo "Yarn is not installed" | ||
fi | ||
|
||
isGit | ||
if [ $OK ]; then | ||
echo "`git version` is installed" | ||
else | ||
echo "Git is not installed" | ||
fi | ||
|
||
isGo | ||
if $OK; then | ||
echo "`go version` is installed" | ||
else | ||
echo "Goland is not installed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should say Golang instead of Goland -- Goland is a Go-specific IDE so this can be confusing |
||
fi | ||
} | ||
|
||
|
||
#********************** | ||
# Execute the functions | ||
#********************** | ||
cd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a comment here why we are doing this |
||
|
||
isNode | ||
if [ $OK ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we can call Example:
Since we don't want to exit in the case where Golang does not exist, we can inline the go check logic from the |
||
echo "Node is installed on your machine." | ||
else | ||
echo "Node is not installed on your machine!" | ||
exit 1 | ||
fi | ||
|
||
isYarn | ||
if [ $OK ]; then | ||
echo "Yarn is installed on your machine." | ||
else | ||
echo "Yarn is not installed on your machine!" | ||
exit 1 | ||
fi | ||
|
||
isGit | ||
if [ $OK ]; then | ||
echo "Git is installed on your machine." | ||
else | ||
echo "Git is not installed on your machine!" | ||
exit 1 | ||
fi | ||
|
||
isGo | ||
if $OK; then | ||
echo "true for some reason" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this echo statement seems confusing. we don't need to echo anything here since we echo the go version below. |
||
else | ||
installGo | ||
echo "Finished installing Golang, now sourcing from .bashrc" | ||
source $HOME/.bashrc | ||
fi | ||
|
||
echo "Go version = $((go version))" | ||
postGoInstall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed that your script does cloning of the repo too -- I remember we had discussed this last time and how we can take advantage of that. that's super cool.
Can you add to your note here that for MacOS you don't need to clone the directory but can download the automated install script from here and that it will also clone the GitHub repo in the correct location -- and link to the script they should run.