From 3ba18a2c386a5a9962cf7b47f490a17f244a0774 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sat, 25 May 2024 21:10:02 -0400 Subject: [PATCH] general fixes --- brc | 54 ++++++++++++++++++++++++++++-------- brc2 | 22 ++++++++++++--- distro-begin | 12 ++++---- input-setup | 8 +++--- subdir_files/.gnupg/gpg.conf | 4 +-- 5 files changed, 73 insertions(+), 27 deletions(-) diff --git a/brc b/brc index dc32a10..32a2c66 100644 --- a/brc +++ b/brc @@ -859,25 +859,40 @@ fpst() { # file paste } _khfix-common() { - local host ip port file key tmp - read -r host ip port < <(timeout -s 9 2 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to ([^ ]+) \[([^\]*)] port ([0-9]+).*/\1 \2 \3/p" ||: ) + local host ip port file key tmp ssh_host alias + ssh_host=$1 + { + read -r host ip port + read -r alias; + # note ":graph:" is needed or else we get a trailing \r out of ssh, + # dunno why. web search says terminals add \r, so I tried adding -T + # to turn off psuedo terminal, but it didnt help. + } < <(timeout -s 9 2 ssh -TN -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $ssh_host |& + sed -rn "s/debug1: Connecting to ([^ ]+) \[([^\]*)] port ([0-9]+).*/\1 \2 \3/p; +s/^debug1: using hostkeyalias: ([[:graph:]]*).*/\1/p" ||: ) file=$(readlink -f ~/.ssh/known_hosts) if [[ ! $ip ]]; then echo "khfix: ssh failed" return 1 fi + ip_entry=$ip + host_entry=$host + if [[ $alias ]]; then + host_entry="$alias" + fi if [[ $port != 22 ]]; then ip_entry="[$ip]:$port" - host_entry="[$host]:$port" - else - ip_entry=$ip - host_entry=$host + if [[ ! $alias ]]; then + host_entry="[$host]:$port" + fi fi - if [[ $host != "$ip" ]]; then + if [[ $host_entry != "$ip_entry" ]]; then tmp=$(mktemp) ssh-keygen -F "$host_entry" -f $file >$tmp || [[ $? == 1 ]] # 1 when it doesnt exist in the file if [[ -s $tmp ]]; then key=$(sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/' $tmp) + else + echo "khfix WARNING: did not find host entry:$host_entry in known_hosts" fi rm $tmp if [[ $key ]]; then @@ -889,12 +904,13 @@ _khfix-common() { ssh-keygen -F "$ip_entry" -f $file >$tmp || [[ $? == 1 ]] if [[ -s $tmp ]]; then key=$(sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/' $tmp) + else + echo "khfix WARNING: did not find ip entry:$ip_entry in known_hosts" fi rm $tmp if [[ $key ]]; then grep -Fv "$key" "$file" | sponge "$file" fi - ll ~/.ssh/known_hosts } khfix-r() { # known hosts fix without syncing to root user _khfix-common "$@" || return 1 @@ -1419,7 +1435,12 @@ egrinid() { sed -rn '/testignore|jtuttle|eximbackup/!s/^[^ ]+ ([^ ]+) [^ ]+ [^ ]+ <= ([^ ]+).* id=([^ ]+) T="(.*)" from (<[^ ]+> .*$)/\1 \5\n \3\n \4/p' <${1:-/var/log/exim4/mainlog} } etailin() { - tail -F /var/log/exim4/mainlog | sed -rn '/testignore|jtuttle|eximbackup/!s/^[^ ]+ ([^ ]+) [^ ]+ [^ ]+ <= ([^ ]+).*T="(.*)" from (<[^ ]+> .*$)/\1 \4\n \3/p' + local -a tail_arg + tail_arg=(-n500) + if [[ $1 ]]; then + tail_arg=($@) + fi + tail "${tail_arg[@]}" -F /var/log/exim4/mainlog | sed -rn '/testignore|jtuttle|eximbackup/!s/^[^ ]+ ([^ ]+) [^ ]+ [^ ]+ <= ([^ ]+).*T="(.*)" from (<[^ ]+> .*$)/\1 \4\n \3/p' } @@ -2775,8 +2796,15 @@ sl() { slr() { sl --rsync "$@" } -sss() { # ssh solo - sl -oControlMaster=no -oControlPath=/ "$@" + + +# ssh solo +# +# WARNING: If you are trying to use -i, remember that keys added to +# agent previously will still be tried. Use ssh-add -D to remove all +# keys from the agent. +sss() { + ssh -oControlMaster=no -oControlPath=/ "$@" } # kill off old shared socket then ssh ssk() { @@ -3448,6 +3476,10 @@ arpflush() { m s ip n flush dev "$default_route_dev" } +dsh() { + command dsh -c "$@" +} + # * stuff that makes sense to be at the end diff --git a/brc2 b/brc2 index 5fde368..6ac5183 100644 --- a/brc2 +++ b/brc2 @@ -441,7 +441,7 @@ ralerts() { # remote alerts ap() { # pushd in case current directory has an ansible.cfg file pushd /a/xans >/dev/null - ansible-playbook -v -l ${1:- $(hostname -f)} site.yml + ansible-playbook -v -i ${1:- $(hostname -f)}, site.yml popd >/dev/null } aw() { @@ -2963,7 +2963,7 @@ EOF done | s cedit -e hosts-file-up /etc/hosts for host in ${hosts[@]}; do echo $host - done | cedit -e /a/bin/ds/subdir_files/.dsh/group/btrbk + done >/p/c/subdir_files/.dsh/group/btrbk ### end focus on hosts file update ### @@ -3384,8 +3384,8 @@ myprof() { pushd /home/iank/.local/share/profanity/chatlogs/iank_at_fsf.org/rooms/office_at_conference.fsf.org logs=(*) logcount=${#logs[@]} - if (( logcount > 15 )); then - i=$(( logcount - 15 )) + if (( logcount > 16 )); then + i=$(( logcount - 16 )) else i=0 fi @@ -4776,6 +4776,20 @@ opensslcertinfo() { openssl x509 -txt -in "$@" } +# dsh on btrbk hosts +dsb() { +: + } + +# dsh a file and run it +dsa() { + local ret file + if ! parallel -j 10 scp x {}:/tmp <~/.dsh/group/btrbk; then + echo parallel scp failed. dsa returning $ret + fi + dsh -g btrbk + } + export BASEFILE_DIR=/a/bin/fai-basefiles #export ANDROID_HOME=/a/opt/android-home diff --git a/distro-begin b/distro-begin index 82b349e..74bbdff 100755 --- a/distro-begin +++ b/distro-begin @@ -553,7 +553,7 @@ fi # disabled temporarily ###### setup /i # if home_network; then -# sudo teeu /etc/fstab <<'EOF' +# sudo /a/exe/teeu /etc/fstab <<'EOF' # /i/w /w none bind,noauto 0 0 # /i/k /k none bind,noauto 0 0 # EOF @@ -562,11 +562,11 @@ fi # sudo chown $USER:user2 /kr # fi # if [[ $HOSTNAME == frodo ]]; then -# sudo teeu /etc/fstab <<'EOF' +# sudo /a/exe/teeu /etc/fstab <<'EOF' # /k /kr none bind,noauto 0 0 # EOF # else -# sudo teeu /etc/fstab <<'EOF' +# sudo /a/exe/teeu /etc/fstab <<'EOF' # frodo:/k /kr nfs noauto 0 0 # EOF # fi @@ -636,7 +636,7 @@ if has_btrfs; then fi first_root_crypt=$(awk '$2 == "/" {print $1}' /etc/mtab) - sudo teeu /etc/fstab < 2)) && echo ,compress=zstd ) 0 0 EOF sudo mkdir -p $dir @@ -649,7 +649,7 @@ fi case $HOSTNAME in kd) - sudo teeu /etc/fstab <<'EOF' + sudo /a/exe/teeu /etc/fstab <<'EOF' /dev/mapper/crypt_dev_ata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V-part7 /d btrfs nofail,x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s,noatime,compress=zstd,subvol=d 0 0 /d/m /i none bind,compress=zstd 0 0 EOF @@ -665,7 +665,7 @@ EOF fi ;; frodo) - sudo teeu /etc/fstab <<'EOF' + sudo /a/exe/teeu /etc/fstab <<'EOF' /dev/mapper/crypt_dev_ata-ata-Hitachi_HDS722020ALA330_JK1121YAG7SXWS-part1 /i btrfs nofail,x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s,noatime,subvol=i 0 0 EOF if ! mountpoint /i &>/dev/null; then diff --git a/input-setup b/input-setup index db8eb44..5b30b31 100755 --- a/input-setup +++ b/input-setup @@ -100,10 +100,10 @@ if set_device_id "Logitech Unifying Device"; then fi ## slow down ploopy trackball, until we recompile firmware -# id=$(xinput list | grep -F 'Ploopy Corporation Trackball Mouse' | sed -rn 's/.*[[:space:]]id=([^[:space:]]*).*/\1/p' ||:) -# if [[ $id ]]; then -# xinput --set-prop $id 'libinput Accel Speed' -0.9 -# fi +id=$(xinput list | grep -F 'Ploopy Corporation Trackball Mouse' | sed -rn 's/.*[[:space:]]id=([^[:space:]]*).*/\1/p' ||:) +if [[ $id ]]; then + xinput --set-prop $id 'libinput Accel Speed' -0.7 +fi set +x exit 0 diff --git a/subdir_files/.gnupg/gpg.conf b/subdir_files/.gnupg/gpg.conf index 035415d..8c6a6f1 100644 --- a/subdir_files/.gnupg/gpg.conf +++ b/subdir_files/.gnupg/gpg.conf @@ -46,9 +46,9 @@ default-key B125F60B7B287FF6A2B7DF8F170AF0E2954295DF #keyserver hkp://keys.gnupg.net #keyserver hkp://keyserver.ubuntu.com #keyserver hkp://keyring.debian.org -#keyserver keyserver.ubuntu.com +keyserver keyserver.ubuntu.com # more secure hkps, but had problems with my gpg version -keyserver hkps://hkps.pool.sks-keyservers.net +#keyserver hkps://hkps.pool.sks-keyservers.net ### begin things added by enigmail cert-digest-algo SHA256 -- 2.30.2