From dd2578e2952b2c73b24a03a94c17974da78e9fed Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Wed, 8 Nov 2017 22:39:14 -0500 Subject: [PATCH] tasty reborn terminal locking script thought this wasn't handy, but i've had several times recently where it would have been. newly cleaned it up and added helpful text feedback, plus now it will show the nechung oracle when locked. --- scripts/tty/lockem.sh | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 scripts/tty/lockem.sh diff --git a/scripts/tty/lockem.sh b/scripts/tty/lockem.sh new file mode 100644 index 00000000..473e0867 --- /dev/null +++ b/scripts/tty/lockem.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Can be used to lock up a terminal screen until the user enters the correct +# password. Pretty sturdy. Store your password in the file "PASSWORDFILE", +# configured below. +# +# Thanks to Kevin Wika for this shell. + +source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh" + +trap '' HUP +trap '' INT +trap '' QUIT +trap '' STOP +trap '' EXIT +trap '' TSTP + +PASSWORDFILE=$TMP/lockup_password_file +LOGFILE=$TMP/session-lockup.log + +if [ ! -f "$PASSWORDFILE" ]; then + sep + echo "no password file is configured. please put your unlock password in:" + echo "$PASSWORDFILE" + sep + exit 1 +fi + +read password <$PASSWORDFILE + +echo "$(date_stringer): +++ terminal locked" >>$LOGFILE + +attempt="" + +stty -echo +while [[ $attempt != $password ]]; do + if [ ! -z "$attempt" ]; then + echo "$(date_stringer): login attempt with wrong password at $(date)" >>$LOGFILE + fi + clear + nechung + echo -ne "\npassword: " + read attempt +done +stty echo + +echo "$(date_stringer): successful login" >>$LOGFILE +echo "$(date_stringer): --- terminal unlocked" >>$LOGFILE + +clear +echo "hi $USER, your password has been accepted. enjoy your computer." +echo + + -- 2.34.1