mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-08 03:20:39 +00:00
Compare commits
2 Commits
e3126d75f7
...
v1.7.9
Author | SHA1 | Date | |
---|---|---|---|
|
f67bb7f73c | ||
|
530b1b646c |
@@ -6,7 +6,7 @@ RUN go mod download
|
|||||||
COPY . .
|
COPY . .
|
||||||
RUN go build
|
RUN go build
|
||||||
|
|
||||||
FROM restic/restic:0.15.1
|
FROM restic/restic:0.16.0
|
||||||
RUN apk add --no-cache rclone bash
|
RUN apk add --no-cache rclone bash
|
||||||
COPY --from=builder /app/autorestic /usr/bin/autorestic
|
COPY --from=builder /app/autorestic /usr/bin/autorestic
|
||||||
ENTRYPOINT []
|
ENTRYPOINT []
|
||||||
|
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -36,7 +37,7 @@ func dlJSON(url string) (GithubRelease, error) {
|
|||||||
return parsed, err
|
return parsed, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return parsed, err
|
return parsed, err
|
||||||
|
|
||||||
@@ -72,10 +73,9 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
|
|||||||
// Uncompress
|
// Uncompress
|
||||||
bz := bzip2.NewReader(resp.Body)
|
bz := bzip2.NewReader(resp.Body)
|
||||||
|
|
||||||
// Save to tmp file in the same directory as the install directory
|
// Save to tmp
|
||||||
// Linux does not support overwriting the file that is currently being running
|
// Linux does not support overwriting the file that is currently being overwritten, but it can be deleted and a new one moved in its place.
|
||||||
// But it can be delete the old one and a new one moved in its place.
|
tmp, err := ioutil.TempFile(os.TempDir(), "autorestic-")
|
||||||
tmp, err := os.CreateTemp(INSTALL_PATH, "autorestic-")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -89,24 +89,22 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
|
|||||||
|
|
||||||
to := path.Join(INSTALL_PATH, name)
|
to := path.Join(INSTALL_PATH, name)
|
||||||
defer os.Remove(tmp.Name()) // Cleanup temporary file after thread exits
|
defer os.Remove(tmp.Name()) // Cleanup temporary file after thread exits
|
||||||
|
if err := os.Rename(tmp.Name(), to); err != nil {
|
||||||
mode := os.FileMode(0755)
|
colors.Error.Printf("os.Rename() failed (%v), retrying with io.Copy()\n", err.Error())
|
||||||
if originalBin, err := os.Lstat(to); err == nil {
|
var src *os.File
|
||||||
mode = originalBin.Mode()
|
var dst *os.File
|
||||||
err := os.Remove(to)
|
if src, err = os.Open(tmp.Name()); err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
|
}
|
||||||
|
if dst, err = os.Create(to); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := io.Copy(dst, src); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := os.Chmod(to, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
err = os.Rename(tmp.Name(), to)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = os.Chmod(to, mode)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
colors.Success.Printf("Successfully installed '%s' under %s\n", name, INSTALL_PATH)
|
colors.Success.Printf("Successfully installed '%s' under %s\n", name, INSTALL_PATH)
|
||||||
|
@@ -17,7 +17,7 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
const VERSION = "1.7.7"
|
const VERSION = "1.7.9"
|
||||||
|
|
||||||
type OptionMap map[string][]interface{}
|
type OptionMap map[string][]interface{}
|
||||||
type Options map[string]OptionMap
|
type Options map[string]OptionMap
|
||||||
|
Reference in New Issue
Block a user