This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ark server before starting it and embed steamcmd and more (#55)
* embedded steamcmd * add server auto updater * refactored console * added stop functionality * added error feedback on server save * removed useless .then
- Loading branch information
1 parent
5820e0c
commit 1756399
Showing
8 changed files
with
192 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {Button, Divider, LinearProgress, Modal, ModalClose, ModalDialog, Typography} from "@mui/joy"; | ||
import React, {useEffect, useState} from "react"; | ||
import {server} from "../../wailsjs/go/models"; | ||
import {useAlert} from "../components/AlertProvider"; | ||
import {EventsOn} from "../../wailsjs/runtime"; | ||
|
||
|
||
type Props = { | ||
onCompleted?: () => void; | ||
open: boolean; | ||
onClose?: () => void; | ||
} | ||
|
||
export function UpdaterModal({onCompleted, open, onClose}: Props) { | ||
|
||
const [action, setAction] = useState("Preparing") | ||
const [progress, setProgress] = useState(0.00) | ||
const [isCompleted, setIsCompleted] = useState(false) | ||
|
||
useEffect(() => { | ||
EventsOn("installingUpdateAction", (data) => {setAction(data);}) | ||
EventsOn("installingUpdateProgress", (data) => {setProgress(data);}) | ||
EventsOn("appInstalled", (i) => {setIsCompleted(true); setAction("Preparing"); setProgress(0.00)}) | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (isCompleted && onCompleted) { | ||
onCompleted() | ||
|
||
} | ||
}, [isCompleted]); | ||
|
||
return ( | ||
<Modal open={open} onClose={onClose} > | ||
<ModalDialog> | ||
<ModalClose/> | ||
<Typography level="title-md"> | ||
Updating server... | ||
</Typography> | ||
<Typography level="body-sm" > | ||
The server will start automatically after the update | ||
</Typography> | ||
<Divider className={'mx-2'}/> | ||
<Typography fontWeight={700} level="title-md"> | ||
Status: {action} | ||
</Typography> | ||
<Typography fontWeight={700} level="title-md"> | ||
Progress: | ||
</Typography> | ||
<div className={'w-1/2 mt-4'}> | ||
<LinearProgress determinate value={progress} /> | ||
</div> | ||
</ModalDialog> | ||
</Modal> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package installer | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"os" | ||
"path" | ||
) | ||
|
||
//go:embed steamcmd.exe | ||
var steamExe []byte | ||
|
||
func (c *InstallerController) setupSteamCMD() error { | ||
|
||
exePath, err := os.Executable() | ||
if err != nil { | ||
return fmt.Errorf("failed to get executable directory: %v", err) | ||
} | ||
|
||
steamExePath := path.Join(path.Dir(exePath), "steamcmd", "steamcmd.exe") | ||
|
||
if _, err := os.Stat(path.Join(steamExePath)); os.IsNotExist(err) { | ||
//steamcmd is not installed | ||
|
||
err := os.MkdirAll(path.Join(path.Dir(steamExePath)), 0666) | ||
if err != nil { | ||
return fmt.Errorf("failed to create steamcmd directory: %v", err) | ||
} | ||
|
||
err = os.WriteFile(steamExePath, steamExe, 0666) | ||
if err != nil { | ||
return fmt.Errorf("failed to create steamcmd directory: %v", err) | ||
} | ||
|
||
c.config.GetConfig() | ||
c.config.Config.SteamCMDPath = path.Join(path.Dir(exePath), "steamcmd", "steamcmd.exe") | ||
c.config.SaveConfig() | ||
|
||
} else { | ||
//steamCMD is installed so set config to the steamCMD path | ||
c.config.GetConfig() | ||
c.config.Config.SteamCMDPath = path.Join(path.Dir(exePath), "steamcmd", "steamcmd.exe") | ||
c.config.SaveConfig() | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.