mirror of
https://github.com/rancher-sandbox/rancher-desktop.git
synced 2021-10-13 00:04:06 +03:00
Make nerdctl script work in both WSL and on native linux
This will detect when linux is run in WSL or by itself to know which method to talk to nerdctl. Note, also removed debug output accidently left in. Signed-off-by: Matt Farina <matt.farina@suse.com>
This commit is contained in:
@@ -1,2 +1,19 @@
|
||||
#!/bin/sh
|
||||
exec /mnt/wsl/rancher-desktop/bin/nerdctl "$@"
|
||||
#!/bin/bash
|
||||
set -eu -o pipefail
|
||||
|
||||
if [[ $(cat /proc/version | grep -i Microsoft) ]]; then
|
||||
exec /mnt/wsl/rancher-desktop/bin/nerdctl "$@"
|
||||
else
|
||||
limaloc="${XDG_DATA_HOME:-$HOME/.local/share/rancher-desktop}"
|
||||
scriptname="${BASH_SOURCE[0]}"
|
||||
while [ -L "${scriptname}" ]; do
|
||||
scriptname="$(readlink "${scriptname}")"
|
||||
done
|
||||
scriptdir="$(cd "$(dirname "${scriptname}")" && pwd)"
|
||||
|
||||
if ! LIMA_HOME="${limaloc}/lima" "${scriptdir}/../lima/bin/limactl" ls --json | grep '"name":"0"' | grep -q '"status":"Running"'; then
|
||||
echo "Rancher Desktop is not running. Please start Rancher Desktop to use nerdctl";
|
||||
else
|
||||
LIMA_HOME="${limaloc}/lima" "${scriptdir}/../lima/bin/limactl" shell 0 sudo --preserve-env=CONTAINERD_ADDRESS nerdctl "$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
func spawn(opts spawnOptions) error {
|
||||
args := []string{"--distribution", opts.distro, "--exec", opts.nerdctl, "--address", opts.containerdSocket}
|
||||
args = append(args, opts.args.args...)
|
||||
log.Printf("running: %+v", args)
|
||||
cmd := exec.Command("wsl.exe", args...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
|
||||
Reference in New Issue
Block a user