x

Programs, configuration and documentation that don't fit anywhere else
Log | Files | Refs | README | LICENSE

commit 0ad82aae19b7411d5d9a376a6c5fdcdeb24d9f31
Author: Oliver Lowe <o@olowe.co>
Date:   Mon, 25 Jul 2022 18:38:00 +1000

initial commit

Diffstat:
Abin/knocknocauth | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ainstall.sh | 6++++++
Alib/git | 12++++++++++++
3 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/bin/knocknocauth b/bin/knocknocauth @@ -0,0 +1,66 @@ +#!/bin/sh + +usage="usage: knocknocauth [-c] host ..." + +jsonheader="Content-Type: application/json" + +args=`getopt c $*` +if test $? -ne 0 +then + echo "$usage" >&2 + exit 2 +fi +set -- $args +while test $# -ne 0 +do + case "$1" + in + -c) + close="$1"; shift;; + --) + shift; break;; + esac +done + +if test "$#" -eq 0 +then + echo "$usage" >&2 + exit 2 +fi + +configdir="$HOME/.config/knocknoc" + +cachedir="$HOME/.cache/knocknoc" +mkdir -p "$cachedir" + +for host in $@ +do + if test "$close" + then + if ! test -f "$cachedir/$host" + then + echo "no session cookie for $host" >&2 + continue + fi + echo "closing sessions not implemented yet" + exit 1 + # curl -v -X POST -b "$cachedir/$host" "https://$host/logout" + continue + fi + + if test -f "$configdir/$host" + then + file="$configdir/$host" + username=`sed -n 1p $file` + password=`sed -n 2p $file` + else + # read in bash(1) + # read -p "$host username: " username + # read -p "$username's password: " password + # for read on ksh(1) e.g. OpenBSD + read username?"$host username: " + read password?"$username's password: " + fi + body="{\"UserName\": \"$username\", \"Password\": \"$password\"}" + curl -s -H "$jsonheader" -d "$body" -c "$cachedir/$host" "https://$host/login" +done diff --git a/install.sh b/install.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +mkdir -p $HOME/bin +cp bin/* $HOME/bin + +cp lib/git $HOME/.config/git/config diff --git a/lib/git b/lib/git @@ -0,0 +1,12 @@ +[core] + pager = "9 nobs" +[user] + email = o@olowe.co +[alias] + co = checkout + st = status + ci = commit + up = pull -r + b = branch +[fetch] + prune = true