Skip to content

Commit

Permalink
Added start script backup and restore logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tobychui committed Apr 17, 2022
1 parent 18e0baa commit 524438b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ func restoreConfigs() {
restoreIfExists("system/cron.json")
restoreIfExists("system/storage.json")
restoreIfExists("web/SystemAO/vendor/")

//Restore start script
if fileExists("./arozos.old/start.sh") {
copy("./arozos.old/start.sh", "./start.sh")
}
if fileExists("./arozos.old/start.bat") {
copy("./arozos.old/start.bat", "./start.bat")
}
}

func restoreOldArozOS() {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
*/

const (
launcherVersion = "1.0"
launcherVersion = "1.1"
restoreRetryCount = 3 //The number of retry before restore old version, if not working after restoreRetryCount + 1 launcher will exit
)

Expand Down
15 changes: 15 additions & 0 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,27 @@ func updateIfExists(binaryName string) {
fmt.Println("[LAUNCHER] Starting system backup process (to ./arozos.old)")
os.MkdirAll("./arozos.old", 0775)
copy(binaryName, filepath.Join("./arozos.old", filepath.Base(binaryName)))

//Backup the start.sh script and start.bat script if exists
if fileExists("./start.sh") {
copy("./start.sh", "./arozos.old/start.sh")
}

if fileExists("./start.bat") {
copy("./start.bat", "./arozos.old/start.bat")
}

//Backup the important system files
fmt.Println("[LAUNCHER] Backing up system files")
cp.Copy("./system", "./arozos.old/system/")

fmt.Println("[LAUNCHER] Backing up web server")
cp.Copy("./web", "./arozos.old/web/")

//Success. Continue binary replacement
fmt.Println("[LAUNCHER] Copying updates to runtime environment")
copy(newArozBinary, binaryName)

cp.Copy("./updates/system", "./system/")
cp.Copy("./updates/web", "./web/")

Expand Down

0 comments on commit 524438b

Please sign in to comment.