Moved chezmoi data one level down under chezmoi.roots

This commit is contained in:
Lockszmith (Mac@VAST) 2025-04-14 14:05:59 -04:00
parent c34f7ae631
commit de47f0c388
240 changed files with 90 additions and 76 deletions

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/.keep

View file

@ -0,0 +1,58 @@
#! /usr/bin/env bash
set -e
if [ $# -eq 0 ]; then
printf '%s\n' \
"${0#/*} - | [Address [... Address]]" \
"" \
"Perform copy-ssh-id where key based ssh auth is failing" \
""
exit 2
fi
REMOTE_HOST=("${@:--}")
if [[ "${#REMOTE_HOST}" -eq 1 && "${REMOTE_HOST[0]}" == '-' ]]; then
read -a REMOTE_HOST
fi
ssh_do() {
local USER="${1}" HOST="${2:?}"
# BLINDLY Trust host keys ( https://stackoverflow.com/a/74410573/799379 )
[ 1 -eq "${NO_REFRESH:-0}" ] || (
ssh-keygen -F "$HOST" &>/dev/null \
&& ssh-keygen -R "$HOST" &>/dev/null \
|| true
)
ssh-keygen -F "$HOST" &>/dev/null || (
ssh-keyscan -Ht ed25519 "$HOST" \
|| ssh-keyscan -H "$HOST"
) | grep -v '^#' >> "$HOME/.ssh/known_hosts"
SSH_ASKPASS_REQUIRE=never \
ssh \
-o PasswordAuthentication=no \
-o LogLevel=ERROR \
-o BatchMode=yes \
-o ConnectTimeout=2 \
-ttn \
"${USER:+${USER}@}${HOST}" -- "${@:3}" \
|| (
local XC=$?
printf '\n'
printf 'Exit code: %s\n' "$XC" >&2
return $XC
)
}
for _host in "${REMOTE_HOST[@]}"; do
printf '%-40s: ' "$_host"
if ssh_do "" "$_host" hostname &>/dev/null; then
echo "ready"
else
printf 'Attempting to copy SSH key...\n\n'
ssh-copy-id "$_host"
fi
done

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_get-github-release.sh

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_load-starship

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_load-webi

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_load-zellij

View file

@ -0,0 +1,28 @@
#! /usr/bin/env bash
set -e
is_cmd() {
type -p -- "${@}" 2> /dev/null 1> /dev/null
}
if ! is_cmd ip; then
printf '%s\n' \
'`ip` command missing, try again after installing:' \
' `brew install iproute2mac`' \
''
exit 1
fi
ip -j a s | jq -r '
map(select(.operstate == "UP"))
| map(select(.addr_info | length > 0))
| map(select(any(.addr_info[]; .family == "inet")))
| sort_by(.addr_info[0].local // "0.0.0.0")
| .[]
| "\( .ifname )\t\( .link_type )\t\(
.addr_info[]
| select(.family == "inet")
| "\(.local)/\(.prefixlen)"
)"
'

View file

@ -0,0 +1,25 @@
#! /usr/bin/env bash
set -e
# Arguments 'TO', optional user (can be configured in ~/.ssh/config.d/...), command to run over ssh
# Figure out the IPAddress I need to operate from
# Figure out the interface name to use
# Set the interface to the IP Address if not already setup
# Test with ping
# Connect with SSH
VASTHOST="${1}"
if [ -z "$VASTHOST" ]; then
VASTHOST=192.168.2.2
printf '%s\n' "VAST host argument not supplied, using default $VASTHOST..." >&2
elif [ "$VASTHOST" == "0" ]; then
printf '%s\n' "Removing:" ~/.ssh/vast.id_rsa*
rm ~/.ssh/vast.id_rsa* || true
cp ~/.ssh/id_rsa ~/.ssh/vast.id_rsa
cp ~/.ssh/id_rsa.pub ~/.ssh/vast.id_rsa.pub
exit
fi
set -x
scp vastdata@${VASTHOST}:.ssh/id_rsa ~/.ssh/vast.id_rsa
scp vastdata@${VASTHOST}:.ssh/id_rsa.pub ~/.ssh/vast.id_rsa.pub

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_tsh-get

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_tssh

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_tssh-with-tunnel

View file

@ -0,0 +1 @@
../../../_src.posix/private_dot_local/bin/executable_update-atuin

View file

@ -0,0 +1,78 @@
#!/usr/bin/env bash
# Usage: ./vast-teleport get version [auto|major|<vMajor>]
# Example: ./latest_teleport_version.sh get major
set -e
SCRIPT_NAME="${0##/*}"
usage() {
printf '%s\n' \
"${SCRIPT_NAME} command..." \
'' \
'Usage:' \
' get version same as running `tsh version`' \
' get version server grabs the version of the server' \
' get version server major grabs the major version of the server' \
' get version client 15 grabs the latest version of the client for major' \
" get version client auto grab the latest version based on the server's major version" \
'' \
" To update teleport's \`tsh\` with \`chezmoi\` run the following" \
' eval "$(vast-teleport get version server major -) czx status"' \
''
exit 2
}
get_server_version() {
curl -s https://teleport.vastdata.com:3080/webapi/ping \
| jq -r '.server_version'
}
get_server_major() {
get_server_version | awk -F. '{print $1}'
}
get_latest_version_by_major() {
local MAJOR="$1"
curl -s "https://api.github.com/repos/gravitational/teleport/releases?per_page=100" \
| jq -r ".[].tag_name" \
| grep -E "^v${MAJOR}\." \
| sort -V \
| tail -n 1
}
case "$1" in
get) shift; case $1 in
version) shift; case $1 in
'') tsh version ;;
server) shift; case $1 in
'') get_server_version ;;
major) shift; case $1 in
'') get_server_major ;;
'-') printf 'TELEPORT_MAJOR=' && get_server_major ;;
*) usage ;;
esac;;
*) usage ;;
esac ;;
client) shift; case $1 in
'') usage ;;
auto) get_latest_version_by_major "$(get_server_major)" ;;
*) get_latest_version_by_major "${@}" ;;
esac;;
*) usage ;;
esac;;
*) usage ;;
esac ;;
*) usage ;;
esac
# MAJOR="$1"
#
# if [[ -z "$MAJOR" ]]; then
# echo "Usage: $0 <major_version>"
# exit 1
# fi
#
# curl -s "https://api.github.com/repos/gravitational/teleport/releases?per_page=100" | \
# jq -r ".[].tag_name" | \
# grep -E "^v${MAJOR}\." | \
# sort -V | \
# tail -n 1

View file

@ -0,0 +1,165 @@
#! /usr/bin/env bash
set -e
# Arguments 'TO', optional user (can be configured in ~/.ssh/config.d/...), command to run over ssh
# Figure out the IPAddress I need to operate from
# Figure out the interface name to use
# Set the interface to the IP Address if not already setup
# Test with ping
# Connect with SSH
SCRIPT_NAME="${0##*/}"
if [ $# -eq 0 ]; then
printf '%s\n' \
"${SCRIPT_NAME} <TO> [<FROM>] [<Interface>]" \
"" \
"Configure MacOS iface to connect to <TO> address from <FROM> address" \
"Default <Interface> is en9" \
"" \
"FROM and FROM_SN will be autofilled for the following subnets:" \
" 10.117.10.0/24" \
" 192.168.[1 or 2].0/24" \
"" \
"for other subnets, you'll need to specify a FROM argument and a FROM_SN env variable" \
"" \
"What the script does:" \
" 1. Attempts a ping to the destination IP." \
" 2. If unsuccessful:" \
" a. if FROM (2nd arg) isn't specified or set to 'dhcp':" \
" - tries to guess the FROM and FROM_SN based on known TO ranges." \
" b. if FROM was specied - uses FROM/2nd argument and FROM_SN from env" \
" c. compares desired FROM and assigned IP on outgoing interface (IFACE env or default: en9)" \
" d. if different, asssigns ip address to interface (temporary, using sudo)" \
" e. Attempts ping once again" \
" 3. If ping was successful, tries to grab hostname via ssh" \
"" \
" The entire process will do it's best to communicate error states and" \
" recommend possible actions if any steps fail" \
""\
"Predefined CIDR and aliases" \
" 10.117.10.254/24 " \
" 192.168.1.254/24 " \
" 192.168.2.254/24 " \
" 169.254.1.15/27 " \
" 169.254.111.15/27 " \
" 169.254.3.254/24 " \
"" \
"Examples:" \
" ${SCRIPT_NAME} 192.168.2.2 # connect to tech port" \
""
exit 2
elif [[ $# -eq 1 && "$1" == "editme" ]]; then
exec ${VISUAL:-${EDITOR:-vi}} "$(readlink -f "$0")"
exit 0
fi
TO="${1}"
IFACE="${IFACE:-en9}"
PINGOK=1
CMDs=("${@:2}")
[ "${#CMDs}" -gt 0 ] || CMDs=( hostname )
_myip() {
lsip | awk "/${IFACE}/"'{split($3, a, "/"); print a[1];}'
}
_ping() {
ping -c "${PING_C:-3}" -W 250 "${TO}"
}
_log() {
printf '%s\n' \
"${@:2}" \
>&2
exit ${1}
}
if _ping &>/dev/null; then
printf "Connection detected.\n"
else
PINGOK=0
if [ "${FROM:-${2:-}}" == "dhcp" ]; then
FROM=dhcp
FROM_SN=auto
SLEEP="${SLEEP:-15s}"
else
SLEEP="${SLEEP:-3s}"
case "${FROM:+__}${TO}" in
10.117.10.*)
FROM=10.117.10.254
FROM_SN=255.255.255.0
;;
192.168.1.*)
FROM=192.168.1.254
FROM_SN=255.255.255.0
;;
192.168.2.*)
FROM=192.168.2.254
FROM_SN=255.255.255.0
;;
169.254.1.*)
FROM=169.254.1.15
FROM_SN=255.255.255.224
;;
169.254.111.*)
FROM=169.254.111.15
FROM_SN=255.255.255.224
;;
169.254.3.*)
FROM=169.254.3.253
FROM_SN=255.255.255.0
;;
*)
FROM=${FROM:-${2:?FROM and FROM_SN Must be supplied for unknown IPv4 destination $1}}
FROM_SN=${FROM_SN:?FROM and FROM_SN Must be supplied for unknown IPv4 destination $1}
;;
esac
fi
MYIP=''
MYIP="$(_myip)"
if [ "$FROM" == "$MYIP" ]; then
_log 2 "Already setup with $MYIP, but ping to $TO is failing, you'll need to troubleshoot this."
exit 2
fi
echo "$MYIP detected on $IFACE, Setting up $FROM / $FROM_SN - \`sudo\` might be prompting you for your password"
if [ "${FROM}" == "dhcp" ]; then
sudo ipconfig set "${IFACE}" bootp || true
sudo ipconfig set "${IFACE}" dhcp
else
sudo ipconfig set "${IFACE}" manual "${FROM}" "${FROM_SN}"
fi \
&& printf 'Waiting %s...' "${SLEEP}" \
&& sleep "${SLEEP}" \
&& MYIP="$(_myip)"
fi
if [ $PINGOK -eq 0 ] && _ping &>/dev/null; then
PINGOK=1
fi
if [ $PINGOK -eq 1 ]; then
# auto-copy-ssh-id "${TO}"
ssh-keygen -R "${TO}" || true
ssh \
-o PasswordAuthentication=no \
-o BatchMode=yes \
-o ConnectTimeout=2 \
-ttn \
"${TO}" -- "${CMDs[*]}" \
|| 1>&2 printf '%s\n' \
"Could not SSH into ${TO}, you might want to run 'pull-vast.id_rsa ${TO}' or 'auto-copy-ssh-id ${TO}'"
else
_log 2 "Ping faild."
fi
exit