set exec bits

This commit is contained in:
AJ ONeal 2019-08-01 01:47:59 -06:00
parent b3ddca4ae2
commit 860f852df9
1 changed files with 9 additions and 5 deletions

View File

@ -107,7 +107,7 @@ func main() {
nfile := fmt.Sprintf("%s.%s", npath, pkg.ext) nfile := fmt.Sprintf("%s.%s", npath, pkg.ext)
// TODO check remote filesize anyway as a quick sanity check // TODO check remote filesize anyway as a quick sanity check
nurl := fmt.Sprintf("https://nodejs.org/download/release/v%s/%s", nodev, nfile) nurl := fmt.Sprintf("https://nodejs.org/download/release/v%s/%s", nodev, nfile)
err = download("node package", nurl, nfile) err = download("node package", nurl, nfile, false)
if nil != err { if nil != err {
panic(err) panic(err)
} }
@ -168,7 +168,7 @@ func main() {
arch, arch,
) )
pathmanFile := filepath.Join(outdir, "bin", "pathman") + pkg.exe pathmanFile := filepath.Join(outdir, "bin", "pathman") + pkg.exe
err = download("pathman", pathmanURL, pathmanFile) err = download("pathman", pathmanURL, pathmanFile, true)
if nil != err { if nil != err {
panic(err) panic(err)
} }
@ -180,7 +180,7 @@ func main() {
arch, arch,
) )
servicemanFile := filepath.Join(outdir, "bin", "serviceman") + pkg.exe servicemanFile := filepath.Join(outdir, "bin", "serviceman") + pkg.exe
err = download("serviceman", servicemanURL, servicemanFile) err = download("serviceman", servicemanURL, servicemanFile, true)
if nil != err { if nil != err {
panic(err) panic(err)
} }
@ -189,7 +189,7 @@ func main() {
fmt.Printf("Done.\n") fmt.Printf("Done.\n")
} }
func download(title string, nurl string, nfile string) error { func download(title string, nurl string, nfile string, exec bool) error {
if _, err := os.Stat(nfile); nil == err { if _, err := os.Stat(nfile); nil == err {
return nil return nil
} }
@ -206,7 +206,11 @@ func download(title string, nurl string, nfile string) error {
// Stream it in locally // Stream it in locally
fmt.Printf("Streaming %s to %s\n", nurl, nfile) fmt.Printf("Streaming %s to %s\n", nurl, nfile)
nf, err := os.OpenFile(nfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) fmode := os.FileMode(0644)
if exec {
fmode = os.FileMode(0755)
}
nf, err := os.OpenFile(nfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, fmode)
_, err = io.Copy(nf, resp.Body) _, err = io.Copy(nf, resp.Body)
if nil != err { if nil != err {
return err return err