Skip to content

Update systray library and make sure the Agent works on all OS #553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c68da6e
Update systray module to getlantern original mainstrem repo
Jan 13, 2020
de1b277
add updated dependency for golang.org/x/sys/windows
Jan 13, 2020
ab3d9e5
Merge pull request #509 from arduino/rsora/systray-update-mainstream
Feb 4, 2020
18519ef
Add new icons for windows and linux
sebromero Mar 5, 2020
4874388
Reword menu items
sebromero Mar 5, 2020
1eecf2f
Use title case for menu items
sebromero Mar 6, 2020
631ad74
Add new icon files
sebromero Mar 19, 2020
223c38b
Add new icon go files
sebromero Mar 19, 2020
d081593
Enable quit in normal mode
sebromero Mar 19, 2020
c3b5435
Update Colors and fonts of console template
sebromero Mar 19, 2020
93addcb
Update spacing and styles of console template
sebromero Mar 20, 2020
407dc64
Add fluid layout
sebromero Mar 20, 2020
f2435fa
Merge console template into go file
sebromero Mar 20, 2020
0ac2cc9
Fix visual alignment of buttons
sebromero Mar 22, 2020
fdd7783
Add clear log function
sebromero Mar 22, 2020
eb1b80c
Merge console template into go file
sebromero Mar 22, 2020
f3fac83
Fix incorrect hibernate icon
sebromero Mar 22, 2020
28e2a95
Satisfy linter
sebromero Mar 22, 2020
98bc4c8
Merge pull request #538 from sbhklr/sbhklr/ux-improvements
Mar 23, 2020
5b34d40
Create manifest for windows and add instructions
matteosuppo Mar 30, 2020
dda98a2
Merge pull request #543 from arduino/manifest
matteosuppo Mar 30, 2020
caffd81
Refactor systray
matteosuppo Mar 31, 2020
d9c50f7
Add comment about systray_fake
matteosuppo Apr 1, 2020
f973044
Merge pull request #544 from arduino/refactor_systray
matteosuppo Apr 1, 2020
bc773b8
Remove vendor folder and use go modules
matteosuppo Apr 1, 2020
b0b3b31
Merge pull request #546 from arduino/mod
matteosuppo Apr 1, 2020
a23bd53
Ensure the path is always trimmed
matteosuppo Apr 6, 2020
1213508
Three card trick
matteosuppo Apr 8, 2020
36dcef5
prevent bad errors on osx
matteosuppo Apr 8, 2020
7f3e25a
Refactor: extract copyExe func
matteosuppo Apr 14, 2020
fd8b606
refactor: extract TempPath and BinPath funcs
matteosuppo Apr 14, 2020
6db5ade
Merge pull request #551 from arduino/autoupdate
matteosuppo Apr 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Three card trick
  • Loading branch information
matteosuppo committed Apr 8, 2020
commit 121350816c513ed59b2169a19eee976e09b88d15
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ github.com/codeclysm/extract v2.0.0+incompatible/go.mod h1:2nhFMPHiU9At61hz+12bf
github.com/creack/goselect v0.0.0-20180501195510-58854f77ee8d h1:6o8WW5zZ+Ny9sbk69epnAPmBzrBaRnvci+l4+pqleeY=
github.com/creack/goselect v0.0.0-20180501195510-58854f77ee8d/go.mod h1:gHrIcH/9UZDn2qgeTUeW5K9eZsVYCH6/60J/FHysWyE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidmz/go-pageant v1.0.1/go.mod h1:WWOKE/93DhgsPq15jaipH4fVY+MLKKWH4Yku5Ei92rE=
github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 h1:MGKhKyiYrvMDZsmLR/+RGffQSXwEkXgfLSA08qDn9AI=
github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598/go.mod h1:0FpDmbrt36utu8jEmeU05dPC9AB5tsLYVVi+ZHfyuwI=
github.com/dimfeld/httptreemux v5.0.1+incompatible h1:Qj3gVcDNoOthBAqftuD596rm4wg/adLLz5xh5CmpiCA=
github.com/dimfeld/httptreemux v5.0.1+incompatible/go.mod h1:rbUlSV+CCpv/SuqUTP/8Bk2O3LyUV436/yaRGkhP6Z0=
Expand Down Expand Up @@ -63,13 +65,15 @@ github.com/lxn/walk v0.0.0-20191113135339-bf589de20b3c/go.mod h1:E23UucZGqpuUANJ
github.com/lxn/walk v0.0.0-20191128110447-55ccb3a9f5c1/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
github.com/lxn/win v0.0.0-20191106123917-121afc750dd3/go.mod h1:ouWl4wViUNh8tPSIwxTVMuS014WakR1hqvBc2I0bMoA=
github.com/lxn/win v0.0.0-20191128105842-2da648fda5b4/go.mod h1:ouWl4wViUNh8tPSIwxTVMuS014WakR1hqvBc2I0bMoA=
github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d h1:Zj+PHjnhRYWBK6RqCDBcAhLXoi3TzC27Zad/Vn+gnVQ=
github.com/manveru/faker v0.0.0-20171103152722-9fbc68a78c4d/go.mod h1:WZy8Q5coAB1zhY9AOBJP0O6J4BuDfbupUDavKY+I3+s=
github.com/mattn/go-isatty v0.0.2-0.20170307163044-57fdcb988a5c h1:vNDTotKSxm/15mLGhBXjdU6q6Ncrx0HlVEd8ToAsGTw=
github.com/mattn/go-isatty v0.0.2-0.20170307163044-57fdcb988a5c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-shellwords v1.0.3 h1:K/VxK7SZ+cvuPgFSLKi5QPI9Vr/ipOf4C1gN+ntueUk=
github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o=
github.com/miekg/dns v1.0.15 h1:9+UupePBQCG6zf1q/bGmTO1vumoG13jsrbWOSX1W6Tw=
github.com/miekg/dns v1.0.15/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/oleksandr/bonjour v0.0.0-20160508152359-5dcf00d8b228 h1:Cvfd2dOlXIPTeEkOT/h8PyK4phBngOM4at9/jlgy7d4=
github.com/oleksandr/bonjour v0.0.0-20160508152359-5dcf00d8b228/go.mod h1:MGuVJ1+5TX1SCoO2Sx0eAnjpdRytYla2uC1YIZfkC9c=
Expand All @@ -80,6 +84,7 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.8.3 h1:9jSe2SxTM8/3bXZjtqnkgTBW+lA8db0knZJyns7gpBA=
github.com/pkg/sftp v1.8.3/go.mod h1:NxmoDg/QLVWluQDUYG7XBZTLUpKeFa8e3aMf1BfjyHk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sfreiberg/simplessh v0.0.0-20180301191542-495cbb862a9c h1:7Q+2oF0uBoLEV+j13E3/xUkPkI7f+sFNPZOPo2jmrWk=
Expand All @@ -91,11 +96,13 @@ github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c/go.mod h1:s
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/ugorji/go v0.0.0-20170215201144-c88ee250d022 h1:wIYK3i9zY6ZBcWw4GFvoPVwtb45iEm8KyOVmDhSLvsE=
github.com/ugorji/go v0.0.0-20170215201144-c88ee250d022/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/xrash/smetrics v0.0.0-20170218160415-a3153f7040e9 h1:w8V9v0qVympSF6GjdjIyeqR7+EVhAF9CBQmkmW7Zw0w=
github.com/xrash/smetrics v0.0.0-20170218160415-a3153f7040e9/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea h1:CyhwejzVGvZ3Q2PSbQ4NRRYn+ZWv5eS1vlaEusT+bAI=
github.com/zach-klippenstein/goregen v0.0.0-20160303162051-795b5e3961ea/go.mod h1:eNr558nEUjP8acGw8FFjTeWvSgU1stO7FAO6eknhHe4=
go.bug.st/downloader v0.0.0-20181116113543-9b8976a44d87 h1:8W/hwyrc25HrXxbtG8Ghiwgq/hDB8KCh7hKMf78gp90=
go.bug.st/downloader v0.0.0-20181116113543-9b8976a44d87/go.mod h1:OUL7bexo6Ir+BRE5E7Cs3qUvO6ZgJL5Hjk/qwiy6Ze0=
Expand Down
37 changes: 37 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"encoding/json"
"flag"
"io/ioutil"
"os"
"os/user"
"path/filepath"
Expand Down Expand Up @@ -118,6 +119,42 @@ func main() {
AdditionalConfig: *additionalConfig,
}

path, err := osext.Executable()
if err != nil {
panic(err)
}

// If the executable is temporary, copy it to the full path, then restart
if strings.Contains(path, "-temp") {
correctPath := strings.Replace(path, "-temp", "", -1)
data, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
err = ioutil.WriteFile(correctPath, data, 0755)
if err != nil {
panic(err)
}

Systray.Restart()
} else {
// Otherwise copy to a path with -temp suffix
correctPath := path
if filepath.Ext(path) == "exe" {
path = strings.Replace(path, ".exe", "-temp.exe", -1)
} else {
path = path + "-temp"
}
data, err := ioutil.ReadFile(correctPath)
if err != nil {
panic(err)
}
err = ioutil.WriteFile(path, data, 0755)
if err != nil {
panic(err)
}
}

Systray.Start()
}

Expand Down
9 changes: 9 additions & 0 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
package main

import (
"path/filepath"
"strings"

"github.com/arduino/arduino-create-agent/updater"
"github.com/gin-gonic/gin"
"github.com/kardianos/osext"
Expand Down Expand Up @@ -60,6 +63,12 @@ func updateHandler(c *gin.Context) {
return
}

if filepath.Ext(path) == "exe" {
path = strings.Replace(path, ".exe", "-temp.exe", -1)
} else {
path = path + "-temp"
}

c.JSON(200, gin.H{"success": "Please wait a moment while the agent reboots itself"})
Systray.Update(path)
}
8 changes: 8 additions & 0 deletions updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/kr/binarydist"
Expand Down Expand Up @@ -202,6 +203,12 @@ func (u *Updater) update() error {
if err != nil {
return err
}
if filepath.Ext(path) == "exe" {
path = strings.Replace(path, ".exe", "-temp.exe", -1)
} else {
path = path + "-temp"
}

old, err := os.Open(path)
if err != nil {
return err
Expand Down Expand Up @@ -241,6 +248,7 @@ func (u *Updater) update() error {
// it can't be renamed if a handle to the file is still open
old.Close()

up.TargetPath = path
err, errRecover := up.FromStream(bytes.NewBuffer(bin))
if errRecover != nil {
log.Errorf("update and recovery errors: %q %q", err, errRecover)
Expand Down