Advertisement
opsftw

Terminal Lock-Screen

Sep 1st, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.90 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # USAGE:
  4. # lock.sh "password" "Message to display, e.g. reason for leaving"
  5. #
  6. trap "" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  7. clear
  8. bad=false
  9. times=0
  10. wait_time=2
  11. while true
  12. do
  13.     echo ""
  14.     echo ""
  15.     echo ""
  16.     echo ""
  17.     echo ".------------------[" $2 $3 $4 $5 $6 $7 $8 $9 "| Failed attempts: $times ]-------->"
  18.     if [ $bad == true ]; then
  19.         echo "\`-----Password: ###Incorrect, please wait $wait_time seconds###"
  20.        sleep $wait_time
  21.        clear
  22.        echo ""
  23.        echo ""
  24.        echo ""
  25.        echo ""
  26.        echo ".------------------[" $2 $3 $4 $5 $6 $7 $8 $9 "| Failed attempts: $times ]-------->"
  27.    fi
  28.    read -s -p "\`-----Password: " pass
  29.     if [ "$pass" == "$1" ]; then
  30.         break
  31.     fi
  32.     bad=true
  33.     let times+=1
  34.     wait_time=$(echo "2*$times+1" | bc)
  35.     clear
  36. done
  37. clear
  38. echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement