Last active
November 21, 2025 16:13
-
-
Save tiesmaster/d6c4bb9f303ccb9d24b4af2468c4f2b9 to your computer and use it in GitHub Desktop.
Rancher wrapper script to follow the oauth flow to your browser
This file contains hidden or 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/env bash | |
| set -ueo pipefail | |
| # Path to the actual rancher executable | |
| RANCHER_BIN="/opt/homebrew/bin/rancher" | |
| # Check if the first argument is "token" | |
| if [ "$1" = "token" ]; then | |
| # Monitor the output file for the authentication code | |
| "$RANCHER_BIN" "$@" 2> >( while IFS= read -r line; do | |
| code=$(echo "$line" | perl -ne 'm/and enter the code ([A-Z0-9]*) to authenticate./ && print "$1\n"') | |
| if [ -n "$code" ]; then | |
| echo "$code" | pbcopy | |
| open https://www.microsoft.com/devicelogin | |
| fi | |
| done) | |
| exit | |
| fi | |
| # Passthrough: call rancher with all arguments | |
| exec "$RANCHER_BIN" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simpler: