feature(unitproc) Add legacy unit process scripts
[BK-2020-03.git] / unitproc / bkgenpass
diff --git a/unitproc/bkgenpass b/unitproc/bkgenpass
new file mode 100755 (executable)
index 0000000..077a88b
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+# 2019-08-23T00:36Z; baltakatei> 
+
+# This bash script should prompt the user for a URL, email address,
+# user name, text notes, and then generate a password, push this
+# password into the x clipboard, and then save a text file containing
+# the prompted details. This script should be run by Debian-based
+# GNU/Linux machines owned by baltakatei.
+
+# This file by Steven Baltakatei Sandoval is licensed under CC BY-SA 4.0.
+
+# Ask user for registration fields
+echo "What is the URL for whose website you are registering? (omit https://)"
+read input_URL
+echo "input_URL is:"$input_URL
+
+echo "What is your email address?"
+read input_EMAIL
+echo "input_EMAIL is:"$input_EMAIL
+
+echo "What is your user name (if any)?"
+read input_USERNAME
+echo "input_USERNAME is:"$input_USERNAME
+
+echo "Notes?"
+read input_NOTE
+echo "input_NOTE is:"$input_NOTE
+
+# Determine long date
+LONGDATE=$(date +%Y%m%dT%H%M%S.%N%z)
+echo "Current time is:"$LONGDATE
+
+# Determine hostname
+HOSTNAME=$(hostname)
+echo "HOSTNAME is:"$HOSTNAME
+
+# Perform superstitious PRNG spells
+echo $LONGDATE$HOSTNAME > /dev/random
+echo $(cat /proc/sys/kernel/random/entropy_avail)" bits of entropy in /dev/random"
+
+# Determine random 128-bit entropy password
+PASS1=$(LC_ALL=C tr -dc "[:graph:]" < /dev/urandom | head -c ${1:-8})
+PASS2=$(LC_ALL=C tr -dc "[:graph:]" < /dev/urandom | head -c ${1:-8})
+PASS3=$(LC_ALL=C tr -dc "[:graph:]" < /dev/urandom | head -c ${1:-4})
+PASSPHRASE=$PASS1" "$PASS2" "$PASS3
+echo "PASSPHRASE is:"$PASSPHRASE
+
+# Print fields to temporary file
+#echo "PASSPHRASE="$PASSPHRASE >> $PATHFILENAME
+#echo "URL="$input_URL >> $PATHFILENAME
+#echo "EMAIL="$input_EMAIL >> $PATHFILENAME
+#echo "USERNAME="$input_USERNAME >> $PATHFILENAME
+#echo "NOTE="$input_NOTE >> $PATHFILENAME
+#echo "DATE="$LONGDATE >> $PATHFILE
+
+# Push passphrase to clipboard
+echo -n $PASSPHRASE | xclip -selection clipboard
+
+echo "Passphrase copied to clipboard via xclip."
+
+# Push passphrase to `pass`
+#printf "$PASSPHRASE\nURL=$input_URL\nEMAIL=$input_EMAIL\nUSERNAME=$input_USERNAME\nNOTE=$input_NOTE\nDATE=$LONGDATE\n" | pass insert -m 01\ Online\ Services/$input_URL
+
+echo "$PASSPHRASE
+URL=$input_URL
+EMAIL=$input_EMAIL
+USERNAME=$input_USERNAME
+NOTE=$input_NOTE
+DATE=$LONGDATE
+" | pass insert -m 01\ Online\ Services/$input_URL