From cb4d795bf5944a6632b204659915ff2d9628b2d0 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Mon, 13 Feb 2023 15:31:22 -0600 Subject: chore: remove unused scripts --- wsl/.local/bin/discord-relay.sh | 3 - wsl/.local/bin/gpg-test.sh | 102 --------------- wsl/.local/bin/socket-relay.sh | 270 ---------------------------------------- 3 files changed, 375 deletions(-) delete mode 100755 wsl/.local/bin/discord-relay.sh delete mode 100644 wsl/.local/bin/gpg-test.sh delete mode 100755 wsl/.local/bin/socket-relay.sh (limited to 'wsl') diff --git a/wsl/.local/bin/discord-relay.sh b/wsl/.local/bin/discord-relay.sh deleted file mode 100755 index d0f8cc6..0000000 --- a/wsl/.local/bin/discord-relay.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec socat UNIX-LISTEN:/var/run/discord-ipc-0,fork,group=discord,umask=007 EXEC:"/home/tobyv/.local/bin/npiperelay.exe -ep -s //./pipe/discord-ipc-0",nofork diff --git a/wsl/.local/bin/gpg-test.sh b/wsl/.local/bin/gpg-test.sh deleted file mode 100644 index f23b83d..0000000 --- a/wsl/.local/bin/gpg-test.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env bash - -TEMP=$(getopt -o hvdsea: --long help,verbose,debug,signature,encryption,authentication \ - -n 'javawrap' -- "$@") - -if [ $? != 0 ]; then - echo "Terminating..." >&2 - exit 1 -fi - -eval set -- "$TEMP" - -usage() { - cat <$temp/test.txt - - result="$(gpg --output $temp/test.gpg -e $temp/test.txt 2>&1 && gpg --output $temp/test.out -d $temp/test.txt.gpg 2>&1)" - grep '42' $temp/test.out 2>&1 - print_result result -fi - -if [[ $ALL -eq "true" || $AUTHENTICATION -eq "true" ]]; then - echo "Testing authentication key..." - result="$(ssh-add -l)" - print_result result -fi diff --git a/wsl/.local/bin/socket-relay.sh b/wsl/.local/bin/socket-relay.sh deleted file mode 100755 index dc6e177..0000000 --- a/wsl/.local/bin/socket-relay.sh +++ /dev/null @@ -1,270 +0,0 @@ -#!/usr/bin/env sh -set -e - -OPTS=$(getopt -o hvs:a:x: --long help,verbose,sock:,args:,exec:,ssh,gpg,gpg-extra,gpg-ssh,gpg-browser,discord -n 'javawrap' -- "$@") - -eval set -- "$OPTS" - -GPG_AGENT_SOCK="${GPG_AGENT_SOCK:-$HOME/.gnupg/S.gpg-agent}" -# SSH_AUTH_SOCK="${SSH_AUTH_SOCK:-$HOME/.ssh/agent.sock}" -SSH_AUTH_SOCK="$GPG_AGENT_SOCK.ssh" -DISCORD_IPC_SOCK="${DISCORD_IPC_SOCK:-/var/run/discord-ipc-0}" -PAGEANT="$HOME/.ssh/wsl2-ssh-pageant.exe" -NPIPE="$(command -v npiperelay.exe)" -SCRIPT="$(basename "$0")" - -help() { - cat <<-EOF - $SCRIPT - Toby Vincent - - $SCRIPT description - - USAGE: - $SCRIPT [OPTIONS] - $SCRIPT [OPTIONS] - - OPTIONS: - -h, --help Display this message - -s, --sock Path to the linux socket - -x, --exec Command to run for socat's EXEC: arg - --ssh Relay the ssh agent's socket - --gpg Relay the gpg agent's socket - --gpg-extra Relay the gpg agent's extra socket - - ARGS: - status - Check the status of the socat process - start (default) - Start the socat process - stop - Kill the socat process - restart - Same as $($SCRIPT stop && $SCRIPT start) - EOF -} - -say() { - if ! $quiet; then - echo "$SCRIPT: $1" - fi -} - -say_verbose() { - if $verbose; then - say "$@" - fi -} - -say_err() { - say "$1" >&2 -} - -err() { - # shellcheck disable=2145 - say_err "ERROR: $@" - exit 1 -} - -need() { - for need_cmd in "$@"; do - if ! command -v "$need_cmd" >/dev/null 2>&1; then - err "need $need_cmd (command not found)" - fi - done -} - -start() { - say_verbose "SOCKET: $sock" - say_verbose "ARGS: $args" - say_verbose "EXEC: $exec" - - if [ -z "$exec" ]; then - err "No EXEC provided. Must supply either one of the preset options, or provide an explicit value with --exec" - fi - - if [ -z "$sock" ]; then - err "No socket provided." - fi - - if ! command -v "$relay" >/dev/null 2>&1; then - err "$relay is not executable." - fi - - if ! pgrep -fa "socat.*$sock.*$relay,"; then - rm -rf "$sock" - (setsid nohup socat UNIX-LISTEN:"${sock},${args}" EXEC:"$exec" >/dev/null 2>&1 &) - fi - - if $gpg; then - gpg-connect-agent.exe /bye >"$v_stdout" 2>"$v_stderr" - fi -} - -stop() { - if [ -z "$sock" ]; then - err "No socket provided." - fi - - if [ -z "$relay" ]; then - err "No exec provided" - fi - - if $gpg; then - gpg-connect-agent.exe KILLAGENT /bye >"$v_stdout" 2>"$v_stderr" - fi - - pkill -fe "socat.*$sock.*$relay" >"$v_stdout" - - rm -rf "$sock" -} - -status() { - proc="socat.*${sock:-}.*${relay:-}" - - if ! pgrep -fa "$proc"; then - say_err "No process found" - return 1 - fi -} - -quiet=false -verbose=false -sock="" -exec="" -gpg=false -gpg_extra=false -gpg_ssh=false -gpg_browser=false -ssh=false -discord=false -v_stdout=/dev/null -v_stderr=/dev/null -while test $# -gt 0; do - case $1 in - -h | --help) - help - return 0 - ;; - -q | --quiet) - quiet=true - shift - ;; - -v | --verbose) - verbose=true - v_stdout=/dev/stdout - v_stderr=/dev/stderr - shift - ;; - -s | --sock) - sock=$2 - shift - shift - ;; - -l | --args) - args=$2 - shift - shift - ;; - -x | --exec) - exec=$2 - shift - shift - ;; - --ssh) - ssh=true - shift - ;; - --gpg) - gpg=true - shift - ;; - --gpg-extra) - gpg=true - gpg_extra=true - shift - ;; - --gpg-ssh) - gpg=true - gpg_ssh=true - shift - ;; - --gpg-browser) - gpg=true - gpg_browser=true - shift - ;; - --discord) - discord=true - shift - ;; - --) - shift - break - ;; - *) - help - exit 1 - ;; - esac -done - -need ss -need socat - -if $ssh; then - need "$PAGEANT" - - sock="${ssh_sock:-$SSH_AUTH_SOCK}" - args="${ssh_args:-fork}" - exec="${ssh_exec:-$PAGEANT}" -elif $gpg; then - need "$PAGEANT" - need "gpg-connect-agent.exe" - - config_path="C\:/Users/$USER/AppData/Local/gnupg" - case ${1:-'start'} in - "$gpg_extra") - sock="${gpg_sock:-$GPG_AGENT_SOCK}.extra" - ;; - "$gpg_ssh") - sock="${gpg_sock:-$GPG_AGENT_SOCK}.ssh" - ;; - "$gpg_browser") - sock="${gpg_sock:-$GPG_AGENT_SOCK}.browser" - ;; - *) - sock="${gpg_sock:-$GPG_AGENT_SOCK}" - ;; - esac - args="${gpg_args:-fork}" - exec="${gpg_exec:-$PAGEANT --gpgConfigBasepath ${config_path} --gpg $(basename "$sock")}" -elif $discord; then - need "$NPIPE" - - sock="${DISCORD_IPC_SOCK:-/var/run/discord-ipc-0}" - exec="$NPIPE -ep -s //./pipe/$(basename "$sock")" - args="fork,group=discord,umask=007" -fi - -relay="$(echo "$exec" | head -n1 | awk '{print $1;}')" - -case ${1:-'start'} in -status) - status - ;; -start) - start - ;; -stop) - stop - ;; -restart) - stop - start - ;; -*) - help - exit 1 - ;; -esac -- cgit v1.2.3-70-g09d2