changelog shortlog graph tags branches files raw help

Mercurial > infra > home / changeset: stash -> .stash

changeset 48: 953c5127546a
parent 47: 02dec5169a1e
child 49: f3c32ffdbbef
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 19 Jun 2024 19:27:14 +0000
files: .stash/scripts/gen-libera-cert.sh .stash/scripts/genfstab.sh .stash/scripts/new-mail.sh .stash/scripts/nfs-export.sh .stash/scripts/pacman-pkgsearch.sh .stash/scripts/podman-machine-default-update.sh .stash/scripts/port-scan.sh .stash/scripts/qmk-flash-moonlander.sh .stash/scripts/sc.sh .stash/scripts/upgrade.sh .stash/scripts/wg-gen-keys.sh stash/scripts/gen-libera-cert.sh stash/scripts/genfstab.sh stash/scripts/new-mail.sh stash/scripts/nfs-export.sh stash/scripts/pacman-pkgsearch.sh stash/scripts/podman-machine-default-update.sh stash/scripts/port-scan.sh stash/scripts/qmk-flash-moonlander.sh stash/scripts/sc.sh stash/scripts/upgrade.sh stash/scripts/wg-gen-keys.sh
description: stash -> .stash
     1.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2+++ b/.stash/scripts/gen-libera-cert.sh	Wed Jun 19 19:27:14 2024 +0000
     1.3@@ -0,0 +1,2 @@
     1.4+#!/bin/sh
     1.5+openssl req -x509 -new -newkey rsa:4096 -sha256 -days 365 -nodes -out libera.pem -keyout libera.pem
     2.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2+++ b/.stash/scripts/genfstab.sh	Wed Jun 19 19:27:14 2024 +0000
     2.3@@ -0,0 +1,3 @@
     2.4+#!/bin/sh
     2.5+if [$# -eq 0] then genfstab -U -L -p / | less
     2.6+else genfstab -U -L -p / | $1
     3.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2+++ b/.stash/scripts/new-mail.sh	Wed Jun 19 19:27:14 2024 +0000
     3.3@@ -0,0 +1,8 @@
     3.4+#!/bin/sh
     3.5+attach_cmds=""
     3.6+while [ $# -gt 0 ]; do
     3.7+    fullpath=$(readlink --canonicalize "$1")
     3.8+    attach_cmds="$attach_cmds (mml-attach-file \"$fullpath\")"
     3.9+    shift
    3.10+done
    3.11+emacsclient -a '' -c -e "(progn (compose-mail) $attach_cmds)"
     4.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2+++ b/.stash/scripts/nfs-export.sh	Wed Jun 19 19:27:14 2024 +0000
     4.3@@ -0,0 +1,3 @@
     4.4+#!/bin/sh
     4.5+exportfs -arv
     4.6+exportfs -v
     5.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2+++ b/.stash/scripts/pacman-pkgsearch.sh	Wed Jun 19 19:27:14 2024 +0000
     5.3@@ -0,0 +1,80 @@
     5.4+#!/bin/bash
     5.5+
     5.6+# SPDX-License-Identifier: GPL-2.0
     5.7+
     5.8+set -o errexit
     5.9+shopt -s extglob
    5.10+
    5.11+help(){
    5.12+    cat << EOF 
    5.13+Usage:
    5.14+  $PROGRAM
    5.15+Flags:
    5.16+    -m [maintainer]     find packages from maintainer
    5.17+    -p [packager]       find packages from the last packager
    5.18+    -q                  local packages
    5.19+    -s                  print the package maintainers
    5.20+    -l [limit]          co-maintainer limit to filter on default: 1
    5.21+    -f [repository]     filter on repository, Default: core extra multilib community
    5.22+    -o                  list flagged packages
    5.23+    -n                  use pkgname instead of pkgbase (not recommended as we sort away split pkgs)
    5.24+    -h                  help messages
    5.25+Example:
    5.26+    Packages from a maintainer with 2 maintainers
    5.27+    $ pkgsearch -m Foxboron -l 2
    5.28+    Orphaned packages in [extra]
    5.29+    $ pkgsearch -f extra -l 0 -m orphan
    5.30+    Packages installed on the system from [core] with 1 maintainer
    5.31+    $ pkgsearch -q -f core -l 1
    5.32+    Locally installed packages from [community], orphaned, and flagged out-of-date 
    5.33+    $ pkgsearch -q -f community -l 0 -m orphan -o
    5.34+EOF
    5.35+}
    5.36+
    5.37+
    5.38+limit_maintainers=1
    5.39+see_maintainers=0
    5.40+out_of_date=""
    5.41+name=".pkgbase"
    5.42+filter=()
    5.43+
    5.44+while true; do
    5.45+    case "$1" in
    5.46+        -m) shift; maintainer_query="maintainer=$1" ;;
    5.47+        -p) shift; packager_query="&packager=$1" ;;
    5.48+        -q) local_packages=1;;
    5.49+        -s) see_maintainers=1;;
    5.50+        -l) shift; limit_maintainers=$1;;
    5.51+        -f) shift; filter+=("${1,,}");;
    5.52+        -o) out_of_date="Flagged";;
    5.53+        -n) name=".pkgname";;
    5.54+        -h) help;;
    5.55+        "") break;;
    5.56+    esac
    5.57+    shift
    5.58+done
    5.59+
    5.60+find_packages(){
    5.61+    test ${#filter} -eq 0 && filter=(core extra community multilib)
    5.62+    if ((local_packages)); then
    5.63+        # shellcheck disable=SC2046
    5.64+        expac -S "%r %a %n %e" $(expac %n) | grep -P "^($(tr ' ' '|' <<< "${filter[*]}")) "
    5.65+    else
    5.66+        filter=("${filter[@]^}") # Uppercase the repo names
    5.67+        filter=("${filter[@]/#/&repo=}") # Prepend &repo= to all elements
    5.68+        query="?${maintainer_query}${packager_query}$(printf "%s" "${filter[@]}")&flagged=$out_of_date"
    5.69+        curl -s "https://archlinux.org/packages/search/json/$query" \
    5.70+          | jq -r '.results[] | "\(.repo) \(.arch) \(.pkgname) \(.pkgbase)"' | sort | uniq
    5.71+    fi
    5.72+}
    5.73+
    5.74+while read -r repo arch pkg _; do
    5.75+    # shellcheck disable=SC2016
    5.76+    format="select(.maintainers | length == \$LIMIT) | \"\(${name})\""
    5.77+    if ((see_maintainers)); then
    5.78+      # shellcheck disable=SC2016
    5.79+      format="select(.maintainers | length == \$LIMIT) | \"\(${name})\", (.maintainers | join(\" \"))"
    5.80+    fi
    5.81+    curl -s "https://archlinux.org/packages/$repo/$arch/$pkg/json/" | \
    5.82+        jq -r --argjson LIMIT "$limit_maintainers" "$format"
    5.83+done <<< "$(find_packages | sort -u -k4,4)"
     6.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2+++ b/.stash/scripts/podman-machine-default-update.sh	Wed Jun 19 19:27:14 2024 +0000
     6.3@@ -0,0 +1,2 @@
     6.4+#!/bin/sh
     6.5+podman machine ssh 'sudo rpm-ostree upgrade --bypass-driver'
     7.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2+++ b/.stash/scripts/port-scan.sh	Wed Jun 19 19:27:14 2024 +0000
     7.3@@ -0,0 +1,55 @@
     7.4+#!/bin/bash
     7.5+#Performs port scan using nmap
     7.6+
     7.7+print_usage() {
     7.8+cat << _EOF_
     7.9+        Utility to scan open ports. Can be used to scan ports for a domain or a list of domains specified in a file.
    7.10+        Example Usage:
    7.11+                -h, --help              Show brief help
    7.12+                -d, --domain            Domain name or ip to scan
    7.13+                -f, --file              Spefify a file containing domains/IPs to scan
    7.14+_EOF_
    7.15+}
    7.16+
    7.17+scan_port() {
    7.18+        domain=$1
    7.19+        echo "Scanning ports for $1...."
    7.20+        nmap -sT -T4 $domain | sed '/^\(Nmap scan\|PORT\|[0-9]\)/!d' | tee -a $port_scan_result_file
    7.21+}
    7.22+
    7.23+create_port_scan_result_file() {
    7.24+        port_scan_result_file="/tmp/port-scan-`date "+%Y-%m-%d-%H:%M:%S"`.txt"
    7.25+	touch $port_scan_result_file
    7.26+}
    7.27+
    7.28+while getopts "f:d:" opt; do
    7.29+        case "$opt" in
    7.30+                d) domain=$OPTARG    ;;
    7.31+                f) file=$OPTARG      ;;
    7.32+                *) print_usage; exit 1 ;;
    7.33+        esac
    7.34+done
    7.35+
    7.36+if [ ! -n "$domain" ] && [ ! -f "$file" ]; then
    7.37+        echo "Option -d $domain or -f $file missing or designates to wrong entry" >&2
    7.38+        exit 1
    7.39+fi
    7.40+
    7.41+scan_port_flow() {
    7.42+
    7.43+if [ -n "$domain" ]; then
    7.44+	create_port_scan_result_file
    7.45+	scan_port $domain
    7.46+	echo "Scan result:$port_scan_result_file"
    7.47+fi
    7.48+
    7.49+if [ -n "$file" ]; then
    7.50+	create_port_scan_result_file
    7.51+	for domain in $(cat $file)
    7.52+	do
    7.53+		scan_port $domain
    7.54+	done
    7.55+	echo "Scan result: $port_scan_result_file"
    7.56+fi
    7.57+}
    7.58+scan_port_flow
     8.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2+++ b/.stash/scripts/qmk-flash-moonlander.sh	Wed Jun 19 19:27:14 2024 +0000
     8.3@@ -0,0 +1,3 @@
     8.4+#!/bin/sh
     8.5+cp -rf ~/.config/kbd/moonlander/* ~/qmk_firmware/keyboards/moonlander/keymaps/ellis/
     8.6+qmk flash -kb moonlander -km ellis
     9.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2+++ b/.stash/scripts/sc.sh	Wed Jun 19 19:27:14 2024 +0000
     9.3@@ -0,0 +1,4 @@
     9.4+#!/usr/local/env bash
     9.5+import png:- >> ${1:-"$(date +%s).png"}
     9.6+# take screenshot of current window on sway
     9.7+# swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -g - ${1:-"$(date +%s).png"}
    10.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2+++ b/.stash/scripts/upgrade.sh	Wed Jun 19 19:27:14 2024 +0000
    10.3@@ -0,0 +1,3 @@
    10.4+#!/usr/bin/sh
    10.5+sudo pacman -Syu
    10.6+rustup update
    11.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2+++ b/.stash/scripts/wg-gen-keys.sh	Wed Jun 19 19:27:14 2024 +0000
    11.3@@ -0,0 +1,4 @@
    11.4+#!/bin/sh
    11.5+# generate base64-enc keypair in current dir
    11.6+umask 077
    11.7+wg genkey | tee privatekey | wg pubkey > publickey
    12.1--- a/stash/scripts/gen-libera-cert.sh	Wed Jun 19 15:32:46 2024 -0400
    12.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3@@ -1,2 +0,0 @@
    12.4-#!/bin/sh
    12.5-openssl req -x509 -new -newkey rsa:4096 -sha256 -days 365 -nodes -out libera.pem -keyout libera.pem
    13.1--- a/stash/scripts/genfstab.sh	Wed Jun 19 15:32:46 2024 -0400
    13.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3@@ -1,3 +0,0 @@
    13.4-#!/bin/sh
    13.5-if [$# -eq 0] then genfstab -U -L -p / | less
    13.6-else genfstab -U -L -p / | $1
    14.1--- a/stash/scripts/new-mail.sh	Wed Jun 19 15:32:46 2024 -0400
    14.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3@@ -1,8 +0,0 @@
    14.4-#!/bin/sh
    14.5-attach_cmds=""
    14.6-while [ $# -gt 0 ]; do
    14.7-    fullpath=$(readlink --canonicalize "$1")
    14.8-    attach_cmds="$attach_cmds (mml-attach-file \"$fullpath\")"
    14.9-    shift
   14.10-done
   14.11-emacsclient -a '' -c -e "(progn (compose-mail) $attach_cmds)"
    15.1--- a/stash/scripts/nfs-export.sh	Wed Jun 19 15:32:46 2024 -0400
    15.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3@@ -1,3 +0,0 @@
    15.4-#!/bin/sh
    15.5-exportfs -arv
    15.6-exportfs -v
    16.1--- a/stash/scripts/pacman-pkgsearch.sh	Wed Jun 19 15:32:46 2024 -0400
    16.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3@@ -1,80 +0,0 @@
    16.4-#!/bin/bash
    16.5-
    16.6-# SPDX-License-Identifier: GPL-2.0
    16.7-
    16.8-set -o errexit
    16.9-shopt -s extglob
   16.10-
   16.11-help(){
   16.12-    cat << EOF 
   16.13-Usage:
   16.14-  $PROGRAM
   16.15-Flags:
   16.16-    -m [maintainer]     find packages from maintainer
   16.17-    -p [packager]       find packages from the last packager
   16.18-    -q                  local packages
   16.19-    -s                  print the package maintainers
   16.20-    -l [limit]          co-maintainer limit to filter on default: 1
   16.21-    -f [repository]     filter on repository, Default: core extra multilib community
   16.22-    -o                  list flagged packages
   16.23-    -n                  use pkgname instead of pkgbase (not recommended as we sort away split pkgs)
   16.24-    -h                  help messages
   16.25-Example:
   16.26-    Packages from a maintainer with 2 maintainers
   16.27-    $ pkgsearch -m Foxboron -l 2
   16.28-    Orphaned packages in [extra]
   16.29-    $ pkgsearch -f extra -l 0 -m orphan
   16.30-    Packages installed on the system from [core] with 1 maintainer
   16.31-    $ pkgsearch -q -f core -l 1
   16.32-    Locally installed packages from [community], orphaned, and flagged out-of-date 
   16.33-    $ pkgsearch -q -f community -l 0 -m orphan -o
   16.34-EOF
   16.35-}
   16.36-
   16.37-
   16.38-limit_maintainers=1
   16.39-see_maintainers=0
   16.40-out_of_date=""
   16.41-name=".pkgbase"
   16.42-filter=()
   16.43-
   16.44-while true; do
   16.45-    case "$1" in
   16.46-        -m) shift; maintainer_query="maintainer=$1" ;;
   16.47-        -p) shift; packager_query="&packager=$1" ;;
   16.48-        -q) local_packages=1;;
   16.49-        -s) see_maintainers=1;;
   16.50-        -l) shift; limit_maintainers=$1;;
   16.51-        -f) shift; filter+=("${1,,}");;
   16.52-        -o) out_of_date="Flagged";;
   16.53-        -n) name=".pkgname";;
   16.54-        -h) help;;
   16.55-        "") break;;
   16.56-    esac
   16.57-    shift
   16.58-done
   16.59-
   16.60-find_packages(){
   16.61-    test ${#filter} -eq 0 && filter=(core extra community multilib)
   16.62-    if ((local_packages)); then
   16.63-        # shellcheck disable=SC2046
   16.64-        expac -S "%r %a %n %e" $(expac %n) | grep -P "^($(tr ' ' '|' <<< "${filter[*]}")) "
   16.65-    else
   16.66-        filter=("${filter[@]^}") # Uppercase the repo names
   16.67-        filter=("${filter[@]/#/&repo=}") # Prepend &repo= to all elements
   16.68-        query="?${maintainer_query}${packager_query}$(printf "%s" "${filter[@]}")&flagged=$out_of_date"
   16.69-        curl -s "https://archlinux.org/packages/search/json/$query" \
   16.70-          | jq -r '.results[] | "\(.repo) \(.arch) \(.pkgname) \(.pkgbase)"' | sort | uniq
   16.71-    fi
   16.72-}
   16.73-
   16.74-while read -r repo arch pkg _; do
   16.75-    # shellcheck disable=SC2016
   16.76-    format="select(.maintainers | length == \$LIMIT) | \"\(${name})\""
   16.77-    if ((see_maintainers)); then
   16.78-      # shellcheck disable=SC2016
   16.79-      format="select(.maintainers | length == \$LIMIT) | \"\(${name})\", (.maintainers | join(\" \"))"
   16.80-    fi
   16.81-    curl -s "https://archlinux.org/packages/$repo/$arch/$pkg/json/" | \
   16.82-        jq -r --argjson LIMIT "$limit_maintainers" "$format"
   16.83-done <<< "$(find_packages | sort -u -k4,4)"
    17.1--- a/stash/scripts/podman-machine-default-update.sh	Wed Jun 19 15:32:46 2024 -0400
    17.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3@@ -1,2 +0,0 @@
    17.4-#!/bin/sh
    17.5-podman machine ssh 'sudo rpm-ostree upgrade --bypass-driver'
    18.1--- a/stash/scripts/port-scan.sh	Wed Jun 19 15:32:46 2024 -0400
    18.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3@@ -1,55 +0,0 @@
    18.4-#!/bin/bash
    18.5-#Performs port scan using nmap
    18.6-
    18.7-print_usage() {
    18.8-cat << _EOF_
    18.9-        Utility to scan open ports. Can be used to scan ports for a domain or a list of domains specified in a file.
   18.10-        Example Usage:
   18.11-                -h, --help              Show brief help
   18.12-                -d, --domain            Domain name or ip to scan
   18.13-                -f, --file              Spefify a file containing domains/IPs to scan
   18.14-_EOF_
   18.15-}
   18.16-
   18.17-scan_port() {
   18.18-        domain=$1
   18.19-        echo "Scanning ports for $1...."
   18.20-        nmap -sT -T4 $domain | sed '/^\(Nmap scan\|PORT\|[0-9]\)/!d' | tee -a $port_scan_result_file
   18.21-}
   18.22-
   18.23-create_port_scan_result_file() {
   18.24-        port_scan_result_file="/tmp/port-scan-`date "+%Y-%m-%d-%H:%M:%S"`.txt"
   18.25-	touch $port_scan_result_file
   18.26-}
   18.27-
   18.28-while getopts "f:d:" opt; do
   18.29-        case "$opt" in
   18.30-                d) domain=$OPTARG    ;;
   18.31-                f) file=$OPTARG      ;;
   18.32-                *) print_usage; exit 1 ;;
   18.33-        esac
   18.34-done
   18.35-
   18.36-if [ ! -n "$domain" ] && [ ! -f "$file" ]; then
   18.37-        echo "Option -d $domain or -f $file missing or designates to wrong entry" >&2
   18.38-        exit 1
   18.39-fi
   18.40-
   18.41-scan_port_flow() {
   18.42-
   18.43-if [ -n "$domain" ]; then
   18.44-	create_port_scan_result_file
   18.45-	scan_port $domain
   18.46-	echo "Scan result:$port_scan_result_file"
   18.47-fi
   18.48-
   18.49-if [ -n "$file" ]; then
   18.50-	create_port_scan_result_file
   18.51-	for domain in $(cat $file)
   18.52-	do
   18.53-		scan_port $domain
   18.54-	done
   18.55-	echo "Scan result: $port_scan_result_file"
   18.56-fi
   18.57-}
   18.58-scan_port_flow
    19.1--- a/stash/scripts/qmk-flash-moonlander.sh	Wed Jun 19 15:32:46 2024 -0400
    19.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3@@ -1,3 +0,0 @@
    19.4-#!/bin/sh
    19.5-cp -rf ~/.config/kbd/moonlander/* ~/qmk_firmware/keyboards/moonlander/keymaps/ellis/
    19.6-qmk flash -kb moonlander -km ellis
    20.1--- a/stash/scripts/sc.sh	Wed Jun 19 15:32:46 2024 -0400
    20.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3@@ -1,4 +0,0 @@
    20.4-#!/usr/local/env bash
    20.5-import png:- >> ${1:-"$(date +%s).png"}
    20.6-# take screenshot of current window on sway
    20.7-# swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -g - ${1:-"$(date +%s).png"}
    21.1--- a/stash/scripts/upgrade.sh	Wed Jun 19 15:32:46 2024 -0400
    21.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3@@ -1,3 +0,0 @@
    21.4-#!/usr/bin/sh
    21.5-sudo pacman -Syu
    21.6-rustup update
    22.1--- a/stash/scripts/wg-gen-keys.sh	Wed Jun 19 15:32:46 2024 -0400
    22.2+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3@@ -1,4 +0,0 @@
    22.4-#!/bin/sh
    22.5-# generate base64-enc keypair in current dir
    22.6-umask 077
    22.7-wg genkey | tee privatekey | wg pubkey > publickey