#!/usr/bin/env bash

ssh_binary="$HOME/.guix-profile/bin/ssh"

main()
{
    if [[ $1 == vm[0-9]* ]] && [[ $1 != *.wugi.info ]]
    then
        exec "$ssh_binary" \
             -o UserKnownHostsFile=/dev/null \
             -o StrictHostKeyChecking=no \
             -i ~/.ssh/id_rsa_majordomo_sup \
             "sup@$(ihs vm ip $1 | recsel -Pip_address)" \
             "$@"
    elif [[ $1 == kube[0-9]* ]] && [[ $1 != *".intr" ]]
    then
        exec kubectl invoke --format=shell "--host=${1}"
    else
        exec "$ssh_binary" "$@"
    fi
}

main "$@"
