3 # Purpose: lock console
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Mon Jun 04 22:49:37 CEST 2007 [mika]
8 ################################################################################
12 if [ -r /etc/grml/script-functions ] ; then
13 . /etc/grml/script-functions
14 if [ -x /usr/bin/X ] ; then
15 check4progs vlock xlock sudo chpasswd dialog || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 }
17 check4progs vlock sudo chpasswd dialog || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 }
21 if [ -r /etc/grml_version ] ; then
23 dialog --stdout --title "$PN" --msgbox "Warning: this system does not look like a grml-system
24 it might not work as intended." 7 70
28 dialog --stdout --title "$PN" --yes-label Continue --no-label Quit --yesno "Welcome to $PN!
30 This script will lock virtual consoles when running
31 on console or lock X server when running X.
33 Notice that you can not lock a GNU screen-session
34 via this script, use the lockscreen command
35 instead (default is pressing ctrl-a x inside
38 Report bugs, send wishes and feedback to the grml team:
39 http://www.grml.org/ - contact (at) grml.org
45 (1) echo "Cancel pressed." ; exit 1 ;;
46 (255) echo "ESC pressed." ; exit 255 ;;
62 dialog --stdout --title "$PN" --yesno "Now lock X?" 0 0
73 dialog --stdout --title "$PN" --yesno "Now lock consoles?" 0 0
84 dialog --stdout --title "$PN" --yesno "Set password for user $USER?" 0 0
88 while [ -z "$PASSWD" ] ; do
89 PASSWD=$(dialog --stdout --title "$PN" --passwordbox "Set password (hidden typing):" 0 0)
90 if [ -n "$PASSWD" ] ; then
91 echo "$USER:$PASSWD" | sudo chpasswd
93 dialog --stdout --title "$PN" --msgbox "Error while setting password. Empty passwords are not accepted." 6 65
104 [[ $(tty) == /dev/tty* ]] && lockcons || lockx
106 if [[ $(tty) == /dev/tty* ]] ; then
110 elif [ -n "$DISPLAY" ] ; then
117 ## END OF FILE #################################################################