From 46a97d837460ca2122da3e32a963e99b1e76410d Mon Sep 17 00:00:00 2001 From: Steven Baltakatei Sandoval Date: Sun, 28 Jun 2020 18:31:54 +0000 Subject: [PATCH] chore(prvt):Move user scripts into prvt submodule for processing --- prvt | 2 +- user/bkcc | 384 --------------------------------------------- user/bkcryptomator | 1 - user/bkdate | 16 -- user/bkdatename | 32 ---- user/bkgit-status | 24 --- user/bkhextobin | 5 - user/bkidle | 17 -- user/bkmusic | 21 --- user/bknpass | 200 ----------------------- user/bkrandlujvo | 59 ------- user/bkrandwatch | 1 - user/bkrnd | 5 - user/bksign | 24 --- user/bkusbreset | 24 --- user/bkwpe | 39 ----- user/bkxz | 39 ----- user/bkytdl | 3 - user/bkytpldl | 10 -- 19 files changed, 1 insertion(+), 905 deletions(-) delete mode 100755 user/bkcc delete mode 100755 user/bkcryptomator delete mode 100755 user/bkdate delete mode 100755 user/bkdatename delete mode 100755 user/bkgit-status delete mode 100755 user/bkhextobin delete mode 100755 user/bkidle delete mode 100755 user/bkmusic delete mode 100755 user/bknpass delete mode 100755 user/bkrandlujvo delete mode 100755 user/bkrandwatch delete mode 100755 user/bkrnd delete mode 100755 user/bksign delete mode 100755 user/bkusbreset delete mode 100755 user/bkwpe delete mode 100755 user/bkxz delete mode 100755 user/bkytdl delete mode 100755 user/bkytpldl diff --git a/prvt b/prvt index e2a56e5..4c95471 160000 --- a/prvt +++ b/prvt @@ -1 +1 @@ -Subproject commit e2a56e5d54d7fd05f0ec51ee27737d411a05655c +Subproject commit 4c954717c286c85f491907c90822975c8f26d568 diff --git a/user/bkcc b/user/bkcc deleted file mode 100755 index 347baaf..0000000 --- a/user/bkcc +++ /dev/null @@ -1,384 +0,0 @@ -#!/bin/bash - -# Date: 2020-02-08T22:21Z - -# Author: Steven Baltakatei Sandoval - -# License: This bash script, 'bkcc', is licensed under GPLv3 or -# later by Steven Baltakatei Sandoval: -# -# 'bkcc', a Creative Commons HTML tag generator. -# Copyright (C) 2020 Steven Baltakatei Sandoval (baltakatei.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# A copy of the GNU General Public License may be found at -# . -# -# The structure of this script was modeled after the following -# Creative Commons license choosers: -# -# https://creativecommons.org/choose/ -# https://chooser-beta.creativecommons.org/ - -# Description: bkcc - A tool that creates a machine-readable (RDFa -# XML) Creative Commons license tag. The tag is generated using -# information prompted from the user and exported to stdout. - -# Usage: bkcc [ OPTIONS ] - - -#==DEFINITIONS== - -# regular expression for identifying valid URLs (source: http://regexlib.com/REDetails.aspx?regexp_id=1051 ) -regexURL="((http\://|https\://|ftp\://)|(www.))+(([a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9%:/-_\?\.'~]*)?" - -# Define 'echoerr' function which outputs text to stderr - # Note: function copied from https://stackoverflow.com/a/2990533 -echoerr() { - echo "$@" 1>&2; -} - -promptAttribute() { - ###echoerr "Note: RECOMMENDED options promote \"Free Cultural Works\" as defined by creativecommons.org" - echoerr "=======================================================" - echoerr "Do you want to require attribution for your work? (y/n)" - echoerr " y) Yes, anyone using my work must give me appropriate credit (RECOMMENDED)." - echoerr " n) No, anyone can use my work even without attribution." - read m - case $m in - y | Y | yes | 1) OPTION_BY="true";; - n | N | no | 2) - echoerr "=======================================================" - echoerr "I hereby waive all copyright and related or neighboring rights together with all" - echoerr "associated claims and causes of action with respect to this work to the extent" - echoerr "possible under law according to" - echoerr "https://creativecommons.org/publicdomain/zero/1.0/ ." - echoerr "" - echoerr "I have read and understood the terms and intended legal effect of CC0, and" - echoerr "hereby voluntarily elect to apply it to this work (y/n):" - read m - case $m in - y | Y | yes | 1) OPTION_BY="false"; - echoerr "DEBUG: OPTION_BY set to $OPTION_BY" - return 1 - ;; - n | N | no | 2) echoerr "No license selected. Exiting."; exit 1;; - *) echoerr "Invalid CC0 release option. Exiting."; exit 1;; - esac ;; - *) echoerr "Invalid attribution requirement option. Exiting."; exit 1;; - esac -} - -promptCommercial() { - echoerr "=======================================================" - echoerr "Do you want to prohibit others commercial use of your work? (y/n)" - echoerr " y) Yes, others cannot use my work for commercial purposes." - echoerr " n) No, others can use my work for commercial purposes (RECOMMENDED)." - read m - case $m in - y | Y | yes | 1) OPTION_NC="true"; echoerr "DEBUG: OPTION_NC set to $OPTION_NC";; - n | N | no | 2) OPTION_NC="false"; echoerr "DEBUG: OPTION_NC set to $OPTION_NC";; - *) echoerr "Invalid commercial use permission option. Exiting."; exit 1;; - esac -} - -promptDerivatives() { - echoerr "=======================================================" - echoerr "Do you want to prohibit others from distributing your work if they remix, transform, or build upon it?" - echoerr " y) Yes, others can use and share my work only as is, without modifications." - echoerr " n) No, others may share modified versions of my work (RECOMMENDED)." - read m - case $m in - y | Y | yes | 1) OPTION_ND="true"; echoerr "DEBUG: OPTION_ND set to $OPTION_ND";; - n | N | no | 2) OPTION_ND="false"; echoerr "DEBUG: OPTION_ND set to $OPTION_ND";; - *) echoerr "Invalid derivative use permission option. Exiting."; exit 1;; - esac -} - -promptShareAlike() { - echoerr "=======================================================" - echoerr "Do you want to prohibit your work under other terms?" - echoerr " y) Yes, anyone who changes your work must share their contributions under the same license as the original. (RECOMMENDED)" - echoerr " n) No, anyone who changes your work can distribute their contributions under a different license." - read m - case $m in - y | Y | yes | 1) OPTION_SA="true"; echoerr "DEBUG: OPTION_SA set to $OPTION_SA";; - n | N | no | 2) OPTION_SA="false"; echoerr "DEBUG: OPTION_SA set to $OPTION_SA";; - *) echoerr "Invalid sharealike requirement option. Exiting."; exit 1;; - esac -} - -promptLicenseDetails() { - # Usage: promptLicenseDetails - # Description: Sets LICENSE_TYPE by questioning user. - - echoerr "DEBUG: Beginning promptLicenseDetails function." - - # Evaluate BY option. - # Ask if author wishes to be attributed. - promptAttribute # set OPTION_BY to true or false. - if [[ $OPTION_BY == "false" ]]; then - LICENSE_TYPE="CC 1.0" - echoerr "DEBUG: LICENSE_TYPE set to $LICENSE_TYPE" - return 1; - fi - - # Evaluate NC option. - # Ask if author permits commercial use of work. - promptCommercial # set OPTION_NC to true or false. - - # Evaluate ND option. - # Ask if author permits derivative use of work. - promptDerivatives # set OPTION_ND to true or false. - - # Evaluate SA option. - # Ask if author requires derivative works to also carry same license as work. - if [[ $OPTION_ND = "true" ]]; then - OPTION_SA="false" # An SA work cannot be made from an ND work. - else - promptShareAlike # set OPTION_SA to true or false. - fi - - # Check for CC BY - if [[ $OPTION_BY == "true" ]] && \ - [[ $OPTION_NC == "false" ]] && \ - [[ $OPTION_ND == "false" ]] && \ - [[ $OPTION_SA == "false" ]] - then - LICENSE_TYPE="CC BY 4.0" - return - fi - - # Check for CC BY-SA - if [[ $OPTION_BY == "true" ]] && \ - [[ $OPTION_NC == "false" ]] && \ - [[ $OPTION_ND == "false" ]] && \ - [[ $OPTION_SA == "true" ]] - then - LICENSE_TYPE="CC BY-SA 4.0" - return - fi - - # Check for CC BY-ND - if [[ $OPTION_BY == "true" ]] && \ - [[ $OPTION_NC == "false" ]] && \ - [[ $OPTION_ND == "true" ]] && \ - [[ $OPTION_SA == "false" ]] - then - LICENSE_TYPE="CC BY-ND 4.0" - return - fi - - # Check for CC BY-NC - if [[ $OPTION_BY == "true" ]] && \ - [[ $OPTION_NC == "true" ]] && \ - [[ $OPTION_ND == "false" ]] && \ - [[ $OPTION_SA == "false" ]] - then - LICENSE_TYPE="CC BY-NC 4.0" - return - fi - - # Check for CC BY-NC-SA - if [[ $OPTION_BY == "true" ]] && \ - [[ $OPTION_NC == "true" ]] && \ - [[ $OPTION_ND == "false" ]] && \ - [[ $OPTION_SA == "true" ]] - then - LICENSE_TYPE="CC BY-NC-SA 4.0" - return - fi - - # Check for CC BY-NC-ND - if [[ $OPTION_BY == "true" ]] && \ - [[ $OPTION_NC == "true" ]] && \ - [[ $OPTION_ND == "true" ]] && \ - [[ $OPTION_SA == "false" ]] - then - LICENSE_TYPE="CC BY-NC-ND 4.0" - return - fi - - # Error message if none of the above if statements returned out of function. - echoerr "ERROR: Invalid license specified or LICENSE_TYPE not set."; exit 1; - -} - -selectLicense() { - # Usage: selectLicense - # Description: Sets LICENSE_TYPE variable according to a set of user prompts. - - # Prompt license type - echoerr "Select license type:" - echoerr " 0) I don't know. Guide me." - echoerr " 1) CC0 1.0 \"CC0 1.0 Universal\"" - echoerr " 2) CC BY 4.0 \"Attribution 4.0 International\"" - echoerr " 3) CC BY-SA 4.0 \"Attribution-ShareAlike 4.0 International\"" - echoerr " 4) CC BY-ND 4.0 \"Attribution-NoDerivatives 4.0 International\"" - echoerr " 5) CC BY-NC 4.0 \"Attribution-NonCommercial 4.0 International\"" - echoerr " 6) CC BY-NC-SA 4.0 \"Attribution-NonCommercial-ShareAlike 4.0 International\"" - echoerr " 7) CC BY-NC-ND 4.0 \"Attribution-NonCommercial-NoDerivatives 4.0 International\"" - read n - case $n in - 0) promptLicenseDetails; return;; # Sets LICENSE_TYPE via many questions to user. - 1) LICENSE_TYPE="CC 1.0";; - 2) LICENSE_TYPE="CC BY 4.0";; - 3) LICENSE_TYPE="CC BY-SA 4.0";; - 4) LICENSE_TYPE="CC BY-ND 4.0";; - 5) LICENSE_TYPE="CC BY-NC 4.0";; - 6) LICENSE_TYPE="CC BY-NC-SA 4.0";; - 7) LICENSE_TYPE="CC BY-NC-ND 4.0";; - *) echoerr "Invalid option selected. Exiting."; exit 1;; - esac - -} - -#==MAIN PROGRAM== -selectLicense # Sets LICENSE_TYPE via simple prompt. - -# Display value of $LICENSE_TYPE -echoerr "=======================================================" -echoerr "$LICENSE_TYPE"" license selected." - -# Prompt metadata -echoerr "=======================================================" -echoerr "Specify metadata (leave blank if not needed):" -read -p " Title of work [title]:" workTitle -read -p " Attribute work to [author]:" workAuthor - -read -p " Attribute work to (ex: author's website) [URL]:" workAuthorURL -if [[ -n $workAuthorURL ]]; then - while [[ ! $workAuthorURL =~ $regexURL ]]; do - echoerr "WARNING: URL may contain error (ex: does not begin with \"https://\"." - echoerr " Preappend \"http://\" to URL? (y/n)" - read m - case $m in - y | Y | yes | 1) workAuthorURL="http://""$workAuthorURL" ;; - n | N | no | 2) read -p " Attribute work to (ex: author's website) [URL]:" workAuthorURL ;; - *) ;; - esac - done -fi - -read -p " Source work from which work was derived (leave blank if original work) [URL]:" workSourceURL -if [[ -n $workSourceURL ]]; then - while [[ ! $workSourceURL =~ $regexURL ]]; do - echoerr "WARNING: URL may contain error (ex: does not begin with \"https://\." - echoerr " Preappend \"http://\" to URL? (y/n)" - read m - case $m in - y | Y | yes | 1) workSourceURL="http://""$workSourceURL" ;; - n | N | no | 2) read -p " Source work from which work was derived (leave blank if original work) [URL]:" workSourceURL ;; - *);; - esac - done -fi - -read -p " Webpage where more additional permissions may be requested (OPTIONAL) [URL]:" morePermissionsURL -if [[ -n $morePermissionsURL ]]; then - while [[ ! $morePermissionsURL =~ $regexURL ]]; do - echoerr "WARNING: URL may contain error (ex: does not begin with \"https://\." - echoerr " Preappend \"http://\" to URL? (y/n)" - read m - case $m in - y | Y | yes | 1) morePermissionsURL="http://""$morePermissionsURL";; - n | N | no | 2) read -p " Webpage where more additional permissions may be requested (OPTIONAL) [URL]:" morePermissionsURL ;; - esac - done -fi - -#===CONSTRUCT RDFA TAG=== -#====RDFA:Handle workTitle, workAuthor, workAuthorURL==== -###echoerr "DEBUG: workTitle is --$workTitle--" -###echoerr "DEBUG: workAuthor is --$workAuthor--" -###echoerr "DEBUG: workAuthorURL is --$workAuthorURL--" -###echoerr "DEBUG: workSourceURL is --$workSourceURL--" -###echoerr "DEBUG: morePermissionsURL is --$morePermissionsURL--" -###echoerr "DEBUG: LICENSE_TYPE is --$LICENSE_TYPE--" - -# Exit early if critical parameters not provided -if [[ -z "$workTitle" ]] || \ - [[ ! -v LICENSE_TYPE ]]; -then - echoerr "ERROR: Problem with workTitle or LICENSE_TYPE." - exit 1; -fi - -# Add workTitle to OUTPUT variable -OUTPUT=$OUTPUT"$workTitle" - -# Add workAuthor and/or workAuthorURL to OUTPUT variable (if applicable) -if [[ -v workAuthor ]]; then - if [[ -v workAuthorURL ]]; then - # workAuthor set, workAuthorURL set - OUTPUT=$OUTPUT" by $workAuthor" - else - #workAuthor set, workAuthorURL not set - OUTPUT=$OUTPUT" by $workAuthor" - fi -fi - -#====RDFA:Handle LICENSE_TYPE==== -# Add selected license to OUTPUT variable - -# Add boilerplate -OUTPUT=$OUTPUT" is licensed under " - -# Add license text -case $LICENSE_TYPE in - "CC 1.0") - OUTPUT=$OUTPUT"CC0 1.0" - ;; - "CC BY 4.0") - OUTPUT=$OUTPUT"CC BY 4.0" - ;; - "CC BY-SA 4.0") - OUTPUT=$OUTPUT"CC BY-SA 4.0" - ;; - "CC BY-ND 4.0") - OUTPUT=$OUTPUT"CC BY-ND 4.0" - ;; - "CC BY-NC 4.0") - OUTPUT=$OUTPUT"CC BY-NC 4.0" - ;; - "CC BY-NC-SA 4.0") - OUTPUT=$OUTPUT"CC BY-NC-SA 4.0" - ;; - "CC BY-NC-ND 4.0") - OUTPUT=$OUTPUT"CC BY-NC-ND 4.0" - ;; - *) echoerr "Error."; exit 1;; -esac -# End sentence. -OUTPUT=$OUTPUT"." - - -#====RDFA:Handle workSourceURL, morePermissionsURL (if applicable)==== -# Add workSourceURL to OUTPUT (if applicable) -if [[ -n "$workSourceURL" ]]; then - OUTPUT=$OUTPUT"
$workTitle is based on a work at $workSourceURL" - # End sentence. - OUTPUT=$OUTPUT"." -fi - -# Add morePermissionsURL to OUTPUT (if applicable) -if [[ -n "$morePermissionsURL" ]]; then - OUTPUT=$OUTPUT"
Permissions beyond the scope of this license may be available at $morePermissionsURL" - #End sentence - OUTPUT=$OUTPUT"." -fi - - - -#====Deliver output==== -# Send OUTPUT to stdout. -echo $OUTPUT diff --git a/user/bkcryptomator b/user/bkcryptomator deleted file mode 100755 index a8583be..0000000 --- a/user/bkcryptomator +++ /dev/null @@ -1 +0,0 @@ -~/Desktop/cryptomator/cryptomator-1.4.15-x86_64.AppImage diff --git a/user/bkdate b/user/bkdate deleted file mode 100755 index 1bf808b..0000000 --- a/user/bkdate +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Date: 2020-02-06T22:51Z - -# Description: A simple command line tool to dispay the date in ISO-8601 format. - -DATE="$(date --iso-8601=seconds)" - -if [[ $DATE =~ "+00:00"$ ]]; then - DATE2=${DATE::-6}"Z" - echo $DATE2 - exit 0 -else - echo $DATE - exit 0 -fi diff --git a/user/bkdatename b/user/bkdatename deleted file mode 100755 index ace4e01..0000000 --- a/user/bkdatename +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# Date: 2020-05-10T15:27Z -# Author: Steven Baltakatei Sandoval -# License: GPLv3+ -# Ref./Attrib: -# [1]: John1024 (2014-08-06). ["linux-shell: renaming files to creation time"](https://stackoverflow.com/a/25153352). Licensed CC BY-SA 4.0. -# [2]: Computer Hope (2019-05-04). ["Bash read builtin command"](https://www.computerhope.com/unix/bash/read.htm). - -# Description: Preappends modification time to all files in current -# working directory. - -# Usage: bkdatename - -# Prompt to change filenames for all files in working directory. -read -p "Append each file's modification date & time to the start of its name in the current working directory? (y/n)" -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]] # see [2] -then - #Perform renaming operation. - for f in * - do - FILE_NAME="$f" - FILE_MDATE="$(date -r "$f" +"%Y%m%dT%H%M%S")" # See [1]. - FILE_NAME_NEW="$FILE_MDATE".."$FILE_NAME" - # Display new file name - echo "Renaming $f to:""$FILE_NAME_NEW" - cp -p ./"$f" ./"$FILE_NAME_NEW" - rm ./"$f" - done - echo "Done." -fi diff --git a/user/bkgit-status b/user/bkgit-status deleted file mode 100755 index 5ec774e..0000000 --- a/user/bkgit-status +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Date: 2020-01-02T03:21Z - -# Description: A bash script to perform the `git-status` command on -#all subdirectories within the working directory. - -# Source: https://gist.github.com/mzabriskie/6631607 - -#for d in ./*/ ; do (cd "$d" && echo "========================" && pwd && git status); done - -for d in ./*/ ; do - ( - cd "$d" - if [ -d ./.git ]; - then - #echo "========================" - pwd - git status -s - else - echo "ERR:No .git dir: "$(pwd) - fi - ); -done diff --git a/user/bkhextobin b/user/bkhextobin deleted file mode 100755 index 39a7ae0..0000000 --- a/user/bkhextobin +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -echo "type a hex number" -read hexNum -echo -n "The binary value of $hexNum=" -echo "obase=2; ibase=16; $hexNum" | bc diff --git a/user/bkidle b/user/bkidle deleted file mode 100755 index 66aff23..0000000 --- a/user/bkidle +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Date: 2020-03-09T04:51Z - -# Description: A bash script showing recent edits to a given -# directory. - -# Usage: bkidle [dir] - -TARGET_DIR="$1" - -while true; -do - find "$1" -readable -mmin -1 -type f -exec b2sum -l 32 '{}' \;; - echo "$(date +%Y%m%dT%H%M%S.%N%z)========"; - sleep 60; -done diff --git a/user/bkmusic b/user/bkmusic deleted file mode 100755 index ebffbb7..0000000 --- a/user/bkmusic +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Date: 2020-04-28T18:31Z -# Author: Steven Baltakatei Sandoval -# Description: Runs mpv to listen to custom playlist generated by cron_vensagusni_day.sh - -TARGET_PLAYLIST="/home/baltakatei/Music/music_library_playlist.m3u" -OUTPUT_LOG_PATH="/home/baltakatei/Sync/kodawkuori-07/2020/archive-PERS/logs/activity/$(date +%Y%m%dT%H%M%S.%N%z)..mpv_history.log" -OUTPUT_LOG_DIR="$(dirname $OUTPUT_LOG_PATH)" - -if ! [ -d "$OUTPUT_LOG_DIR" ]; then - echo "ERROR: Output log directory not found:""$OUTPUT_LOG_DIR" 1>&2 ; exit 1; -fi - -if ! [ -f "$TARGET_PLAYLIST" ]; then - echo "ERROR: Playlist file not found:""$TARGET_PLAYLIST" 1>&2 ; exit 1; -fi - -mpv "$TARGET_PLAYLIST" --no-video --log-file="$OUTPUT_LOG_PATH" --msg-time; - -exit 0 diff --git a/user/bknpass b/user/bknpass deleted file mode 100755 index 4f53da0..0000000 --- a/user/bknpass +++ /dev/null @@ -1,200 +0,0 @@ -#!/bin/bash - -# Date: 2020-01-20T16:34Z -# -# Author: Steven Baltakatei Sandoval (baltakatei.com) -# -# License: This bash script, `bknpass`, is licensed under GPLv3 or -# later by Steven Baltakatei Sandoval: -# -# `bknpass`, an alphanumeric password generator -# Copyright (C) 2020 Steven Baltakatei Sandoval (baltakatei.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# A copy of the GNU General Public License may be found at -# . -# -# Description: This bash script generates alphanumeric passphrases -# with a char-count determined by a user-provided number of bits of -# entropy. The passphrase is then outputted to stdout with a trailing -# newline. It works as follows: -# -# - Prompt user for an integer. This integer is the number of bits -# of entropy that the generated password should have. -# -# - Check if user-provided string is an integer using `bash` regular -# expression test. -# -# - Calculate the minimum number of alphanumeric characters required -# to encode the specified number of bits of entropy. -# -# - This step uses `bc` to calculate a logarithm float string -# and `awk` to convert the float into an integer, rounding up. -# -# - Use `tr`, `/dev/urandom`, and `head` to generate a random -# alphanumeric string with the length calculated in the previous -# step. -# -# - Use `echo` to display the passphrase in stdout with a trailing -# newline. -# -# Dependencies: bash, echo, bc, awk, tr, head. See end of file -# -# Tested on: -# -# - GNU/Linux Debian 10 - - -#==Initialization== - -let ALPHABET_SIZE="26+26+10" # number of unique chars in [:alnum:], argument fed to `tr -c` in 'Generate passphrase' step) -LOG_BASE=2 # Set logarithm base to 2 - -# Define `echoerr` function which outputs text to stderr - # Note: function copied from https://stackoverflow.com/a/2990533 -function echoerr { - echo "$@" 1>&2; -} - -# Define `rpass` function which generates an alphanumeric passphrase of length $1 (ex: `rpass 22` generates a 22-char string) - # Note: function adapted from https://www.thegeekstuff.com/2010/04/unix-bash-function-examples/ -function rpass { - cat /dev/urandom | LC_ALL=C tr -cd "[:alnum:]" | head -c ${1:-22} -} - - -#==Main Program== - -# Define $ENTROPY_BIT_COUNT1 as argument $1 or prompt user if $1 is not defined. - # note: argument test adapted from https://stackoverflow.com/a/6482403 -if [ -z "$1" ] -then - echo "Entropy bit count argument (\$1) not supplied." - # Get from user the number of bits of entropy. - echoerr -n "Please specify the required strength of the password in bits of entropy (ex: 256):" # prompt via stderr - read ENTROPY_BIT_COUNT1 -else - ENTROPY_BIT_COUNT1="$1" -fi - -# Check if $ENTROPY_BIT_COUNT1 is an non-negative integer - # Note: Regular expression test is adapted from https://stackoverflow.com/a/806923 -RETEST1='^[0-9]+$' -if ! [[ $ENTROPY_BIT_COUNT1 =~ $RETEST1 ]] ; then - echo "error: Not an integer." >&2; exit 1 -fi - -# Calculate minimum count of chars needed to encode $ENTROPY_BIT_COUNT1 with alphabet size of $ALPHABET_SIZE as float - # Solve ln(a^n)/ln(2)=b for n using `bc` where - # a=$ALPHABET_SIZE - # n=$CHAR_COUNT1_FLOAT - # b=$ENTROPY_BIT_COUNT1 - # Note: `bc` logarithm usage adapted from http://phodd.net/gnu-bc/bcfaq.html#bashlog -CHAR_COUNT1_FLOAT=$(echo "$ENTROPY_BIT_COUNT1*l($LOG_BASE)/l($ALPHABET_SIZE)" | bc -l) - # Note: Float will be of form "21.49744370650136860806". This particular float should be rounded to "22" later. - -# Round $CHAR_COUNT1_FLOAT1 up to next highest integer for use as argument in later bash functions. - # Note: awk expression from https://bits.mdminhazulhaque.io/linux/round-number-in-bash-script.html -CHAR_COUNT1=$(echo "$CHAR_COUNT1_FLOAT" | awk '{print ($0-int($0)>0)?int($0)+1:int($0)}') - -# Generate passphrase -PASS1=$(rpass "$CHAR_COUNT1") -echo -e "$PASS1" - - -#==References== -# -# - How to echo a string as stderr instead of stdout. -# https://stackoverflow.com/a/2990533 -# Author: James Roth -# Date: 2010-06-07T14:52Z -# Date Accessed: 2020-01-20 -# -# - How to check if script argument exists or not. -# https://stackoverflow.com/a/6482403 -# Author: phoxix -# Date: 2011-06-26T05:55Z -# Date Accessed: 2020-01-20 -# -# - How to check that a string is an integer using regular expression test. -# https://stackoverflow.com/a/806923 -# Author: Charles Duffy -# Date: 2009-04-30T13:32Z -# Date Accessed: 2020-01-20 -# -# - How to use `bc` to calculate logarithms in Bash -# http://phodd.net/gnu-bc/bcfaq.html#bashlog -# Author: unknown -# Date Accessed: 2020-01-20 -# -# - How to use `awk` to convert and round up a float to an integer. -# https://bits.mdminhazulhaque.io/linux/round-number-in-bash-script.html -# Author: Md. Minhazul Haque -# Date: 2015-01-09 -# Date Accessed: 2020-01-20 -# -# - How to use `/dev/urandom`, `tr`, and `head` to generate a random password in Bash. -# https://www.thegeekstuff.com/2010/04/unix-bash-function-examples/ -# Author: SASIKALA, Ramesh Natarajan -# Date: 2010-04-21 -# Date Accessed: 2020-01-20 -# -# - Dependencies: bash, echo, bc, awk, tr, head. -# -# - GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu) -# Copyright (C) 2019 Free Software Foundation, Inc. -# License GPLv3+: GNU GPL version 3 or later -# This is free software; you are free to change and redistribute it. -# There is NO WARRANTY, to the extent permitted by law. -# -# - echo (GNU coreutils) 8.30 -# Copyright (C) 2018 Free Software Foundation, Inc. -# License GPLv3+: GNU GPL version 3 or later . -# This is free software: you are free to change and redistribute it. -# There is NO WARRANTY, to the extent permitted by law. -# -# Written by Brian Fox and Chet Ramey. -# -# - bc 1.07.1 -# Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc. -# -# - GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) -# Copyright (C) 1989, 1991-2018 Free Software Foundation. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/. -# -# - tr (GNU coreutils) 8.30 -# Copyright (C) 2018 Free Software Foundation, Inc. -# License GPLv3+: GNU GPL version 3 or later . -# This is free software: you are free to change and redistribute it. -# There is NO WARRANTY, to the extent permitted by law. -# -# Written by Jim Meyering. -# -# - head (GNU coreutils) 8.30 -# Copyright (C) 2018 Free Software Foundation, Inc. -# License GPLv3+: GNU GPL version 3 or later . -# This is free software: you are free to change and redistribute it. -# There is NO WARRANTY, to the extent permitted by law. -# -# Written by David MacKenzie and Jim Meyering. diff --git a/user/bkrandlujvo b/user/bkrandlujvo deleted file mode 100755 index 35e09e8..0000000 --- a/user/bkrandlujvo +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# usage: bkrandlujvo - -INPUT_FILE="/home/baltakatei/Sync/kodawkuori-07/2020/reference-PERS/lojban/20190626..gismu_english_order.txt" -if [ ! -f "$INPUT_FILE" ]; then echo "ERROR: gismu list text file not found." 2>&1 ; exit 1; fi - -randGismuDef () { - # usage: randGismuDef [gismu.txt file] - # output: <>,<> - FILE="$1" - randLineNum=$(shuf -n1 -i2-$(cat "$FILE" | wc -l)) # Generate random line number of FILE - # Output random 2nd space-delimted field (gismu) from file - #echo $(cat "$FILE" | cut -d' ' -f2-3 | head -n"$randLineNum" | tail -n1 ) - echo $(cat "$FILE" | awk '{print $1 "," $3}' | head -n"$randLineNum" | tail -n1 ) -} - -randGismu () { - # usage: randGismu [gismu.txt file] - # output: <> - FILE="$1" - randLineNum=$(shuf -n1 -i2-$(cat "$FILE" | wc -l)) # Generate random line number of FILE - # Output random 2nd space-delimted field (gismu) from file - echo $(cat "$FILE" | awk '{print $1}' | head -n"$randLineNum" | tail -n1 ) -} - -GISMU1=$(randGismu "$INPUT_FILE") -GISMU2=$(randGismu "$INPUT_FILE") -GISMU3=$(randGismu "$INPUT_FILE") - -#RAW1=$(randGismuDef "$INPUT_FILE") -#RAW2=$(randGismuDef "$INPUT_FILE") -#RAW3=$(randGismuDef "$INPUT_FILE") - -#GISMU1=$(echo "$RAW1" | cut -d',' -f1) -#GISMU2=$(echo "$RAW2" | cut -d',' -f1) -#GISMU3=$(echo "$RAW3" | cut -d',' -f1) - -#DEF1=$(echo "$RAW1" | cut -d',' -f2) -#DEF2=$(echo "$RAW2" | cut -d',' -f2) -#DEF3=$(echo "$RAW3" | cut -d',' -f2) - -echo "$GISMU1 $GISMU2 $GISMU3" -#echo "$DEF1 $DEF2 $DEF3" - -if command -v jbofihe 1>/dev/null 2>&1; then - echo "$GISMU1" | jbofihe -x - echo "$GISMU2" | jbofihe -x - echo "$GISMU3" | jbofihe -x -else - echo "ERROR: jbofihe command not available." 2>&1; -fi - -if command -v jvocuhadju 1>/dev/null 2>&1; then - jvocuhadju "$GISMU1" "$GISMU2" "$GISMU3"; -else - echo "ERROR: jvocuhadju command not available." 2>&1; -fi - -exit 0 diff --git a/user/bkrandwatch b/user/bkrandwatch deleted file mode 100755 index f0373a9..0000000 --- a/user/bkrandwatch +++ /dev/null @@ -1 +0,0 @@ -watch -d -n 1 cat /proc/sys/kernel/random/entropy_avail diff --git a/user/bkrnd b/user/bkrnd deleted file mode 100755 index a6846a7..0000000 --- a/user/bkrnd +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# A script that outputs a random 8-digit hexadecimal number to stdout. - -LC_ALL=C tr -dc "0123456789abcdef" < /dev/urandom | head -c ${1:-8} diff --git a/user/bksign b/user/bksign deleted file mode 100755 index b182008..0000000 --- a/user/bksign +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Date: 2020-05-24T00:47Z - -# Author: Steven Baltakatei Sandoval - -# Description: A bash script that creates a gpg signature using -# default key. - -# Usage: bksign [ file ] - -FILEIN="$1" - -# Check that provided argument is a file. -if ! [ -f "$FILEIN" ]; then - echo "ERROR: Invalid filename provided." 2>&1; - exit 1; -fi - -# Determine output file name -FILEOUT="$FILEIN".asc -gpg --armor --verbose --output "$FILEOUT" --detach-sign "$FILEIN" - -exit 1 diff --git a/user/bkusbreset b/user/bkusbreset deleted file mode 100755 index 4e135f9..0000000 --- a/user/bkusbreset +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# script to force reset USB devices -# soruce: http://billauer.co.il/blog/2013/02/usb-reset-ehci-uhci-linux/ - - -if [[ $EUID != 0 ]] ; then - echo This must be run as root! - exit 1 -fi - -for xhci in /sys/bus/pci/drivers/?hci_hcd ; do - - if ! cd $xhci ; then - echo Weird error. Failed to change directory to $xhci - exit 1 - fi - - echo Resetting devices from $xhci... - - for i in ????:??:??.? ; do - echo -n "$i" > unbind - echo -n "$i" > bind - done -done diff --git a/user/bkwpe b/user/bkwpe deleted file mode 100755 index 3b28052..0000000 --- a/user/bkwpe +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# 2019-08-14T21:58:08Z; baltakatei> - -# The purpose of this script is to open a session of firefox dedicated -# to editing wikipedia from a remote machine with a public IP address -# not on Wikipedia's blocklist. - -# This script: -# 1. Creates ssh proxy to remote server -# 2. Starts Firefox by calling a local installation of firefox via -# its own startup script. - -# Note: This script does not automatically initialize the default -# Firefox profile with the correct SOCKS5 settings as can be seen in -# "Connection Settings" ("Manual proxy configuration", SOCKS -# Host="127.0.0.1", Port="8080"). These changes must be made manually -# until an automated method for applying SOCKS settings via edits to -# `prefs.js` in the default Firefox profile. - -# Reference: - -# SSH CONNECTION SETTINGS -REMOTE_USER=baltakatei -REMOTE_IP=76.102.50.36 -REMOTE_PORT=63865 -LOCAL_PROXY_PORT=8080 - -# STEP 1: Start an SSH master connection (-M) -# in the background (-f) -# without running a remote command (-N) -ssh -p $REMOTE_PORT -M -o ControlPath=/tmp/socks.%r@%h:%p -f -N -D $LOCAL_PROXY_PORT -C $REMOTE_USER@$REMOTE_IP - -# STEP 2: Launch Firefox in the foreground -#/home/baltakatei/Desktop/firefox/firefox -P -no-remote -/home/baltakatei/Desktop/firefox/firefox -no-remote - -# STEP 3: When user is done with Firefox, send an "exit" command to the master connection -ssh -p $REMOTE_PORT -o ControlPath=/tmp/socks.%r@%h:%p -O exit $REMOTE_USER@$REMOTE_IP diff --git a/user/bkxz b/user/bkxz deleted file mode 100755 index 465369a..0000000 --- a/user/bkxz +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -# Date: 2020-04-09T00:09Z - -# Author: Steven Baltakatei Sandoval - -# Description: Compresses a file or directory using xz at max -# settings. Saves compressed .tar.xz file in the same directory as the -# original file. - -# Usage: bkxz [ file or dir ] - -echoerr() { echo "$@" 1>&2; } # Define error display function. - -TARGET="$1" # Identify first argument as target file or directory. - -if ! command -v tar >/dev/null 2>&1; then # Check that 'tar' command exists. - echoerr "ERROR: Command doesn't exist: tar"; -fi - -if ! command -v xz >/dev/null 2>&1; then # check that 'xz' command exist. - echoerr "ERROR: Command doesn't exist: xz. Suggestion: Install 'xz-utils' package."; - exit 1; -fi - -if ! ( [ -f "$TARGET" ] || [ -d "$TARGET" ] ); then # check that TARGET is a file or dir. - echoerr "ERROR: Target is not a file or dir."; exit 1; -fi - - -TARGET_BASENAME="$(basename "$TARGET")" # Save name of target's basename (ex: 'input.txt' from '/tmp/input.txt'). -TARGET_DIRNAME="$(dirname "$TARGET")" # Save name of target's directory (ex: '/tmp' from '/tmp/input.txt'). - -OUTPUT="$TARGET_DIRNAME"/"$TARGET_BASENAME".tar.xz # Define output file to be in same location as target but with .tar.xz extension. - -pushd "$TARGET_DIRNAME" 1>/dev/null 2>&1 # Temporarily navigate to directory holding TARGET. -tar cf - "$TARGET_BASENAME" | xz -9e --lzma2=dict=1536MiB,mf=bt4,nice=273,depth=1000 > "$OUTPUT" -echoerr "Archive saved at: $OUTPUT" -popd 1>/dev/null 2>&1 # Return to original working directory. diff --git a/user/bkytdl b/user/bkytdl deleted file mode 100755 index 1e93586..0000000 --- a/user/bkytdl +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' -o '%(upload_date)s_%(id)s..%(channel)s,_%(title)s.%(ext)s' --restrict-filenames $@ diff --git a/user/bkytpldl b/user/bkytpldl deleted file mode 100755 index 67d20a0..0000000 --- a/user/bkytpldl +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -#Sync Youtube playlist "cukta-2019Q4" -#bash ~/Sync/baltakatei_bin/youtube-playlist-sync -l https://www.youtube.com/playlist?list=PL840bf-Yx7uabEhowgn-e2CYoqdVOJ8uF -d ~/Sync/kodawkuori-07/2019/videos-PERS/internet/youtube - -#Sync Youtube playlist "cukta-2020Q1" -#bash ~/Sync/baltakatei_bin/youtube-playlist-sync -l https://www.youtube.com/playlist?list=PL840bf-Yx7uY8JAHFfBJ1poRfWHy25AUE -d ~/Sync/kodawkuori-07/2020/videos-PERS/internet/youtube - -#Sync Youtube playlist "cukta-2020Q2" -bash ~/Sync/baltakatei_bin/youtube-playlist-sync -l https://www.youtube.com/playlist?list=PL840bf-Yx7uaW5cj_l24b8v2DZek5Nwv5 -d ~/Sync/kodawkuori-07/2020/videos-PERS/internet/youtube/cukta-2020Q2 -- 2.30.2