-
Notifications
You must be signed in to change notification settings - Fork 1
/
vagrant-provision.sh
80 lines (61 loc) · 1.82 KB
/
vagrant-provision.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
#/bin/bash
LINE_PREFIX="microeth"
cd /root
# Sanity check
if [ ! -d /home/vagrant ]; then
echo "$LINE_PREFIX: Environment sanity check failed. This script should only be run on guests."
exit 1
fi
# Install system utilities
echo "$LINE_PREFIX: Installing system utilities..."
apt -y update
apt -y install net-tools locate
# Setup build environment
echo "$LINE_PREFIX: Setting up build environment..."
apt -y install build-essential
# Install node
echo "$LINE_PREFIX: Installing node..."
# https://github.com/nodesource/distributions/blob/master/README.md
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt install -y nodejs
#which node || exit 1
#which npm || exit 1
# Install solhint
echo "$LINE_PREFIX: Installing solhint..."
npm install -g solhint
# Install solc
echo "$LINE_PREFIX: Installing solc..."
# From: https://github.com/ethereum/solidity/releases
SOLC_VERSION=0.8.9
pushd /usr/local/bin
wget -O solc-$SOLC_VERSION "https://github.com/ethereum/solidity/releases/download/v$SOLC_VERSION/solc-static-linux"
chmod +x solc-$SOLC_VERSION
if [ -f solc ]; then
unlink solc
fi
ln -s solc-$SOLC_VERSION solc
popd
# Add jump to project folder upon login (for dev.sh)
echo "$LINE_PREFIX: Adding project jump..."
echo 'cd ~/project' >> /root/.profile
echo '' >> /root/.profile
# Add "hardhat" command alias
echo "$LINE_PREFIX: Adding hardhat alias..."
echo '' >> /root/.bashrc
echo 'alias hardhat="npx hardhat"' >> /root/.bashrc
echo '' >> /root/.bashrc
# Initialize project
echo "$LINE_PREFIX: Initializing project..."
cd /root/project
if [ -f "package.json" ]; then
# Project already exists, install packages
echo "Project already exists, installing modules..."
rm -rf node_modules
npm install
fi
# Finalize install
echo "$LINE_PREFIX: finalizing installation..."
updatedb
# Success
echo "$LINE_PREFIX: Done."
exit 0