Skip to content

Commit

Permalink
src: add InstallFile preset.json
Browse files Browse the repository at this point in the history
  • Loading branch information
yuk7 committed Feb 8, 2022
1 parent 18d800a commit ca9f996
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/install/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@ func Execute(name string, args []string) {
if !wsllib.WslIsDistributionRegistered(name) {
var rootPath string
var showProgress bool
jsonPreset, _ := preset.ReadParsePreset()
switch len(args) {
case 0:
rootPath = detectRootfsFiles()
if jsonPreset.InstallFile != "" {
rootPath = jsonPreset.InstallFile
}
showProgress = true

case 1:
showProgress = false
if args[0] == "--root" {
rootPath = detectRootfsFiles()
if jsonPreset.InstallFile != "" {
rootPath = jsonPreset.InstallFile
}
} else {
rootPath = args[0]
}
Expand Down Expand Up @@ -58,12 +65,9 @@ func Execute(name string, args []string) {
utils.ErrorExit(err, showProgress, true, args == nil)
}

json, err2 := preset.ReadParsePreset()
if err2 == nil {
if json.WslVersion == 1 || json.WslVersion == 2 {
wslexe := utils.GetWindowsDirectory() + "\\System32\\wsl.exe"
_, err = exec.Command(wslexe, "--set-version", name, strconv.Itoa(json.WslVersion)).Output()
}
if jsonPreset.WslVersion == 1 || jsonPreset.WslVersion == 2 {
wslexe := utils.GetWindowsDirectory() + "\\System32\\wsl.exe"
_, err = exec.Command(wslexe, "--set-version", name, strconv.Itoa(jsonPreset.WslVersion)).Output()
}

if err == nil {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/preset/model_preset.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package preset

type Preset struct {
WslVersion int `json:"wslversion,omitempty"`
WslVersion int `json:"wslversion,omitempty"`
InstallFile string `json:"installfile,omitempty"`
}

0 comments on commit ca9f996

Please sign in to comment.