tasty reborn terminal locking script
[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 "PASSWORDFILE",
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 PASSWORDFILE=$TMP/lockup_password_file
19 LOGFILE=$TMP/session-lockup.log
20
21 if [ ! -f "$PASSWORDFILE" ]; then
22   sep
23   echo "no password file is configured.  please put your unlock password in:"
24   echo "$PASSWORDFILE"
25   sep
26   exit 1
27 fi
28
29 read password <$PASSWORDFILE
30
31 echo "$(date_stringer): +++ terminal locked" >>$LOGFILE
32
33 attempt=""
34
35 stty -echo
36 while [[ $attempt != $password ]]; do
37   if [ ! -z "$attempt" ]; then
38     echo "$(date_stringer): login attempt with wrong password at $(date)" >>$LOGFILE
39   fi
40   clear
41   nechung
42   echo -ne "\npassword: "
43   read attempt
44 done
45 stty echo
46
47 echo "$(date_stringer): successful login" >>$LOGFILE
48 echo "$(date_stringer): --- terminal unlocked" >>$LOGFILE
49
50 clear
51 echo "hi $USER, your password has been accepted.  enjoy your computer."
52 echo
53
54