#!/usr/bin/env bash # SPDX-FileCopyrightText: 2022 Patrick Spek # # SPDX-License-Identifier: AGPL-3.0-or-later subcommand() { local ssh ssh="$(config "app.ssh")" if [[ ! -d "$BASHTARD_ETCDIR/hosts.d" ]] then crit "$BASHTARD_NAME/ssh" "Could not find hosts file at $BASHTARD_ETCDIR/hosts.d" return 3 fi chgdir "$BASHTARD_ETCDIR/hosts.d" for node in * do local user local host user="$(config_for "$node" "ssh.user" "root")" host="$(config_for "$node" "ssh.host" "$(config_for "$node" "vpn.ipv4")")" if [[ -z "$host" ]] then crit "ssh" "ssh.host is not configured for $node" continue fi notice "ssh" "$user@$node ($host) > $*" $ssh "$user@$host" "$@" unset user unset host done }