forked from Chia-Network/chia-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-gui.sh
executable file
·106 lines (95 loc) · 3.19 KB
/
install-gui.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
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
set -e
if [ -z "$VIRTUAL_ENV" ]; then
echo "This requires the chia python virtual environment."
echo "Execute '. ./activate' before running."
exit 1
fi
if [ "$(id -u)" = 0 ]; then
echo "The Chia Blockchain GUI can not be installed or run by the root user."
exit 1
fi
# Allows overriding the branch or commit to build in chia-blockchain-gui
SUBMODULE_BRANCH=$1
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 libxss1
elif type yum && [ ! -f "/etc/redhat-release" ] && [ ! -f "/etc/centos-release" ] && [ ! -f /etc/rocky-release ]; then
# AMZN 2
echo "Installing on Amazon Linux 2."
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo yum install -y nodejs
elif type yum && [ ! -f /etc/rocky-release ] && [ -f /etc/redhat-release ] || [ -f /etc/centos-release ]; then
# CentOS or Redhat
echo "Installing on CentOS/Redhat."
curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
sudo yum install -y nodejs
elif type yum && [ -f /etc/rocky-release ]; then
# RockyLinux
echo "Installing on RockyLinux"
dnf module enable nodejs:12
sudo dnf install -y nodejs
elif type dnf && [ -f /etc/fedora-release ]; then
# Fedora
echo "Installing on Fedora"
sudo dnf 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
# For Mac and Windows, we will set up node.js on GitHub Actions and Azure
# Pipelines directly, so skip unless you are completing a source/developer install.
# Ubuntu special cases above.
if [ ! "$CI" ]; then
echo "Running git submodule update --init --recursive."
echo ""
git submodule update --init --recursive
echo "Running git submodule update."
echo ""
git submodule update
cd chia-blockchain-gui
if [ "$SUBMODULE_BRANCH" ];
then
git fetch
git checkout "$SUBMODULE_BRANCH"
git pull
echo ""
echo "Building the GUI with branch $SUBMODULE_BRANCH"
echo ""
fi
npm install
npm audit fix || true
npm run build
else
echo "Skipping node.js in install.sh on MacOS ci."
fi
echo ""
echo "Chia blockchain install-gui.sh completed."
echo ""
echo "Type 'cd chia-blockchain-gui' and then 'npm run electron &' to start the GUI."