mirror of
https://code.dumpstack.io/tools/appvm.git
synced 2025-05-01 09:34:23 +00:00
Generate appvm at start automatically if not exists
This commit is contained in:
parent
7e4aa33a0a
commit
04b2cf63ce
2 changed files with 29 additions and 3 deletions
22
appvm.go
22
appvm.go
|
@ -196,9 +196,31 @@ func stupidProgressBar() {
|
|||
}
|
||||
}
|
||||
|
||||
func fileExists(filename string) bool {
|
||||
info, err := os.Stat(filename)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
||||
func isAppvmConfigurationExists(appvmPath, name string) bool {
|
||||
return fileExists(appvmPath + "/nix/" + name + ".nix")
|
||||
}
|
||||
|
||||
func start(l *libvirt.Libvirt, name string, verbose bool) {
|
||||
appvmPath := configDir
|
||||
|
||||
if !isAppvmConfigurationExists(appvmPath, name) {
|
||||
log.Println("No configuration exists for app, " +
|
||||
"trying to generate")
|
||||
err := generate(l, name, "", "")
|
||||
if err != nil {
|
||||
log.Println("Can't auto generate")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Copy templates
|
||||
err := prepareTemplates(appvmPath)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue