nice new tool to show version of feisty meow
[feisty_meow.git] / scripts / tty / lockem.sh
1 #!/bin/bash
2
3 # Can be used to lock up a terminal screen until the user enters the correct
4 # password.  Pretty sturdy.  Store your password in the file "PASSWORD_FILE",
5 # configured below.
6 #
7 # Thanks to Kevin Wika for this shell.
8
9 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
10
11 trap '' HUP
12 trap '' INT
13 trap '' QUIT
14 trap '' STOP
15 trap '' EXIT
16 trap '' TSTP
17
18 PASSWORD_FILE=$TMP/lockem.password
19 LOG_FILE=$TMP/session-lockem.log
20
21 if [ ! -f "$PASSWORD_FILE" ]; then
22   sep
23   echo "no password file is configured.  please put your unlock password in:"
24   echo "$PASSWORD_FILE"
25   sep
26   exit 1
27 fi
28
29 chmod 700 "$PASSWORD_FILE"
30
31 read password <"$PASSWORD_FILE"
32
33 echo "$(date_stringer): +++ terminal locked" >>"$LOG_FILE"
34
35 attempt=""
36
37 stty -echo
38 while [[ $attempt != $password ]]; do
39   if [ ! -z "$attempt" ]; then
40     echo "$(date_stringer): login attempt with wrong password at $(date)" >>$LOG_FILE
41   fi
42   clear
43   nechung
44   echo -ne "\npassword: "
45   read attempt
46 done
47 stty echo
48
49 echo "$(date_stringer): successful login" >>$LOG_FILE
50 echo "$(date_stringer): --- terminal unlocked" >>$LOG_FILE
51
52 clear
53 echo "hi $USER, your password has been accepted.  enjoy your computer."
54 echo
55
56