commit 0ad82aae19b7411d5d9a376a6c5fdcdeb24d9f31 from: Oliver Lowe date: Mon Jul 25 08:38:00 2022 UTC initial commit commit - /dev/null commit + 0ad82aae19b7411d5d9a376a6c5fdcdeb24d9f31 blob - /dev/null blob + e0699a903ae0de79d93b7c2ad0964570cbc981e1 (mode 755) --- /dev/null +++ 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 blob - /dev/null blob + eacbf7ce77da901ba9137821246db761e9de03b6 (mode 644) --- /dev/null +++ install.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +mkdir -p $HOME/bin +cp bin/* $HOME/bin + +cp lib/git $HOME/.config/git/config blob - /dev/null blob + 8300e2a571c953e56413eb314685b2ca8fcb172b (mode 644) --- /dev/null +++ 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