Created
November 11, 2020 13:27
-
-
Save jfqd/f77181d9dd4fab0bb15f4c090b72ba05 to your computer and use it in GitHub Desktop.
convenient login script for SmartOS zones (native, lx, kvm)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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