Skip to content

Commit 28a5a37

Browse files
author
Yunshi Sun
authored
Merge pull request #54 from renproject/release/v3.0.7
v3.0.7
2 parents 13eafa8 + 3cf9c47 commit 28a5a37

18 files changed

Lines changed: 292 additions & 167 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ commands:
3232
wget https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
3333
tar xvzf ghr_v0.13.0_linux_amd64.tar.gz
3434
mv ghr_v0.13.0_linux_amd64/ghr ghr
35-
./ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete $(cat ./VERSION) ./artifacts/
35+
./ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -soft $(cat ./VERSION) ./artifacts/
3636
3737
test_env:
3838
description: "Push the binaries to aws s3, so that we can test before releasing."

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.6
1+
3.0.7

cmd/down.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ func (s status) err() string {
5656
func destroyNode(ctx *cli.Context) error {
5757
force := ctx.Bool("force")
5858
name := ctx.Args().First()
59+
if err := util.ValidateNodeName(name); err != nil {
60+
return err
61+
}
5962
path := util.NodePath(name)
6063

6164
// Check node current registration status.
@@ -95,6 +98,9 @@ func destroyNode(ctx *cli.Context) error {
9598
// Withdraw ETH and REN in the darknode address to the provided receiver address
9699
func withdraw(ctx *cli.Context) error {
97100
name := ctx.Args().First()
101+
if err := util.ValidateNodeName(name); err != nil {
102+
return err
103+
}
98104
withdrawAddress := ctx.String("address")
99105

100106
// Validate the name and received ethereum address

cmd/flag.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ var (
3636
Name: "force, f",
3737
Usage: "Force destruction without interactive prompts",
3838
}
39+
VersionFlag = cli.StringFlag{
40+
Name: "version",
41+
Usage: "Version of darknode you want to upgrade to",
42+
}
3943
)
4044

4145
// AWS flags

cmd/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func main() {
6868
{
6969
Name: "update",
7070
Usage: "Update your Darknodes to the latest software and configuration",
71-
Flags: []cli.Flag{TagsFlag},
71+
Flags: []cli.Flag{TagsFlag, VersionFlag},
7272
Action: func(c *cli.Context) error {
7373
return updateNode(c)
7474
},
@@ -79,6 +79,9 @@ func main() {
7979
Usage: "SSH into one of your Darknode",
8080
Action: func(c *cli.Context) error {
8181
name := c.Args().First()
82+
if err := util.ValidateNodeName(name); err != nil {
83+
return err
84+
}
8285
ip, err := util.IP(name)
8386
if err != nil {
8487
return err

cmd/provider/aws.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func (p providerAws) Deploy(ctx *cli.Context) error {
6767
name := ctx.String("name")
6868
tags := ctx.String("tags")
6969

70+
latestVersion, err := util.LatestReleaseVersion()
71+
if err != nil {
72+
return err
73+
}
7074
region, instance, err := p.validateRegionAndInstance(ctx)
7175
if err != nil {
7276
return err
@@ -82,7 +86,7 @@ func (p providerAws) Deploy(ctx *cli.Context) error {
8286
}
8387

8488
// Generate terraform config and start deploying
85-
if err := p.tfConfig(name, region, instance, ipfsUrl(network)); err != nil {
89+
if err := p.tfConfig(name, region, instance, latestVersion); err != nil {
8690
return err
8791
}
8892
if err := runTerraform(name); err != nil {

cmd/provider/aws_template.go

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,31 @@ import (
1010
)
1111

1212
type awsTerraform struct {
13-
Name string
14-
Region string
15-
InstanceType string
16-
ConfigPath string
17-
PubKeyPath string
18-
PriKeyPath string
19-
AccessKey string
20-
SecretKey string
21-
IPFS string
13+
Name string
14+
Region string
15+
InstanceType string
16+
ConfigPath string
17+
PubKeyPath string
18+
PriKeyPath string
19+
AccessKey string
20+
SecretKey string
21+
ServiceFile string
22+
LatestVersion string
2223
}
2324

2425
// tfConfig generates the terraform config file for deploying to AWS.
25-
func (p providerAws) tfConfig(name, region, instance, ipfs string) error {
26+
func (p providerAws) tfConfig(name, region, instance, latestVersion string) error {
2627
tf := awsTerraform{
27-
Name: name,
28-
Region: region,
29-
InstanceType: instance,
30-
ConfigPath: fmt.Sprintf("~/.darknode/darknodes/%v/config.json", name),
31-
PubKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair.pub", name),
32-
PriKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair", name),
33-
AccessKey: p.accessKey,
34-
SecretKey: p.secretKey,
35-
IPFS: ipfs,
28+
Name: name,
29+
Region: region,
30+
InstanceType: instance,
31+
ConfigPath: fmt.Sprintf("~/.darknode/darknodes/%v/config.json", name),
32+
PubKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair.pub", name),
33+
PriKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair", name),
34+
AccessKey: p.accessKey,
35+
SecretKey: p.secretKey,
36+
ServiceFile: darknodeService,
37+
LatestVersion: latestVersion,
3638
}
3739

3840
t, err := template.New("aws").Parse(awsTemplate)
@@ -156,12 +158,20 @@ resource "aws_instance" "darknode" {
156158
provisioner "remote-exec" {
157159
158160
inline = [
159-
"wget -O darknode.gz {{.IPFS}}",
160-
"tar -zxvf darknode.gz",
161-
"mkdir -p $HOME/.darknode",
161+
"set -x",
162+
"mkdir -p $HOME/.darknode/bin",
163+
"mkdir -p $HOME/.config/systemd/user",
162164
"mv $HOME/config.json $HOME/.darknode/config.json",
163-
"./install.sh",
164-
"rm -r darknode.gz bin config install.sh",
165+
"curl -sL https://www.github.com/renproject/darknode-release/releases/latest/download/darknode > ~/.darknode/bin/darknode",
166+
"chmod +x ~/.darknode/bin/darknode",
167+
"echo {{.LatestVersion}} > ~/.darknode/version",
168+
<<EOT
169+
echo "{{.ServiceFile}}" > ~/.config/systemd/user/darknode.service
170+
EOT
171+
,
172+
"loginctl enable-linger darknode",
173+
"systemctl --user enable darknode.service",
174+
"systemctl --user start darknode.service",
165175
]
166176
167177
connection {

cmd/provider/do.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ func (p providerDo) Deploy(ctx *cli.Context) error {
3333
name := ctx.String("name")
3434
tags := ctx.String("tags")
3535

36+
latestVersion, err := util.LatestReleaseVersion()
37+
if err != nil {
38+
return err
39+
}
3640
region, droplet, err := validateRegionAndDroplet(ctx)
3741
if err != nil {
3842
return err
3943
}
44+
45+
// Initialization
4046
network, err := darknode.NewNetwork(ctx.String("network"))
4147
if err != nil {
4248
return err
@@ -46,7 +52,7 @@ func (p providerDo) Deploy(ctx *cli.Context) error {
4652
}
4753

4854
// Generate terraform config and start deploying
49-
if err := p.tfConfig(name, region, droplet, ipfsUrl(network)); err != nil {
55+
if err := p.tfConfig(name, region, droplet, latestVersion); err != nil {
5056
return err
5157
}
5258
if err := runTerraform(name); err != nil {

cmd/provider/do_template.go

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,28 @@ import (
1010
)
1111

1212
type doTerraform struct {
13-
Name string
14-
Token string
15-
Region string
16-
Size string
17-
ConfigPath string
18-
PubKeyPath string
19-
PriKeyPath string
20-
IPFS string
13+
Name string
14+
Token string
15+
Region string
16+
Size string
17+
ConfigPath string
18+
PubKeyPath string
19+
PriKeyPath string
20+
ServiceFile string
21+
LatestVersion string
2122
}
2223

23-
func (p providerDo) tfConfig(name, region, droplet, ipfs string) error {
24+
func (p providerDo) tfConfig(name, region, droplet, latestVersion string) error {
2425
tf := doTerraform{
25-
Name: name,
26-
Token: p.token,
27-
Region: region,
28-
Size: droplet,
29-
ConfigPath: fmt.Sprintf("~/.darknode/darknodes/%v/config.json", name),
30-
PubKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair.pub", name),
31-
PriKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair", name),
32-
IPFS: ipfs,
26+
Name: name,
27+
Token: p.token,
28+
Region: region,
29+
Size: droplet,
30+
ConfigPath: fmt.Sprintf("~/.darknode/darknodes/%v/config.json", name),
31+
PubKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair.pub", name),
32+
PriKeyPath: fmt.Sprintf("~/.darknode/darknodes/%v/ssh_keypair", name),
33+
ServiceFile: darknodeService,
34+
LatestVersion: latestVersion,
3335
}
3436

3537
t, err := template.New("do").Parse(doTemplate)
@@ -107,12 +109,20 @@ resource "digitalocean_droplet" "darknode" {
107109
provisioner "remote-exec" {
108110
109111
inline = [
110-
"wget -O darknode.gz {{.IPFS}}",
111-
"tar -zxvf darknode.gz",
112-
"mkdir -p $HOME/.darknode",
112+
"set -x",
113+
"mkdir -p $HOME/.darknode/bin",
114+
"mkdir -p $HOME/.config/systemd/user",
113115
"mv $HOME/config.json $HOME/.darknode/config.json",
114-
"./install.sh",
115-
"rm -r darknode.gz bin config install.sh",
116+
"curl -sL https://www.github.com/renproject/darknode-release/releases/latest/download/darknode > ~/.darknode/bin/darknode",
117+
"chmod +x ~/.darknode/bin/darknode",
118+
"echo {{.LatestVersion}} > ~/.darknode/version",
119+
<<EOT
120+
echo "{{.ServiceFile}}" > ~/.config/systemd/user/darknode.service
121+
EOT
122+
,
123+
"loginctl enable-linger darknode",
124+
"systemctl --user enable darknode.service",
125+
"systemctl --user start darknode.service",
116126
]
117127
118128
connection {

cmd/provider/gcp.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/renproject/darknode-cli/darknode"
14+
"github.com/renproject/darknode-cli/util"
1415
"github.com/urfave/cli"
1516
"golang.org/x/oauth2/google"
1617
"google.golang.org/api/cloudresourcemanager/v1"
@@ -70,6 +71,10 @@ func (p providerGcp) Deploy(ctx *cli.Context) error {
7071
name := ctx.String("name")
7172
tags := ctx.String("tags")
7273

74+
latestVersion, err := util.LatestReleaseVersion()
75+
if err != nil {
76+
return err
77+
}
7378
projectID, err := p.projectID()
7479
if err != nil {
7580
return err
@@ -89,7 +94,7 @@ func (p providerGcp) Deploy(ctx *cli.Context) error {
8994
}
9095

9196
// Generate terraform config and start deploying
92-
if err := p.tfConfig(name, projectID, zone, machine, ipfsUrl(network)); err != nil {
97+
if err := p.tfConfig(name, projectID, zone, machine, latestVersion); err != nil {
9398
return err
9499
}
95100
if err := runTerraform(name); err != nil {

0 commit comments

Comments
 (0)