Skip to content

Commit

Permalink
Create new install-gui.sh and auto install Ubuntu OS deps
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmang9 committed Oct 1, 2020
1 parent f4cd269 commit da3a0af
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 61 deletions.
69 changes: 69 additions & 0 deletions install-gui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -e

echo "This requires the chia python virtual environment."
echo "Execute '. ./activate' if you have not already, before running."

UBUNTU=false
# Manage npm and other install requirements on an OS specific basis
if [ "$(uname)" = "Linux" ]; then
#LINUX=1
if type apt-get; then
# Debian/Ubuntu
UBUNTU=true
sudo apt-get install -y npm nodejs
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then
# AMZN 2
echo "Installing on Amazon Linux 2"
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install -y nodejs
elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
# CentOS or Redhat
echo "Installing on CentOS/Redhat"
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install -y nodejs
fi
elif [ "$(uname)" = "Darwin" ] && type brew && ! npm version>/dev/null 2>&1; then
# Install npm if not installed
brew install npm
elif [ "$(uname)" = "OpenBSD" ]; then
pkg_add node
elif [ "$(uname)" = "FreeBSD" ]; then
pkg install node
fi

# Ubuntu before 20.04LTS has an ancient node.js
echo ""
UBUNTU_PRE_2004=false
if $UBUNTU; then
UBUNTU_PRE_2004=$(python -c 'import subprocess; process = subprocess.run(["lsb_release", "-rs"], stdout=subprocess.PIPE); print(float(process.stdout) < float(20.04))')
fi

if [ "$UBUNTU_PRE_2004" = "True" ]; then
echo "Installing on Ubuntu older than 20.04 LTS: Ugrading node.js to stable"
UBUNTU_PRE_2004=true # Unfortunately Python returns True when shell expects true
sudo npm install -g n
sudo n stable
export PATH="$PATH"
fi

if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "False" ]; then
echo "Installing on Ubuntu 20.04 LTS or newer: Using installed node.js version"
fi

# We will set up node.js on GitHub Actions and Azure Pipelines directly
# for Mac and Windows so skip unless completing a source/developer install
# Ubuntu special cases above
if [ ! "$CI" ]; then
cd ./electron-react
npm install
npm audit fix
npm run build
else
echo "Skipping node.js in install.sh on MacOS ci"
fi

echo ""
echo "Chia blockchain install-gui.sh complete."
echo ""
echo "Type 'cd electron-react' and then 'npm run electron &' to start the GUI"
104 changes: 43 additions & 61 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,39 @@
#!/bin/bash
set -e
UBUNTU=false
if [ "$(uname)" = "Linux" ]; then
#LINUX=1
if type apt-get; then
UBUNTU=true
fi
fi

find_python() {
set +e
unset BEST_VERSION
for V in 37 3.7 38 3.8 3
do
if which python$V > /dev/null
then
if [ x"$BEST_VERSION" = x ]
then
BEST_VERSION=$V
fi
fi
done
echo $BEST_VERSION
set -e
}

if [ x"$INSTALL_PYTHON_VERSION" = x ]
then
INSTALL_PYTHON_VERSION=$(find_python)
UBUNTU_PRE_2004=false
if $UBUNTU; then
LSB_RELEASE=$(lsb_release -rs)
UBUNTU_PRE_2004=$(echo "$LSB_RELEASE<20.04" | bc)
fi

UBUNTU=false
# Manage npm and other install requirements on an OS specific basis
if [ "$(uname)" = "Linux" ]; then
#LINUX=1
if type apt-get; then
if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "1" ]; then
# Debian/Ubuntu
UBUNTU=true
sudo apt-get install -y npm nodejs
echo "Installing on Ubuntu/Debian pre 20.04 LTS"
sudo apt-get update
sudo apt-get install -y python3.7-venv python3.7-distutils
elif [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "0" ]; then
echo "Installing on Ubuntu/Debian 20.04 LTS or newer"
sudo apt-get update
sudo apt-get install -y python3.8-venv python3.8-distutils
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ]; then
# AMZN 2
echo "Installing on Amazon Linux 2"
sudo yum install -y python3 git
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install -y nodejs
elif type yum && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
# CentOS or Redhat
echo "Installing on CentOS/Redhat"
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install -y nodejs
fi
elif [ "$(uname)" = "Darwin" ] && type brew && ! npm version>/dev/null 2>&1; then
# Install npm if not installed
brew install npm
elif [ "$(uname)" = "Darwin" ] && ! type brew >/dev/null 2>&1; then
echo "Installation currently requires brew on MacOS - https://brew.sh/"
elif [ "$(uname)" = "OpenBSD" ]; then
Expand All @@ -56,6 +44,28 @@ elif [ "$(uname)" = "FreeBSD" ]; then
export BUILD_VDF_CLIENT=${BUILD_VDF_CLIENT:-N}
fi

find_python() {
set +e
unset BEST_VERSION
for V in 37 3.7 38 3.8 3
do
if which python$V > /dev/null
then
if [ x"$BEST_VERSION" = x ]
then
BEST_VERSION=$V
fi
fi
done
echo $BEST_VERSION
set -e
}

if [ x"$INSTALL_PYTHON_VERSION" = x ]
then
INSTALL_PYTHON_VERSION=$(find_python)
fi

# this fancy syntax sets INSTALL_PYTHON_PATH to "python3.7" unless INSTALL_PYTHON_VERSION is defined
# if INSTALL_PYTHON_VERSION=3.8, then INSTALL_PYTHON_PATH becomes python3.8

Expand All @@ -77,36 +87,6 @@ pip install wheel
pip install --extra-index-url https://download.chia.net/simple/ miniupnpc==2.1 setproctitle==1.1.10 cbor2==5.1.2
pip install -e .

# Ubuntu before 20.04LTS has an ancient node.js
echo ""
UBUNTU_PRE_2004=false
if $UBUNTU; then
UBUNTU_PRE_2004=$(python -c 'import subprocess; process = subprocess.run(["lsb_release", "-rs"], stdout=subprocess.PIPE); print(float(process.stdout) < float(20.04))')
fi

if [ "$UBUNTU_PRE_2004" = "True" ]; then
echo "Installing on Ubuntu older than 20.04 LTS: Ugrading node.js to stable"
UBUNTU_PRE_2004=true # Unfortunately Python returns True when shell expects true
sudo npm install -g n
sudo n stable
export PATH="$PATH"
fi

if [ "$UBUNTU" = "true" ] && [ "$UBUNTU_PRE_2004" = "False" ]; then
echo "Installing on Ubuntu 20.04 LTS or newer: Using installed node.js version"
fi

# We will set up node.js on GitHub Actions and Azure Pipelines directly
# for Mac and Windows so skip unless completing a source/developer install
# Ubuntu special cases above
if [ ! "$CI" ]; then
cd ./electron-react
npm install
npm audit fix
else
echo "Skipping node.js in install.sh on MacOS ci"
fi

echo ""
echo "Chia blockchain install.sh complete."
echo "For assistance join us on Keybase in the #testnet chat channel"
Expand All @@ -115,4 +95,6 @@ echo ""
echo "Try the Quick Start Guide to running chia-blockchain"
echo "https://github.com/Chia-Network/chia-blockchain/wiki/Quick-Start-Guide"
echo ""
echo "To install the GUI type 'sh install-gui.sh' after '. ./activate'"
echo ""
echo "Type '. ./activate' and then 'chia init' to begin"

0 comments on commit da3a0af

Please sign in to comment.