-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhk2go.sh
More file actions
85 lines (71 loc) · 2.09 KB
/
hk2go.sh
File metadata and controls
85 lines (71 loc) · 2.09 KB
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
#!/bin/bash
#stop IRI
sudo service iota stop
#On an existing ubuntu 16.04 server:
#pre-empt interactive promps:
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get -qy update
sudo -E apt-get -qy -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade
sudo -E apt-get -qy autoclean
sudo apt install make
sudo apt-get -y install gcc
#download Go
sudo curl -O https://storage.googleapis.com/golang/go1.9.3.linux-amd64.tar.gz
sudo tar -xvf go1.9.3.linux-amd64.tar.gz
sudo mv go /usr/local/go
sudo rm go1.9.3.linux-amd64.tar.gz
#set env
echo "export GOROOT=/usr/local/go" >> ~/.profile
echo "export GOPATH=/home/ubuntu/go" >> ~/.profile
echo "export PATH=$GOPATH/bin:$GOROOT/bin:$PATH/" >> ~/.profile
source ~/.profile
#until that works, we can do this:
export GOROOT=/usr/local/go
export GOPATH=/home/ubuntu/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH/
#fix permissions#1
sudo chmod -R 774 /home/ubuntu
sudo chown -R ubuntu /home/ubuntu
#Pull repo
sudo mkdir -p /home/ubuntu/go/src/github.com/oysterprotocol
cd /home/ubuntu/go/src/github.com/oysterprotocol
sudo git clone https://github.com/oysterprotocol/hooknode.git
cd hooknode
#fix permissions#2
sudo chmod -R 774 /home/ubuntu/go
sudo chown -R ubuntu /home/ubuntu
# Setup ENV variables
sudo cp .env.example .env
#install dependencies for server
make install-deps
#make executable
go build -o ./bin/main.go
#setup systemd service
cat <<EOF | sudo tee /lib/systemd/system/hooknode.service
[Unit]
Description=Oyster Hooknode in Golang
After=network.target
[Service]
WorkingDirectory=/home/ubuntu/go/src/github.com/oysterprotocol/hooknode
User=ubuntu
PrivateDevices=yes
ProtectSystem=full
Type=simple
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGTERM
TimeoutStopSec=60
ExecStart=/home/ubuntu/go/src/github.com/oysterprotocol/hooknode/./bin/main
SyslogIdentifier=hooknode
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target
Alias=hooknode.service
EOF
#start service
sudo service hooknode start
sudo systemctl start hooknode.service
sudo systemctl enable hooknode.service
#start iota again
sudo service iota start