Compare commits

...

4 Commits

Author SHA1 Message Date
ಠ_ಠ 0e6b446c86
Merge 0a48d13d6c into bbb1c85cad 2024-02-16 20:03:42 +01:00
rdelaage bbb1c85cad
Fix upgrade command (#259)
fix #191

Co-authored-by: Romain de Laage <romain.delaage@rdelaage.ovh>
2024-02-15 14:27:37 +01:00
Natanel Shitrit 4cc44315ab
feat: add `docker-cli` package (#339)
Co-authored-by: Nicco <hi@nicco.io>
2024-02-15 14:26:26 +01:00
ಠ_ಠ 0a48d13d6c
Fix quick installation instruction
The command in the documentation was wrong and didn't run the script with elevated privileges. This one does.
2023-12-28 12:11:47 +01:00
3 changed files with 23 additions and 21 deletions

View File

@ -7,7 +7,7 @@ COPY . .
RUN go build
FROM restic/restic:0.16.4
RUN apk add --no-cache rclone bash curl
RUN apk add --no-cache rclone bash curl docker-cli
COPY --from=builder /app/autorestic /usr/bin/autorestic
ENTRYPOINT []
CMD [ "autorestic" ]

View File

@ -5,7 +5,7 @@ Linux & macOS. Windows is not supported. If you have problems installing please
Autorestic requires `bash`, `wget` and `bzip2` to be installed. For most systems these should be already installed.
```bash
wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash
sudo bash -c "$(wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh)"
```
## Alternatives

View File

@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"path"
@ -37,7 +36,7 @@ func dlJSON(url string) (GithubRelease, error) {
return parsed, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return parsed, err
@ -73,9 +72,10 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
// Uncompress
bz := bzip2.NewReader(resp.Body)
// Save to tmp
// 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.
tmp, err := ioutil.TempFile(os.TempDir(), "autorestic-")
// Save to tmp file in the same directory as the install directory
// Linux does not support overwriting the file that is currently being running
// But it can be delete the old one and a new one moved in its place.
tmp, err := os.CreateTemp(INSTALL_PATH, "autorestic-")
if err != nil {
return err
}
@ -89,24 +89,26 @@ func downloadAndInstallAsset(body GithubRelease, name string) error {
to := path.Join(INSTALL_PATH, name)
defer os.Remove(tmp.Name()) // Cleanup temporary file after thread exits
if err := os.Rename(tmp.Name(), to); err != nil {
colors.Error.Printf("os.Rename() failed (%v), retrying with io.Copy()\n", err.Error())
var src *os.File
var dst *os.File
if src, err = os.Open(tmp.Name()); 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 {
mode := os.FileMode(0755)
if originalBin, err := os.Lstat(to); err == nil {
mode = originalBin.Mode()
err := os.Remove(to)
if err != nil {
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)
return nil
}