diff --git a/podman-desktop b/podman-desktop index 74f0725..f7f2f4b 100755 --- a/podman-desktop +++ b/podman-desktop @@ -13,32 +13,30 @@ show_help() { " } -die() { +err() { echo >&2 "$@" - exit 1 } -install_cmd() { - set +e - if [ -z "$(command -v brew)" ]; then - echo "# Install homebrew for easier MacOS management" - # shellcheck disable=SC2016 - echo '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"' - fi - set -e - echo "brew install $1" +die() { + err "$@" + exit 1 } validate() { cmd=$1 - if [ ! -x "$(command -v "$cmd")" ]; then - echo "ERROR: \`$cmd\` command not found. Please install $cmd." >&2 - echo "Instructions are:" - install_cmd "$cmd" - exit 1 - else - echo "$cmd found." - fi + set +e + command -v $cmd >/dev/null 2>&1 && return + command -v brew >/dev/null 2>&1 || { + die 'Install homebrew for easier macOS management + + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" +' + } + + die "ERROR: \`$cmd\` command not found. Please install with + + brew install $cmd + " } validate "podman" @@ -82,10 +80,11 @@ PUBKEY=$(cat "$PUBKEYFILE") PRIMARY=$(multipass get client.primary-name) if [ "$PRIMARY" != "$INSTANCE_NAME" ] && [ "$PRIMARY" != "primary" ]; then - die "client.primary-name already set ($PRIMARY) for multipass" + err "client.primary-name already set ($PRIMARY) for multipass" +else + multipass set client.primary-name="$INSTANCE_NAME" fi -multipass set client.primary-name="$INSTANCE_NAME" echo >&2 "this may take a while - to view progress: multipass exec $INSTANCE_NAME -- tail -f /var/log/cloud-init-output.log diff --git a/readme.md b/readme.md index 9ad7898..71f711d 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ podman runs on linux, so this script spins up a virtual linux machine, and confi Requires `muiltipass` and `podman` -> if you are on Apple Silicon, use multipass [1.8.0](https://multipass-ci.s3.amazonaws.com/pr403/multipass-1.8.0-dev.403.pr403%2Bg843f3ca3.mac%2Barm64-Darwin.pkg) +> if you are on Apple Silicon, use multipass [1.8.0-rc.849](https://multipass-ci.s3.amazonaws.com/multipass-1.8.0-rc.849%2Bgb6625c10.mac-Darwin.pkg) brew install multipass podman