mirror of
https://github.com/octoleo/syncthing.git
synced 2024-10-10 06:57:56 +00:00
Build script
This commit is contained in:
parent
7d235a454d
commit
8e65d36691
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
syncthing
|
||||
*.tar.gz
|
||||
|
16
build.sh
Executable file
16
build.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
version=$(git describe --always)
|
||||
|
||||
for goos in darwin linux freebsd ; do
|
||||
for goarch in amd64 386 ; do
|
||||
export GOOS="$goos"
|
||||
export GOARCH="$goarch"
|
||||
go build -ldflags "-X main.Version $version" \
|
||||
&& mkdir -p "syncthing-$goos-$goarch" \
|
||||
&& mv syncthing "syncthing-$goos-$goarch" \
|
||||
&& cp syncthing.ini "syncthing-$goos-$goarch" \
|
||||
&& tar zcf "syncthing-$goos-$goarch.tar.gz" "syncthing-$goos-$goarch" \
|
||||
&& rm -r "syncthing-$goos-$goarch"
|
||||
done
|
||||
done
|
12
main.go
12
main.go
@ -39,6 +39,7 @@ type DebugOptions struct {
|
||||
}
|
||||
|
||||
var opts Options
|
||||
var Version string
|
||||
|
||||
const (
|
||||
confDirName = ".syncthing"
|
||||
@ -67,9 +68,11 @@ func main() {
|
||||
opts.ConfDir = strings.Replace(opts.ConfDir, "~", getHomeDir(), 1)
|
||||
}
|
||||
|
||||
infoln("Version", Version)
|
||||
|
||||
// Ensure that our home directory exists and that we have a certificate and key.
|
||||
|
||||
ensureDir(ConfDir)
|
||||
ensureDir(ConfDir, 0700)
|
||||
cert, err := loadCert(ConfDir)
|
||||
if err != nil {
|
||||
newCertificate(ConfDir)
|
||||
@ -120,6 +123,7 @@ func main() {
|
||||
nodeAddrs[nodeID] = addrs
|
||||
}
|
||||
|
||||
ensureDir(dir, -1)
|
||||
m := NewModel(dir)
|
||||
|
||||
// Walk the repository and update the local model before establishing any
|
||||
@ -304,13 +308,13 @@ func loadIndex(m *Model) {
|
||||
m.SeedIndex(idx)
|
||||
}
|
||||
|
||||
func ensureDir(dir string) {
|
||||
func ensureDir(dir string, mode int) {
|
||||
fi, err := os.Stat(dir)
|
||||
if os.IsNotExist(err) {
|
||||
err := os.MkdirAll(dir, 0700)
|
||||
fatalErr(err)
|
||||
} else if fi.Mode()&0077 != 0 {
|
||||
err := os.Chmod(dir, 0700)
|
||||
} else if mode >= 0 && err == nil && int(fi.Mode()&0777) != mode {
|
||||
err := os.Chmod(dir, os.FileMode(mode))
|
||||
fatalErr(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user