Skip to content

Commit

Permalink
Merge branch 'master' into feat/CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tok-kkk committed Oct 22, 2020
2 parents d235ca3 + 2417a37 commit 755ab42
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ commands:
- run:
name: Publish release to github
command: |
wget https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
wget https://www.github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
tar xvzf ghr_v0.13.0_linux_amd64.tar.gz
mv ghr_v0.13.0_linux_amd64/ghr ghr
./ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -soft $(cat ./VERSION) ./artifacts/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To jump straight into running your first Darknode on AWS, checkout our [Getting

## Getting Started on Digital Ocean

Checkout the instructions for [Creating a Personal Access Token](https://github.com/renproject/darknode-cli#digital-ocean) on Digital Ocean.
Checkout the instructions for [Creating a Personal Access Token](https://www.github.com/renproject/darknode-cli#digital-ocean) on Digital Ocean.


## Installing the tool
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.13
3.0.14
6 changes: 3 additions & 3 deletions cmd/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ var (
Name: "version",
Usage: "Version of darknode you want to upgrade to",
}
DowngradeFlag = cli.BoolFlag{
Name: "downgrade",
Usage: "Force downgrading to an older version without interactive prompts",
ForceUpdateFlag = cli.BoolFlag{
Name: "force, f",
Usage: "Force updating to an older version without interactive prompts",
}
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func main() {
{
Name: "update",
Usage: "Update your Darknodes to the latest software and configuration",
Flags: []cli.Flag{TagsFlag, VersionFlag, DowngradeFlag},
Flags: []cli.Flag{TagsFlag, VersionFlag, ForceUpdateFlag},
Action: func(c *cli.Context) error {
return updateNode(c)
},
Expand Down
3 changes: 1 addition & 2 deletions cmd/provider/aws_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ resource "aws_instance" "darknode" {
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade",
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade",
"sudo DEBIAN_FRONTEND=noninteractive apt-get -y autoremove",
"sudo apt-get -y install jq",
"sudo apt-get install ufw",
"sudo ufw limit 22/tcp",
"sudo ufw allow 18514/tcp",
Expand Down Expand Up @@ -162,7 +161,7 @@ resource "aws_instance" "darknode" {
"mkdir -p $HOME/.darknode/bin",
"mkdir -p $HOME/.config/systemd/user",
"mv $HOME/config.json $HOME/.darknode/config.json",
"curl -sL https://www.github.com/renproject/darknode-release/releases/latest/download/darknode > ~/.darknode/bin/darknode",
"curl -sL https://www.github.com/renproject/darknode-release/releases/download/{{.LatestVersion}}/darknode > ~/.darknode/bin/darknode",
"chmod +x ~/.darknode/bin/darknode",
"echo {{.LatestVersion}} > ~/.darknode/version",
<<EOT
Expand Down
3 changes: 1 addition & 2 deletions cmd/provider/do_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ resource "digitalocean_droplet" "darknode" {
"sudo ufw allow 18514/tcp",
"sudo ufw allow 18515/tcp",
"sudo ufw --force enable",
"until sudo apt-get -y install jq; do sleep 4; done",
]
connection {
Expand Down Expand Up @@ -113,7 +112,7 @@ resource "digitalocean_droplet" "darknode" {
"mkdir -p $HOME/.darknode/bin",
"mkdir -p $HOME/.config/systemd/user",
"mv $HOME/config.json $HOME/.darknode/config.json",
"curl -sL https://www.github.com/renproject/darknode-release/releases/latest/download/darknode > ~/.darknode/bin/darknode",
"curl -sL https://www.github.com/renproject/darknode-release/releases/download/{{.LatestVersion}}/darknode > ~/.darknode/bin/darknode",
"chmod +x ~/.darknode/bin/darknode",
"echo {{.LatestVersion}} > ~/.darknode/version",
<<EOT
Expand Down
3 changes: 1 addition & 2 deletions cmd/provider/gcp_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ resource "google_compute_instance" "darknode" {
"sudo ufw allow 18514/tcp",
"sudo ufw allow 18515/tcp",
"sudo ufw --force enable",
"until sudo apt-get -y install jq; do sleep 4; done",
]
connection {
Expand Down Expand Up @@ -159,7 +158,7 @@ resource "google_compute_instance" "darknode" {
"mkdir -p $HOME/.darknode/bin",
"mkdir -p $HOME/.config/systemd/user",
"mv $HOME/config.json $HOME/.darknode/config.json",
"curl -sL https://www.github.com/renproject/darknode-release/releases/latest/download/darknode > ~/.darknode/bin/darknode",
"curl -sL https://www.github.com/renproject/darknode-release/releases/download/{{.LatestVersion}}/darknode > ~/.darknode/bin/darknode",
"chmod +x ~/.darknode/bin/darknode",
"echo {{.LatestVersion}} > ~/.darknode/version",
<<EOT
Expand Down
22 changes: 13 additions & 9 deletions cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
func updateNode(ctx *cli.Context) error {
name := ctx.Args().First()
tags := ctx.String("tags")
force := ctx.Bool("downgrade")
force := ctx.Bool("force")
version := strings.TrimSpace(ctx.String("version"))
nodes, err := util.ParseNodesFromNameAndTags(name, tags)
if err != nil {
Expand Down Expand Up @@ -60,7 +60,15 @@ func updateSingleNode(name, ver string, force bool) error {
res := curVersion.Compare(newVersion)
switch res {
case 0:
color.Green("darknode [%v] is running version [%v] already.", name, ver)
if !force {
color.Green("darknode [%v] is running version [%v] already.", name, ver)
return nil
}
if err := update(name, ver); err != nil {
color.Red("cannot update darknode %v, error = %v", name, err)
} else {
color.Green("[%s] has been updated to version %v", name, ver)
}
case 1:
if !force {
color.Red("darknode [%v] is running with version %v, you cannot downgrade to a lower version %v", name, curVersion.String(), newVersion.String())
Expand All @@ -82,14 +90,10 @@ func updateSingleNode(name, ver string, force bool) error {
}

func update(name, ver string) error {
url := fmt.Sprintf("https://github.com/renproject/darknode-release/releases/download/%v", ver)
script := fmt.Sprintf(`mv ~/.darknode/bin/darknode ~/.darknode/bin/darknode-backup &&
curl -sL %v/darknode > ~/.darknode/bin/darknode &&
url := fmt.Sprintf("https://www.github.com/renproject/darknode-release/releases/download/%v", ver)
script := fmt.Sprintf(`curl -sL %v/darknode > ~/.darknode/bin/darknode-new &&
mv ~/.darknode/bin/darknode-new ~/.darknode/bin/darknode &&
chmod +x ~/.darknode/bin/darknode &&
systemctl --user stop darknode &&
cp -a ~/.darknode/db/. ~/.darknode/db_bak/ &&
rm -rf ~/.darknode/db &&
mv ~/.darknode/db_bak ~/.darknode/db &&
echo %v > ~/.darknode/version &&
systemctl --user restart darknode`, url, ver)
return util.RemoteRun(name, script)
Expand Down

0 comments on commit 755ab42

Please sign in to comment.