# HG changeset patch # User Richard Westhaver # Date 1718825234 0 # Node ID 953c5127546ac6550c1ceac2d2e66a5376330833 # Parent 02dec5169a1eb434896c2c42a37f9deff3377876 stash -> .stash diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/gen-libera-cert.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/gen-libera-cert.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,2 @@ +#!/bin/sh +openssl req -x509 -new -newkey rsa:4096 -sha256 -days 365 -nodes -out libera.pem -keyout libera.pem diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/genfstab.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/genfstab.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh +if [$# -eq 0] then genfstab -U -L -p / | less +else genfstab -U -L -p / | $1 diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/new-mail.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/new-mail.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,8 @@ +#!/bin/sh +attach_cmds="" +while [ $# -gt 0 ]; do + fullpath=$(readlink --canonicalize "$1") + attach_cmds="$attach_cmds (mml-attach-file \"$fullpath\")" + shift +done +emacsclient -a '' -c -e "(progn (compose-mail) $attach_cmds)" diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/nfs-export.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/nfs-export.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh +exportfs -arv +exportfs -v diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/pacman-pkgsearch.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/pacman-pkgsearch.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,80 @@ +#!/bin/bash + +# SPDX-License-Identifier: GPL-2.0 + +set -o errexit +shopt -s extglob + +help(){ + cat << EOF +Usage: + $PROGRAM +Flags: + -m [maintainer] find packages from maintainer + -p [packager] find packages from the last packager + -q local packages + -s print the package maintainers + -l [limit] co-maintainer limit to filter on default: 1 + -f [repository] filter on repository, Default: core extra multilib community + -o list flagged packages + -n use pkgname instead of pkgbase (not recommended as we sort away split pkgs) + -h help messages +Example: + Packages from a maintainer with 2 maintainers + $ pkgsearch -m Foxboron -l 2 + Orphaned packages in [extra] + $ pkgsearch -f extra -l 0 -m orphan + Packages installed on the system from [core] with 1 maintainer + $ pkgsearch -q -f core -l 1 + Locally installed packages from [community], orphaned, and flagged out-of-date + $ pkgsearch -q -f community -l 0 -m orphan -o +EOF +} + + +limit_maintainers=1 +see_maintainers=0 +out_of_date="" +name=".pkgbase" +filter=() + +while true; do + case "$1" in + -m) shift; maintainer_query="maintainer=$1" ;; + -p) shift; packager_query="&packager=$1" ;; + -q) local_packages=1;; + -s) see_maintainers=1;; + -l) shift; limit_maintainers=$1;; + -f) shift; filter+=("${1,,}");; + -o) out_of_date="Flagged";; + -n) name=".pkgname";; + -h) help;; + "") break;; + esac + shift +done + +find_packages(){ + test ${#filter} -eq 0 && filter=(core extra community multilib) + if ((local_packages)); then + # shellcheck disable=SC2046 + expac -S "%r %a %n %e" $(expac %n) | grep -P "^($(tr ' ' '|' <<< "${filter[*]}")) " + else + filter=("${filter[@]^}") # Uppercase the repo names + filter=("${filter[@]/#/&repo=}") # Prepend &repo= to all elements + query="?${maintainer_query}${packager_query}$(printf "%s" "${filter[@]}")&flagged=$out_of_date" + curl -s "https://archlinux.org/packages/search/json/$query" \ + | jq -r '.results[] | "\(.repo) \(.arch) \(.pkgname) \(.pkgbase)"' | sort | uniq + fi +} + +while read -r repo arch pkg _; do + # shellcheck disable=SC2016 + format="select(.maintainers | length == \$LIMIT) | \"\(${name})\"" + if ((see_maintainers)); then + # shellcheck disable=SC2016 + format="select(.maintainers | length == \$LIMIT) | \"\(${name})\", (.maintainers | join(\" \"))" + fi + curl -s "https://archlinux.org/packages/$repo/$arch/$pkg/json/" | \ + jq -r --argjson LIMIT "$limit_maintainers" "$format" +done <<< "$(find_packages | sort -u -k4,4)" diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/podman-machine-default-update.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/podman-machine-default-update.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,2 @@ +#!/bin/sh +podman machine ssh 'sudo rpm-ostree upgrade --bypass-driver' diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/port-scan.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/port-scan.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,55 @@ +#!/bin/bash +#Performs port scan using nmap + +print_usage() { +cat << _EOF_ + Utility to scan open ports. Can be used to scan ports for a domain or a list of domains specified in a file. + Example Usage: + -h, --help Show brief help + -d, --domain Domain name or ip to scan + -f, --file Spefify a file containing domains/IPs to scan +_EOF_ +} + +scan_port() { + domain=$1 + echo "Scanning ports for $1...." + nmap -sT -T4 $domain | sed '/^\(Nmap scan\|PORT\|[0-9]\)/!d' | tee -a $port_scan_result_file +} + +create_port_scan_result_file() { + port_scan_result_file="/tmp/port-scan-`date "+%Y-%m-%d-%H:%M:%S"`.txt" + touch $port_scan_result_file +} + +while getopts "f:d:" opt; do + case "$opt" in + d) domain=$OPTARG ;; + f) file=$OPTARG ;; + *) print_usage; exit 1 ;; + esac +done + +if [ ! -n "$domain" ] && [ ! -f "$file" ]; then + echo "Option -d $domain or -f $file missing or designates to wrong entry" >&2 + exit 1 +fi + +scan_port_flow() { + +if [ -n "$domain" ]; then + create_port_scan_result_file + scan_port $domain + echo "Scan result:$port_scan_result_file" +fi + +if [ -n "$file" ]; then + create_port_scan_result_file + for domain in $(cat $file) + do + scan_port $domain + done + echo "Scan result: $port_scan_result_file" +fi +} +scan_port_flow diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/qmk-flash-moonlander.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/qmk-flash-moonlander.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh +cp -rf ~/.config/kbd/moonlander/* ~/qmk_firmware/keyboards/moonlander/keymaps/ellis/ +qmk flash -kb moonlander -km ellis diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/sc.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/sc.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,4 @@ +#!/usr/local/env bash +import png:- >> ${1:-"$(date +%s).png"} +# take screenshot of current window on sway +# swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -g - ${1:-"$(date +%s).png"} diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/upgrade.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/upgrade.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,3 @@ +#!/usr/bin/sh +sudo pacman -Syu +rustup update diff -r 02dec5169a1e -r 953c5127546a .stash/scripts/wg-gen-keys.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.stash/scripts/wg-gen-keys.sh Wed Jun 19 19:27:14 2024 +0000 @@ -0,0 +1,4 @@ +#!/bin/sh +# generate base64-enc keypair in current dir +umask 077 +wg genkey | tee privatekey | wg pubkey > publickey diff -r 02dec5169a1e -r 953c5127546a stash/scripts/gen-libera-cert.sh --- a/stash/scripts/gen-libera-cert.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -#!/bin/sh -openssl req -x509 -new -newkey rsa:4096 -sha256 -days 365 -nodes -out libera.pem -keyout libera.pem diff -r 02dec5169a1e -r 953c5127546a stash/scripts/genfstab.sh --- a/stash/scripts/genfstab.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -#!/bin/sh -if [$# -eq 0] then genfstab -U -L -p / | less -else genfstab -U -L -p / | $1 diff -r 02dec5169a1e -r 953c5127546a stash/scripts/new-mail.sh --- a/stash/scripts/new-mail.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#!/bin/sh -attach_cmds="" -while [ $# -gt 0 ]; do - fullpath=$(readlink --canonicalize "$1") - attach_cmds="$attach_cmds (mml-attach-file \"$fullpath\")" - shift -done -emacsclient -a '' -c -e "(progn (compose-mail) $attach_cmds)" diff -r 02dec5169a1e -r 953c5127546a stash/scripts/nfs-export.sh --- a/stash/scripts/nfs-export.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -#!/bin/sh -exportfs -arv -exportfs -v diff -r 02dec5169a1e -r 953c5127546a stash/scripts/pacman-pkgsearch.sh --- a/stash/scripts/pacman-pkgsearch.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -#!/bin/bash - -# SPDX-License-Identifier: GPL-2.0 - -set -o errexit -shopt -s extglob - -help(){ - cat << EOF -Usage: - $PROGRAM -Flags: - -m [maintainer] find packages from maintainer - -p [packager] find packages from the last packager - -q local packages - -s print the package maintainers - -l [limit] co-maintainer limit to filter on default: 1 - -f [repository] filter on repository, Default: core extra multilib community - -o list flagged packages - -n use pkgname instead of pkgbase (not recommended as we sort away split pkgs) - -h help messages -Example: - Packages from a maintainer with 2 maintainers - $ pkgsearch -m Foxboron -l 2 - Orphaned packages in [extra] - $ pkgsearch -f extra -l 0 -m orphan - Packages installed on the system from [core] with 1 maintainer - $ pkgsearch -q -f core -l 1 - Locally installed packages from [community], orphaned, and flagged out-of-date - $ pkgsearch -q -f community -l 0 -m orphan -o -EOF -} - - -limit_maintainers=1 -see_maintainers=0 -out_of_date="" -name=".pkgbase" -filter=() - -while true; do - case "$1" in - -m) shift; maintainer_query="maintainer=$1" ;; - -p) shift; packager_query="&packager=$1" ;; - -q) local_packages=1;; - -s) see_maintainers=1;; - -l) shift; limit_maintainers=$1;; - -f) shift; filter+=("${1,,}");; - -o) out_of_date="Flagged";; - -n) name=".pkgname";; - -h) help;; - "") break;; - esac - shift -done - -find_packages(){ - test ${#filter} -eq 0 && filter=(core extra community multilib) - if ((local_packages)); then - # shellcheck disable=SC2046 - expac -S "%r %a %n %e" $(expac %n) | grep -P "^($(tr ' ' '|' <<< "${filter[*]}")) " - else - filter=("${filter[@]^}") # Uppercase the repo names - filter=("${filter[@]/#/&repo=}") # Prepend &repo= to all elements - query="?${maintainer_query}${packager_query}$(printf "%s" "${filter[@]}")&flagged=$out_of_date" - curl -s "https://archlinux.org/packages/search/json/$query" \ - | jq -r '.results[] | "\(.repo) \(.arch) \(.pkgname) \(.pkgbase)"' | sort | uniq - fi -} - -while read -r repo arch pkg _; do - # shellcheck disable=SC2016 - format="select(.maintainers | length == \$LIMIT) | \"\(${name})\"" - if ((see_maintainers)); then - # shellcheck disable=SC2016 - format="select(.maintainers | length == \$LIMIT) | \"\(${name})\", (.maintainers | join(\" \"))" - fi - curl -s "https://archlinux.org/packages/$repo/$arch/$pkg/json/" | \ - jq -r --argjson LIMIT "$limit_maintainers" "$format" -done <<< "$(find_packages | sort -u -k4,4)" diff -r 02dec5169a1e -r 953c5127546a stash/scripts/podman-machine-default-update.sh --- a/stash/scripts/podman-machine-default-update.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -#!/bin/sh -podman machine ssh 'sudo rpm-ostree upgrade --bypass-driver' diff -r 02dec5169a1e -r 953c5127546a stash/scripts/port-scan.sh --- a/stash/scripts/port-scan.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -#!/bin/bash -#Performs port scan using nmap - -print_usage() { -cat << _EOF_ - Utility to scan open ports. Can be used to scan ports for a domain or a list of domains specified in a file. - Example Usage: - -h, --help Show brief help - -d, --domain Domain name or ip to scan - -f, --file Spefify a file containing domains/IPs to scan -_EOF_ -} - -scan_port() { - domain=$1 - echo "Scanning ports for $1...." - nmap -sT -T4 $domain | sed '/^\(Nmap scan\|PORT\|[0-9]\)/!d' | tee -a $port_scan_result_file -} - -create_port_scan_result_file() { - port_scan_result_file="/tmp/port-scan-`date "+%Y-%m-%d-%H:%M:%S"`.txt" - touch $port_scan_result_file -} - -while getopts "f:d:" opt; do - case "$opt" in - d) domain=$OPTARG ;; - f) file=$OPTARG ;; - *) print_usage; exit 1 ;; - esac -done - -if [ ! -n "$domain" ] && [ ! -f "$file" ]; then - echo "Option -d $domain or -f $file missing or designates to wrong entry" >&2 - exit 1 -fi - -scan_port_flow() { - -if [ -n "$domain" ]; then - create_port_scan_result_file - scan_port $domain - echo "Scan result:$port_scan_result_file" -fi - -if [ -n "$file" ]; then - create_port_scan_result_file - for domain in $(cat $file) - do - scan_port $domain - done - echo "Scan result: $port_scan_result_file" -fi -} -scan_port_flow diff -r 02dec5169a1e -r 953c5127546a stash/scripts/qmk-flash-moonlander.sh --- a/stash/scripts/qmk-flash-moonlander.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -#!/bin/sh -cp -rf ~/.config/kbd/moonlander/* ~/qmk_firmware/keyboards/moonlander/keymaps/ellis/ -qmk flash -kb moonlander -km ellis diff -r 02dec5169a1e -r 953c5127546a stash/scripts/sc.sh --- a/stash/scripts/sc.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -#!/usr/local/env bash -import png:- >> ${1:-"$(date +%s).png"} -# take screenshot of current window on sway -# swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -g - ${1:-"$(date +%s).png"} diff -r 02dec5169a1e -r 953c5127546a stash/scripts/upgrade.sh --- a/stash/scripts/upgrade.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -#!/usr/bin/sh -sudo pacman -Syu -rustup update diff -r 02dec5169a1e -r 953c5127546a stash/scripts/wg-gen-keys.sh --- a/stash/scripts/wg-gen-keys.sh Wed Jun 19 15:32:46 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -#!/bin/sh -# generate base64-enc keypair in current dir -umask 077 -wg genkey | tee privatekey | wg pubkey > publickey