X-Git-Url: http://git.grml.org/?p=grml-scripts.git;a=blobdiff_plain;f=usr_bin%2Fgrml-lock;h=6b0bf598cd085033a63e72bac313d7b4885c062d;hp=2d750506e8bcb2fd25de09293c7f8d5b22e18766;hb=86460cc3653e55e63ee6ffb1cdf9800c74e22b7a;hpb=e720deae78f1eda5e6f62629606c194f16796762 diff --git a/usr_bin/grml-lock b/usr_bin/grml-lock index 2d75050..6b0bf59 100755 --- a/usr_bin/grml-lock +++ b/usr_bin/grml-lock @@ -4,10 +4,19 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Sam Mai 27 15:12:24 CEST 2006 [mika] +# Latest change: Mon Jun 04 22:49:37 CEST 2007 [mika] ################################################################################ -PN=$0 +PN="$0" + +if [ -r /etc/grml/script-functions ] ; then + . /etc/grml/script-functions + if [ -x /usr/bin/X ] ; then + check4progs vlock xlock sudo chpasswd dialog || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 } + else + check4progs vlock sudo chpasswd dialog || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 } + fi +fi if [ -r /etc/grml_version ] ; then else @@ -16,7 +25,7 @@ it might not work as intended." 7 70 fi welcome_screen() { -dialog --stdout --title "$PN" --msgbox "Welcome to $PN! +dialog --stdout --title "$PN" --yes-label Continue --no-label Quit --yesno "Welcome to $PN! This script will lock virtual consoles when running on console or lock X server when running X. @@ -29,6 +38,13 @@ GNU screen)! Report bugs, send wishes and feedback to the grml team: http://www.grml.org/ - contact (at) grml.org " 16 65 + + case $? in + (0) # everything ok + ;; + (1) echo "Cancel pressed." ; exit 1 ;; + (255) echo "ESC pressed." ; exit 255 ;; + esac } lockcons() @@ -46,7 +62,7 @@ askxlock() dialog --stdout --title "$PN" --yesno "Now lock X?" 0 0 retval=$? case $retval in - 0) + 0) lockx ;; esac @@ -68,7 +84,7 @@ askpwd() dialog --stdout --title "$PN" --yesno "Set password for user $USER?" 0 0 retval=$? case $retval in - 0) + 0) while [ -z "$PASSWD" ] ; do PASSWD=$(dialog --stdout --title "$PN" --passwordbox "Set password (hidden typing):" 0 0) if [ -n "$PASSWD" ] ; then @@ -84,14 +100,18 @@ case $retval in esac } -if [[ $(tty) == /dev/tty* ]] ; then - welcome_screen - askpwd - askvlock -elif [ -n "$DISPLAY" ] ; then - welcome_screen - askpwd - askxlock +if ! isgrmlcd ; then + [[ $(tty) == /dev/tty* ]] && lockcons || lockx +else + if [[ $(tty) == /dev/tty* ]] ; then + welcome_screen + askpwd + askvlock + elif [ -n "$DISPLAY" ] ; then + welcome_screen + askpwd + askxlock + fi fi ## END OF FILE #################################################################