feat(user/bkytpldl-generic):Add generic yt-dlp wrapper
[BK-2020-03.git] / unitproc / bkgenpass
1 #!/bin/bash
2
3 # 2019-08-23T00:36Z; baltakatei>
4
5 # This bash script should prompt the user for a URL, email address,
6 # user name, text notes, and then generate a password, push this
7 # password into the x clipboard, and then save a text file containing
8 # the prompted details. This script should be run by Debian-based
9 # GNU/Linux machines owned by baltakatei.
10
11 # This file by Steven Baltakatei Sandoval is licensed under CC BY-SA 4.0.
12
13 # Ask user for registration fields
14 echo "What is the URL for whose website you are registering? (omit https://)"
15 read input_URL
16 echo "input_URL is:"$input_URL
17
18 echo "What is your email address?"
19 read input_EMAIL
20 echo "input_EMAIL is:"$input_EMAIL
21
22 echo "What is your user name (if any)?"
23 read input_USERNAME
24 echo "input_USERNAME is:"$input_USERNAME
25
26 echo "Notes?"
27 read input_NOTE
28 echo "input_NOTE is:"$input_NOTE
29
30 # Determine long date
31 LONGDATE=$(date +%Y%m%dT%H%M%S.%N%z)
32 echo "Current time is:"$LONGDATE
33
34 # Determine hostname
35 HOSTNAME=$(hostname)
36 echo "HOSTNAME is:"$HOSTNAME
37
38 # Perform superstitious PRNG spells
39 echo $LONGDATE$HOSTNAME > /dev/random
40 echo $(cat /proc/sys/kernel/random/entropy_avail)" bits of entropy in /dev/random"
41
42 # Determine random 128-bit entropy password
43 PASS1=$(LC_ALL=C tr -dc "[:graph:]" < /dev/urandom | head -c ${1:-8})
44 PASS2=$(LC_ALL=C tr -dc "[:graph:]" < /dev/urandom | head -c ${1:-8})
45 PASS3=$(LC_ALL=C tr -dc "[:graph:]" < /dev/urandom | head -c ${1:-4})
46 PASSPHRASE=$PASS1" "$PASS2" "$PASS3
47 echo "PASSPHRASE is:"$PASSPHRASE
48
49 # Print fields to temporary file
50 #echo "PASSPHRASE="$PASSPHRASE >> $PATHFILENAME
51 #echo "URL="$input_URL >> $PATHFILENAME
52 #echo "EMAIL="$input_EMAIL >> $PATHFILENAME
53 #echo "USERNAME="$input_USERNAME >> $PATHFILENAME
54 #echo "NOTE="$input_NOTE >> $PATHFILENAME
55 #echo "DATE="$LONGDATE >> $PATHFILE
56
57 # Push passphrase to clipboard
58 echo -n $PASSPHRASE | xclip -selection clipboard
59
60 echo "Passphrase copied to clipboard via xclip."
61
62 # Push passphrase to `pass`
63 #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
64
65 echo "$PASSPHRASE
66 URL=$input_URL
67 EMAIL=$input_EMAIL
68 USERNAME=$input_USERNAME
69 NOTE=$input_NOTE
70 DATE=$LONGDATE
71 " | pass insert -m 01\ Online\ Services/$input_URL