diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..24e3f3a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+data
+vrisingd
\ No newline at end of file
diff --git a/README.md b/README.md
index e48f510..add917f 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,6 @@
# VRisingD (V Rising Daemon)
-This tool allows for the simple configuration, backup, and starting of a V Rising Server to better assist for Docker deployments using a web page
\ No newline at end of file
+This tool allows for the simple configuration, backup, and starting of a V Rising Server to better assist for Docker deployments using a web page
+
+- [x] Backup Saves
+- [x] Update
+- [] Upload Config Files
\ No newline at end of file
diff --git a/handlers.go b/handlers.go
index a5349b8..8fc5ebc 100644
--- a/handlers.go
+++ b/handlers.go
@@ -1,18 +1,27 @@
package main
import (
+ "archive/zip"
"bytes"
+ "io"
"net/http"
+ "os"
"os/exec"
+ "path/filepath"
+ "strings"
"github.com/gin-gonic/gin"
)
-func index(c *gin.Context) {
- index_page, err := indexHTML.ReadFile("html/index.html")
+func check(err error) {
if err != nil {
panic(err)
}
+}
+
+func index(c *gin.Context) {
+ index_page, err := indexHTML.ReadFile("html/index.html")
+ check(err)
c.Data(http.StatusOK, "text/html", index_page)
}
@@ -30,3 +39,55 @@ func update(c *gin.Context) {
c.String(http.StatusOK, out.String())
}
}
+
+func RecursiveZip(pathToZip, destinationPath string) error {
+
+ os.MkdirAll("data", 0755)
+
+ destinationFile, err := os.Create(destinationPath)
+ if err != nil {
+ return err
+ }
+ myZip := zip.NewWriter(destinationFile)
+ err = filepath.Walk(pathToZip, func(filePath string, info os.FileInfo, err error) error {
+ if info.IsDir() {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+ relPath := strings.TrimPrefix(filePath, filepath.Dir(pathToZip))
+ zipFile, err := myZip.Create(relPath)
+ if err != nil {
+ return err
+ }
+ fsFile, err := os.Open(filePath)
+ if err != nil {
+ return err
+ }
+ _, err = io.Copy(zipFile, fsFile)
+ if err != nil {
+ return err
+ }
+ return nil
+ })
+ if err != nil {
+ return err
+ }
+ err = myZip.Close()
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func backup(c *gin.Context) {
+
+ err := RecursiveZip("/root/.wine/drive_c/users/root/AppData/LocalLow/Stunlock Studios/VRisingServer/Saves", "data/backup.zip")
+ check(err)
+
+ backup, err := os.ReadFile("data/backup.zip")
+ check(err)
+
+ c.Data(http.StatusOK, "application/zip", backup)
+}
diff --git a/html/index.html b/html/index.html
index 7be402e..4291b18 100644
--- a/html/index.html
+++ b/html/index.html
@@ -1,19 +1,24 @@
Why Hello There
- + + +