From e2a0cf2a79b43f9f86b74270f3d96fe300687804 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sat, 20 Jan 2024 12:31:58 -0500 Subject: Cleanup unused files and code. --- scripts/httpsvr | 68 --------------------------------------------- scripts/key-check.sh | 12 -------- scripts/readme.md | 3 -- scripts/snap-btrfs.sh | 23 ---------------- scripts/snap-lvm.sh | 31 --------------------- scripts/syncthing-cert.sh | 70 ----------------------------------------------- scripts/webhook.py | 70 ----------------------------------------------- 7 files changed, 277 deletions(-) delete mode 100755 scripts/httpsvr delete mode 100755 scripts/key-check.sh delete mode 100644 scripts/readme.md delete mode 100755 scripts/snap-btrfs.sh delete mode 100755 scripts/snap-lvm.sh delete mode 100644 scripts/syncthing-cert.sh delete mode 100755 scripts/webhook.py (limited to 'scripts') diff --git a/scripts/httpsvr b/scripts/httpsvr deleted file mode 100755 index ffc816a..0000000 --- a/scripts/httpsvr +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -# Stupid basic http server using OpenBSD netcat -set -e - -PORT="${PORT:-8900}" -ADDR="${ADDR:-127.0.0.1}" - -ncpid= - -send_index() { -cat < - - - - Netcat HTTP - - - Minimal HTTP server in posix SH and OpenBSD's netcat - - -EOF -} - -cleanup() { - set +e - kill "$ncpid" >/dev/null 2>&1 - rm "$_f" "$_inF" >/dev/null 2>&1 - exit 0 -} -trap cleanup EXIT INT - -while true ; do - _f="$(mktemp)" - - _inF="$(mktemp)" - rm -f "$_inF" - mkfifo "$_inF" - - #shellcheck disable=SC2002 - cat "$_inF" | nc -l "$ADDR" "$PORT" > "$_f" & # | tee /dev/fd/2 >"$_f" & - ncpid=$! - - counter=0 - while [ $counter -lt 100 ] || [ -s "$_f" ] ; do - if grep -qi "^Accept:" "$_f" ; then - pth="$(sed -nre 's@^GET ([^ ][^ ]*) HTTP/1.1.*@\1@gp' < "$_f")" - - echo "Request for path: $pth" - - case $pth in - /) send_index >"$_inF" ;; - esac - - break - fi - sleep .01 - [ -s "$_f" ] && counter=$((counter += 1)) - ps $ncpid >/dev/null 2>&1 || break - done - - kill $ncpid || echo "" - rm "$_f" "$_inF" -done diff --git a/scripts/key-check.sh b/scripts/key-check.sh deleted file mode 100755 index 1672bc4..0000000 --- a/scripts/key-check.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Check for a public key, and create one for the user if it -# does not exist. Spit the key in red to stdout. Not so much for me, -# but as a convienient script to give to others who aren't so familiar -# with how SSH key authorization works. - -keyf="$HOME/.ssh/id_ed25519"; -! [ -e "$keyf" ] && ssh-keygen -t ed25519 -f "$keyf" -P ""; -printf '\033[1;31m%s\033[0m\n' "$(cat "$keyf.pub")"; - -# One line version for pasting into chat: -# keyf="$HOME/.ssh/id_ed25519"; ! [ -e "$keyf" ] && ssh-keygen -t ed25519 -f "$keyf" -P ""; printf '\033[1;31m%s\033[0m\n' "$(cat "$keyf.pub")"; diff --git a/scripts/readme.md b/scripts/readme.md deleted file mode 100644 index 60c79c1..0000000 --- a/scripts/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# scripts - -A couple of misc scripts that may be of some utility. diff --git a/scripts/snap-btrfs.sh b/scripts/snap-btrfs.sh deleted file mode 100755 index cc2e5a9..0000000 --- a/scripts/snap-btrfs.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -set -x -set -e -timestamp() { - date +%m.%d.%y_%H.%M.%S -} - -rootfs="glibc" -snap="${rootfs}-snap" - -cd /ROOT - -if [ -e "$snap" ] ; then - btrfs sub del "$snap" -fi - -if ! [ -e "bak" ] ; then - btrfs sub create "bak" -fi - -btrfs sub snap -r "$rootfs" "bak/${rootfs}-$(timestamp)" -btrfs sub snap "$rootfs" "$snap" -sed -i.bak -e"s/subvol=${rootfs}/subvol=${snap}/g" "${snap}/etc/fstab" diff --git a/scripts/snap-lvm.sh b/scripts/snap-lvm.sh deleted file mode 100755 index 4991495..0000000 --- a/scripts/snap-lvm.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -set -e - -vg="x230" -lv="root" -snap_name="${lv}-snap" -mountpoint="/mnt/snap" -PERCENT="100" - -mount_fs() { - _device="$1"; shift - _opts="nouuid,rw" - _mntpoint="$1"; shift - if ! [ -d "$_mntpoint" ] ; then - mkdir "$_mntpoint" - fi - mount -o "$_opts" "$_device" "$_mntpoint" -} - -# If snapshot doesn't exist -if ! lvm lvs "$vg/$snap_name" >/dev/null 2>&1 ; then - lvm lvcreate "$vg/$lv" -s --name "$snap_name" -l "${PERCENT}%ORIGIN" - mount_fs "/dev/$vg/$snap_name" "$mountpoint" - sed -i.bak -r "s@(/dev/${vg}/${lv})@\1${snap_name}@" \ - "$mountpoint/etc/fstab" - umount "$mountpoint" -else - printf 'Cannot continue snapshot "%s" already exists.\n' \ - "$vg/$snap_name" - exit 1; -fi diff --git a/scripts/syncthing-cert.sh b/scripts/syncthing-cert.sh deleted file mode 100644 index 0dd460b..0000000 --- a/scripts/syncthing-cert.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh -set -e -days="3650" -keyout="syncthing.key" -reqout="$(mktemp)" -certout="syncthing.crt" -alg="ED25519" - -help() { -cat < ] [ -k ] [ -448 ] -Defaults are: -certificate_out: 'syncthing.crt' -key_out: 'syncthing.key' - -Optionally, the -448 option will generate an ED448 key instead of ED25519. - -EOF -exit 1 -} - -while [ $# -gt 0 ] ; do case $1 in - -c) certout="$2" ; shift ; shift ;; - -k) keyout="$2" ; shift ; shift ;; - -448) alg="ED448"; shift ;; - *) help ;; -esac ; done - -v3Section=" -basicConstraints = CA:FALSE -keyUsage = digitalSignature, keyEncipherment, dataEncipherment -extendedKeyUsage = serverAuth, clientAuth -subjectAltName = @alt_names -[alt_names] -DNS.1 = syncthing -" - -openssl genpkey -algorithm $alg > "$keyout" - -cnf="$(mktemp)" -cat > "$cnf" < "$extfile" <