changelog shortlog graph tags branches files raw help

Mercurial > infra > home / changeset: added scripts

changeset 6: 45f3b1bc3cd7
parent 5: 40ad5e17f337
child 7: d0058e5787b5
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 10 May 2024 19:54:12 -0400
files: .skelrc .stumpwm.d/init.lisp 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: added scripts
     1.1--- a/.skelrc	Wed May 01 19:50:45 2024 -0400
     1.2+++ b/.skelrc	Fri May 10 19:54:12 2024 -0400
     1.3@@ -8,11 +8,12 @@
     1.4 :auto-insert t
     1.5 :license :mpl2
     1.6 :log-level :info
     1.7-:shed "~/shed"
     1.8-:stash "~/stash"
     1.9-:cache "~/.cache/skel"
    1.10+:shed ".shed"
    1.11+:stash ".stash"
    1.12+:scratch ".stash/scratch"
    1.13+:cache ".cache"
    1.14 :registry "~/.data/skel/registry"
    1.15-:scripts "/usr/local/stash/scripts"
    1.16+:scripts ("/usr/local/share/stash/scripts" "~/stash/scripts")
    1.17 :alias-list
    1.18 (("p" "vc push")
    1.19  ("P" "vc pull")
     2.1--- a/.stumpwm.d/init.lisp	Wed May 01 19:50:45 2024 -0400
     2.2+++ b/.stumpwm.d/init.lisp	Fri May 10 19:54:12 2024 -0400
     2.3@@ -8,6 +8,7 @@
     2.4       *startup-message* "Greetings, stranger.")
     2.5 
     2.6 ;; (set-font "CommitMono")
     2.7+(set-module-dir "/usr/share/stupmwm/contrib/")
     2.8 (init-load-path *module-dir*)
     2.9 
    2.10 (setf *window-format* "%m%n%s%c")
    2.11@@ -21,3 +22,14 @@
    2.12 
    2.13 (when *initializing*
    2.14   (run-shell-command "sh ~/.fehbg"))
    2.15+
    2.16+(which-key-mode)
    2.17+
    2.18+(defcommand term (&optional program) ()
    2.19+  (sb-thread:make-thread
    2.20+   (lambda ()
    2.21+     (run-shell-command (if program
    2.22+                            (format nil "alacritty ~A" program)
    2.23+                            "alacritty")))))
    2.24+
    2.25+(define-key *root-map* (kbd "c") "term")
     3.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2+++ b/stash/scripts/gen-libera-cert.sh	Fri May 10 19:54:12 2024 -0400
     3.3@@ -0,0 +1,2 @@
     3.4+#!/bin/sh
     3.5+openssl req -x509 -new -newkey rsa:4096 -sha256 -days 365 -nodes -out libera.pem -keyout libera.pem
     4.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2+++ b/stash/scripts/genfstab.sh	Fri May 10 19:54:12 2024 -0400
     4.3@@ -0,0 +1,3 @@
     4.4+#!/bin/sh
     4.5+if [$# -eq 0] then genfstab -U -L -p / | less
     4.6+else genfstab -U -L -p / | $1
     5.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2+++ b/stash/scripts/new-mail.sh	Fri May 10 19:54:12 2024 -0400
     5.3@@ -0,0 +1,8 @@
     5.4+#!/bin/sh
     5.5+attach_cmds=""
     5.6+while [ $# -gt 0 ]; do
     5.7+    fullpath=$(readlink --canonicalize "$1")
     5.8+    attach_cmds="$attach_cmds (mml-attach-file \"$fullpath\")"
     5.9+    shift
    5.10+done
    5.11+emacsclient -a '' -c -e "(progn (compose-mail) $attach_cmds)"
     6.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2+++ b/stash/scripts/nfs-export.sh	Fri May 10 19:54:12 2024 -0400
     6.3@@ -0,0 +1,3 @@
     6.4+#!/bin/sh
     6.5+exportfs -arv
     6.6+exportfs -v
     7.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2+++ b/stash/scripts/pacman-pkgsearch.sh	Fri May 10 19:54:12 2024 -0400
     7.3@@ -0,0 +1,80 @@
     7.4+#!/bin/bash
     7.5+
     7.6+# SPDX-License-Identifier: GPL-2.0
     7.7+
     7.8+set -o errexit
     7.9+shopt -s extglob
    7.10+
    7.11+help(){
    7.12+    cat << EOF 
    7.13+Usage:
    7.14+  $PROGRAM
    7.15+Flags:
    7.16+    -m [maintainer]     find packages from maintainer
    7.17+    -p [packager]       find packages from the last packager
    7.18+    -q                  local packages
    7.19+    -s                  print the package maintainers
    7.20+    -l [limit]          co-maintainer limit to filter on default: 1
    7.21+    -f [repository]     filter on repository, Default: core extra multilib community
    7.22+    -o                  list flagged packages
    7.23+    -n                  use pkgname instead of pkgbase (not recommended as we sort away split pkgs)
    7.24+    -h                  help messages
    7.25+Example:
    7.26+    Packages from a maintainer with 2 maintainers
    7.27+    $ pkgsearch -m Foxboron -l 2
    7.28+    Orphaned packages in [extra]
    7.29+    $ pkgsearch -f extra -l 0 -m orphan
    7.30+    Packages installed on the system from [core] with 1 maintainer
    7.31+    $ pkgsearch -q -f core -l 1
    7.32+    Locally installed packages from [community], orphaned, and flagged out-of-date 
    7.33+    $ pkgsearch -q -f community -l 0 -m orphan -o
    7.34+EOF
    7.35+}
    7.36+
    7.37+
    7.38+limit_maintainers=1
    7.39+see_maintainers=0
    7.40+out_of_date=""
    7.41+name=".pkgbase"
    7.42+filter=()
    7.43+
    7.44+while true; do
    7.45+    case "$1" in
    7.46+        -m) shift; maintainer_query="maintainer=$1" ;;
    7.47+        -p) shift; packager_query="&packager=$1" ;;
    7.48+        -q) local_packages=1;;
    7.49+        -s) see_maintainers=1;;
    7.50+        -l) shift; limit_maintainers=$1;;
    7.51+        -f) shift; filter+=("${1,,}");;
    7.52+        -o) out_of_date="Flagged";;
    7.53+        -n) name=".pkgname";;
    7.54+        -h) help;;
    7.55+        "") break;;
    7.56+    esac
    7.57+    shift
    7.58+done
    7.59+
    7.60+find_packages(){
    7.61+    test ${#filter} -eq 0 && filter=(core extra community multilib)
    7.62+    if ((local_packages)); then
    7.63+        # shellcheck disable=SC2046
    7.64+        expac -S "%r %a %n %e" $(expac %n) | grep -P "^($(tr ' ' '|' <<< "${filter[*]}")) "
    7.65+    else
    7.66+        filter=("${filter[@]^}") # Uppercase the repo names
    7.67+        filter=("${filter[@]/#/&repo=}") # Prepend &repo= to all elements
    7.68+        query="?${maintainer_query}${packager_query}$(printf "%s" "${filter[@]}")&flagged=$out_of_date"
    7.69+        curl -s "https://archlinux.org/packages/search/json/$query" \
    7.70+          | jq -r '.results[] | "\(.repo) \(.arch) \(.pkgname) \(.pkgbase)"' | sort | uniq
    7.71+    fi
    7.72+}
    7.73+
    7.74+while read -r repo arch pkg _; do
    7.75+    # shellcheck disable=SC2016
    7.76+    format="select(.maintainers | length == \$LIMIT) | \"\(${name})\""
    7.77+    if ((see_maintainers)); then
    7.78+      # shellcheck disable=SC2016
    7.79+      format="select(.maintainers | length == \$LIMIT) | \"\(${name})\", (.maintainers | join(\" \"))"
    7.80+    fi
    7.81+    curl -s "https://archlinux.org/packages/$repo/$arch/$pkg/json/" | \
    7.82+        jq -r --argjson LIMIT "$limit_maintainers" "$format"
    7.83+done <<< "$(find_packages | sort -u -k4,4)"
     8.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2+++ b/stash/scripts/podman-machine-default-update.sh	Fri May 10 19:54:12 2024 -0400
     8.3@@ -0,0 +1,2 @@
     8.4+#!/bin/sh
     8.5+podman machine ssh 'sudo rpm-ostree upgrade --bypass-driver'
     9.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2+++ b/stash/scripts/port-scan.sh	Fri May 10 19:54:12 2024 -0400
     9.3@@ -0,0 +1,55 @@
     9.4+#!/bin/bash
     9.5+#Performs port scan using nmap
     9.6+
     9.7+print_usage() {
     9.8+cat << _EOF_
     9.9+        Utility to scan open ports. Can be used to scan ports for a domain or a list of domains specified in a file.
    9.10+        Example Usage:
    9.11+                -h, --help              Show brief help
    9.12+                -d, --domain            Domain name or ip to scan
    9.13+                -f, --file              Spefify a file containing domains/IPs to scan
    9.14+_EOF_
    9.15+}
    9.16+
    9.17+scan_port() {
    9.18+        domain=$1
    9.19+        echo "Scanning ports for $1...."
    9.20+        nmap -sT -T4 $domain | sed '/^\(Nmap scan\|PORT\|[0-9]\)/!d' | tee -a $port_scan_result_file
    9.21+}
    9.22+
    9.23+create_port_scan_result_file() {
    9.24+        port_scan_result_file="/tmp/port-scan-`date "+%Y-%m-%d-%H:%M:%S"`.txt"
    9.25+	touch $port_scan_result_file
    9.26+}
    9.27+
    9.28+while getopts "f:d:" opt; do
    9.29+        case "$opt" in
    9.30+                d) domain=$OPTARG    ;;
    9.31+                f) file=$OPTARG      ;;
    9.32+                *) print_usage; exit 1 ;;
    9.33+        esac
    9.34+done
    9.35+
    9.36+if [ ! -n "$domain" ] && [ ! -f "$file" ]; then
    9.37+        echo "Option -d $domain or -f $file missing or designates to wrong entry" >&2
    9.38+        exit 1
    9.39+fi
    9.40+
    9.41+scan_port_flow() {
    9.42+
    9.43+if [ -n "$domain" ]; then
    9.44+	create_port_scan_result_file
    9.45+	scan_port $domain
    9.46+	echo "Scan result:$port_scan_result_file"
    9.47+fi
    9.48+
    9.49+if [ -n "$file" ]; then
    9.50+	create_port_scan_result_file
    9.51+	for domain in $(cat $file)
    9.52+	do
    9.53+		scan_port $domain
    9.54+	done
    9.55+	echo "Scan result: $port_scan_result_file"
    9.56+fi
    9.57+}
    9.58+scan_port_flow
    10.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2+++ b/stash/scripts/qmk-flash-moonlander.sh	Fri May 10 19:54:12 2024 -0400
    10.3@@ -0,0 +1,3 @@
    10.4+#!/bin/sh
    10.5+cp -rf ~/.config/kbd/moonlander/* ~/qmk_firmware/keyboards/moonlander/keymaps/ellis/
    10.6+qmk flash -kb moonlander -km ellis
    11.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2+++ b/stash/scripts/sc.sh	Fri May 10 19:54:12 2024 -0400
    11.3@@ -0,0 +1,4 @@
    11.4+#!/usr/local/env bash
    11.5+import png:- >> ${1:-"$(date +%s).png"}
    11.6+# take screenshot of current window on sway
    11.7+# swaymsg -t get_tree | jq -r '.. | select(.focused?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | grim -g - ${1:-"$(date +%s).png"}
    12.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2+++ b/stash/scripts/upgrade.sh	Fri May 10 19:54:12 2024 -0400
    12.3@@ -0,0 +1,3 @@
    12.4+#!/usr/bin/sh
    12.5+sudo pacman -Syu
    12.6+rustup update
    13.1--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2+++ b/stash/scripts/wg-gen-keys.sh	Fri May 10 19:54:12 2024 -0400
    13.3@@ -0,0 +1,4 @@
    13.4+#!/bin/sh
    13.5+# generate base64-enc keypair in current dir
    13.6+umask 077
    13.7+wg genkey | tee privatekey | wg pubkey > publickey