Skip to content

Instantly share code, notes, and snippets.

@jfqd
Created November 11, 2020 13:27
Show Gist options
  • Save jfqd/f77181d9dd4fab0bb15f4c090b72ba05 to your computer and use it in GitHub Desktop.
Save jfqd/f77181d9dd4fab0bb15f4c090b72ba05 to your computer and use it in GitHub Desktop.
convenient login script for SmartOS zones (native, lx, kvm)
#!/usr/bin/bash
if [[ "$1" =~ ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]]; then
if [[ $(/usr/sbin/vmadm lookup uuid="$1" -j -o type | /opt/tools/bin/jq '.[][]') = "KVM" ]]; then
/usr/sbin/vmadm console "$1"
else
/usr/sbin/zlogin "$1"
fi
else
uuid=$(/usr/sbin/vmadm lookup alias="$1")
brand=$(/usr/sbin/vmadm lookup alias="$1" -j -o type | /opt/tools/bin/jq '.[][]' |sed 's/"//g')
if [[ "$brand" = "KVM" ]]; then
/usr/sbin/vmadm console $uuid
else
/usr/sbin/zlogin $uuid
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment