Skip to content

Commit

Permalink
adding service and deb installer
Browse files Browse the repository at this point in the history
  • Loading branch information
danny committed Apr 15, 2020
1 parent 9fc793c commit d572b55
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ gitmoo-goog.zip
199*


installer/installer
13 changes: 10 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ jobs:
# specify any bash command here prefixed with `run: `
- run: go test -v ./...
- run: GOOS=windows go build
- run: go build

- run: |
go build
cd installer
go build
./installer
- store_artifacts:
path: /go/src/github.com/dtylman/gitmoo-goog/gitmoo-goog

- store_artifacts:
path: /go/src/github.com/dtylman/gitmoo-goog/gitmoo-goog.exe
path: /go/src/github.com/dtylman/gitmoo-goog/gitmoo-goog.exe

- store_artifacts:
path: /go/src/github.com/dtylman/gitmoo-goog/installer/*.deb
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.12

require (
cloud.google.com/go v0.37.4 // indirect
github.com/dtylman/gopack v0.0.0-20191030095432-3a1a77a8b52c
github.com/dustin/go-humanize v1.0.0
github.com/fatih/gomodifytags v1.0.1 // indirect
github.com/fujiwara/shapeio v0.0.0-20170602072123-c073257dd745
Expand Down Expand Up @@ -31,8 +32,6 @@ require (
google.golang.org/appengine v1.6.2 // indirect
google.golang.org/genproto v0.0.0-20190916214212-f660b8655731 // indirect
google.golang.org/grpc v1.23.1 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.2.2 // indirect
honnef.co/go/tools v0.0.1-2019.2.3 // indirect
honnef.co/go/tools v0.0.1-2019.2.3
)
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4pJSv7WO+VECIWUQ7OJYSoTrMh4=
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb/go.mod h1:PkYb9DJNAwrSvRx5DYA+gUcOIgTGVMNkfSCbZM8cWpI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
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/dtylman/gopack v0.0.0-20191030095432-3a1a77a8b52c h1:9wYr8Ov2GBCr7y/jgguLcr9c7TwL4x8LahaOOAyBtWw=
github.com/dtylman/gopack v0.0.0-20191030095432-3a1a77a8b52c/go.mod h1:JzsIqAkSYGV8T5xLMbHJJ7xuN4DJNLzOLeVYQwFMdNs=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
Expand Down Expand Up @@ -106,6 +112,7 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
Expand All @@ -118,8 +125,11 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
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.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
Expand Down Expand Up @@ -271,10 +281,13 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
12 changes: 12 additions & 0 deletions installer/gitmoo-goog.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=gitmoo-goog

[Service]
Type=simple
Restart=always
RestartSec=30
ExecStart=/usr/local/bin/gitmoo-goog -folder /var/photos -loop
StandardOutput=journal

[Install]
WantedBy=multi-user.target
61 changes: 61 additions & 0 deletions installer/inst.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package main

import (
"fmt"
"os"

"github.com/dtylman/gitmoo-goog/version"
"github.com/dtylman/gopack/deb"
)

var options struct {
Name string
Arch string
Branch string
BuildNum string
MediaBin string
}

func init() {
options.Branch = os.Getenv("CIRCLE_BRANCH")
options.BuildNum = os.Getenv("CIRCLE_BUILD_NUM")
options.Arch = "amd64"
}

func createDeb() error {
if options.Branch != "" && options.Branch != "master" {
version.Version += "-" + options.Branch
}

d, err := deb.New(options.Name, version.Version, options.BuildNum, options.Arch)
if err != nil {
return err
}

d.Info.Maintainer = "[email protected]"
d.Info.Section = "base"
d.Info.Homepage = "https://github.com/dtylman/gitmoo-goog"
d.Info.Description = `A Google Photos backup tool. `
files := map[string]string{
"../gitmoo-goog": "/usr/local/bin/gitmoo-goog",
"gitmoo-goog.service": "/etc/systemd/system/gitmoo-goog.service",
}

for source, target := range files {
err = d.AddFile(source, target)
if err != nil {
return err
}
}

debFileName, err := d.Create("")
fmt.Println("Created " + debFileName)
return err
}

func main() {
err := createDeb()
if err != nil {
fmt.Println("Error creating deb: " + err.Error())
}
}
6 changes: 2 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ import (
"path/filepath"

"github.com/dtylman/gitmoo-goog/downloader"
"github.com/dtylman/gitmoo-goog/version"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
photoslibrary "google.golang.org/api/photoslibrary/v1"
"gopkg.in/natefinch/lumberjack.v2"
)

//Version is the version number
const Version = "0.23"

var options struct {
loop bool
logfile string
Expand Down Expand Up @@ -117,7 +115,7 @@ func process(downloader *downloader.Downloader) error {
func main() {
workingDirectory, _ := os.Getwd()
downloader := downloader.NewDownloader()
log.Println("This is gitmoo-goog ver", Version)
log.Println("This is gitmoo-goog ver", version.Version)
flag.BoolVar(&options.loop, "loop", false, "loops forever (use as daemon)")
flag.BoolVar(&options.ignoreerrors, "force", false, "ignore errors, and force working")
flag.StringVar(&options.logfile, "logfile", "", "log to this file")
Expand Down
4 changes: 4 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package version

//Version is the version number
var Version = "0.24"

0 comments on commit d572b55

Please sign in to comment.