#!/usr/bin/env bash # Dependency check command -v jq > /dev/null && true || printf "\033[1;31mInstall jq, then come back.\n" command -v jq > /dev/null && true || exit command -v tailscale > /dev/null && true || printf "\033[1;31mInstall Tailscale, then come back.\n" command -v tailscale > /dev/null && true || exit # Define useful variables tailscaleStatus=`tailscale status --json` isTailscaleUp=`echo $tailscaleStatus | jq .Self.Online` tailnetName=`echo $tailscaleStatus | jq -r .CurrentTailnet.Name` tailscaleVersion=`echo $tailscaleStatus | jq -r .Version` tailscaleIPs=`echo $tailscaleStatus | jq -r '.TailscaleIPs | join(", ")'` tailscalePeerCount=`echo $tailscaleStatus | jq -r '.Peer | length'` tailscaleOnlinePeerCount=`echo $tailscaleStatus | jq -r '[.Peer[] | select(.Online == true)] | length'` tailscaleOfflinePeerCount=`echo $tailscaleStatus | jq -r '[.Peer[] | select(.Online == false)] | length'` tailscaleExitNodesCount=`echo $tailscaleStatus | jq -r '[.Peer[] | select(.ExitNodeOption == true)] | length'` tailscaleIsExitNode=`echo $tailscaleStatus | jq -r .Self.ExitNode` tailscaleCanBeExitNode=`echo $tailscaleStatus | jq -r .Self.ExitNodeOption` tailscaleDeviceID=`echo $tailscaleStatus | jq -r .Self.ID` tailscaleUserID=`echo $tailscaleStatus | jq -r .Self.UserID` tailscaleIsMagicDNSEnabled=`echo $tailscaleStatus | jq -r .CurrentTailnet.MagicDNSEnabled` tailscaleMagicDNSHostname=`echo $tailscaleStatus | jq -r .CurrentTailnet.MagicDNSSuffix` tailscaleLoginName=`echo $tailscaleStatus | jq -r '.Self.UserID as $userID | .User[] | select(.ID == $userID) | .LoginName'` tailscaleUserCount=`echo $tailscaleStatus | jq -r '.Peer | length'` tailscaleAPIURL=`echo $tailscaleStatus | jq -r '.Self.PeerAPIURL[0]'` # Show content printf "\033[0;38;5;248m oooooooo oooooooo oooooooo \033[1;37m$tailnetName\033[0;38;5;248m\n" printf " oooooooooo oooooooooo oooooooooo \033[1;37m--------------\033[0;38;5;248m\n" printf " oooooooooooo oooooooooooo oooooooooooo \033[1;37mVersion: \033[0;37m$tailscaleVersion\033[0;38;5;248m\n" printf " oooooooooo oooooooooo oooooooooo \033[1;37mIP addresses: \033[0;37m$tailscaleIPs\033[0;38;5;248m\n" printf " oooooooo oooooooo oooooooo \033[1;37mDevice count: \033[0;37m$tailscalePeerCount ($tailscaleOnlinePeerCount online, $tailscaleOfflinePeerCount offline, $tailscaleExitNodesCount exit node/s)\033[0;38;5;248m\n" printf " \033[1;37mIs exit node: \033[0;37m$tailscaleIsExitNode\033[0;38;5;248m\n" [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || printf "\033[0;38;5;248m" printf " oooooooo oooooooo oooooooo \033[1;37mAllowed to be exit node: \033[0;37m$tailscaleCanBeExitNode\033[0;38;5;248m\n" [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || printf "\033[0;38;5;248m" printf " oooooooooo oooooooooo oooooooooo \033[1;37mDevice ID: \033[0;37m$tailscaleDeviceID\033[0;38;5;248m\n" [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || printf "\033[0;38;5;248m" printf " oooooooooooo oooooooooooo oooooooooooo \033[1;37mUser ID: \033[0;37m$tailscaleUserID\033[0;38;5;248m\n" [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || printf "\033[0;38;5;248m" printf " oooooooooo oooooooooo oooooooooo \033[1;37mMagicDNS enabled: \033[0;37m$tailscaleIsMagicDNSEnabled\033[0;38;5;248m\n" [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || printf "\033[0;38;5;248m" printf " oooooooo oooooooo oooooooo \033[1;37mMagicDNS hostname: \033[0;37m$tailscaleMagicDNSHostname\033[0;38;5;248m\n" printf " \033[1;37mUser login name: \033[0;37m$tailscaleLoginName\033[0;38;5;248m\n" printf "\033[0;38;5;248m oooooooo " [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || false printf "oooooooo " printf "\033[0;38;5;248moooooooo \033[1;37mTailnet user count: \033[0;37m$tailscaleUserCount\033[0;38;5;248m\n" printf "\033[0;38;5;248m oooooooooo " [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || false printf "oooooooooo " printf "\033[0;38;5;248moooooooooo \033[1;37mPeer API URL: \033[0;37m$tailscaleAPIURL\033[0;38;5;248m\n" printf "\033[0;38;5;248m oooooooooooo " [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || false printf "oooooooooooo " printf "\033[0;38;5;248moooooooooooo\n" printf "\033[0;38;5;248m oooooooooo " [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || false printf "oooooooooo " printf "\033[0;38;5;248moooooooooo \033[40m \033[41m \033[42m \033[43m \033[44m \033[45m \033[46m \033[47m \033[m\n" printf "\033[0;38;5;248m oooooooo " [[ "$isTailscaleUp" == "true" ]] && printf "\033[1;37m" || false printf "oooooooo " printf "\033[0;38;5;248moooooooo \033[100m \033[101m \033[102m \033[103m \033[104m \033[105m \033[106m \033[107m \033[m\n\n\n"