summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
749ee8e)
gdialog is a compatibility wrapper around zenity and encourages
users to switch to usage of zenity, let's follow this recommendation.
Older zenity versions (like 3.14.0) had a different wrapping
behavior than more current versions (like 3.30.0). To avoid
small dialogs with only one or two words on each line (which
is ugly and close to unreadable) let's avoid wrapping text.
While at it fix some minor issues reported by shellcheck.
This work was funded by Grml-Forensic.
# License: This file is licensed under the GPL v2.
################################################################################
# License: This file is licensed under the GPL v2.
################################################################################
[ -n "$USER" ] || USER=grml
[ -n "$USER" ] || USER=grml
DIALOG='dialog'
PWD_CMD="dialog --stdout --title $PN --passwordbox"
DIALOG='dialog'
PWD_CMD="dialog --stdout --title $PN --passwordbox"
-# only if using X and gdialog + zenity are available use graphical frontend
-if [ -n "$DISPLAY" ] && [ -x "$(which gdialog)" ] && [ -x "$(which zenity)" ] ; then
- DIALOG='gdialog'
+GUI=false
+# only when using X and zenity is available use graphical frontend
+if [ -n "${DISPLAY}" ] && [ -x "$(command -v zenity)" ] ; then
+ DIALOG='zenity'
PWD_CMD="zenity --title $PN --entry --hide-text"
PWD_CMD="zenity --title $PN --entry --hide-text"
fi
if ! [ -r /etc/grml_version ] ; then
fi
if ! [ -r /etc/grml_version ] ; then
- $DIALOG --title "$PN" --msgbox "Warning: this system does not look like a Grml (based) system
-and therefore might not work as intended." 7 70
+ if [ "${GUI}" = true ] ; then
+ $DIALOG --no-wrap --title "$PN" --warning --text "Warning: this system does not look like a Grml (based) system,\n
+ and therefore might not work as intended."
+ else
+ $DIALOG --title "$PN" --msgbox "Warning: this system does not look like a Grml (based) system
+ and therefore might not work as intended." 7 70
+ fi
- if [ "$DIALOG" = "gdialog" ] ; then
+ if [ "${GUI}" = true ] ; then
PASSWD1="$($PWD_CMD --text="$PWD_TEXT1")"
PASSWD2="$($PWD_CMD --text="$PWD_TEXT2")"
else
PASSWD1="$($PWD_CMD --text="$PWD_TEXT1")"
PASSWD2="$($PWD_CMD --text="$PWD_TEXT2")"
else
fi
if [ -z "$PASSWD1" ] ; then
fi
if [ -z "$PASSWD1" ] ; then
- $DIALOG --title "$PN" --msgbox "Error retrieving password. Exiting." 0 0
+ if [ -n "${GUI}" ] ; then
+ $DIALOG --title "$PN" --error --text "Error retrieving password. Exiting."
+ else
+ $DIALOG --title "$PN" --msgbox "Error retrieving password. Exiting." 0 0
+ fi
if [ "$PASSWD1" = "$PASSWD2" ] ; then
echo "$USER:$PASSWD2" | sudo chpasswd
else
if [ "$PASSWD1" = "$PASSWD2" ] ; then
echo "$USER:$PASSWD2" | sudo chpasswd
else
- $DIALOG --title "$PN" --msgbox "Error: passwords do not match. Exiting." 0 0
+ if [ "${GUI}" = true ] ; then
+ $DIALOG --no-wrap --title "$PN" --error --text "Error: passwords do not match.\nExiting."
+ else
+ $DIALOG --title "$PN" --msgbox "Error: passwords do not match. Exiting." 0 0
+ fi
- if [ "$DIALOG" = "gdialog" ] ; then
- zenity --title="$PN" --question --cancel-label='Exit' --ok-label='Set password' --text="User $USER has no password set yet. Without a password you will not be able to log in again. Set password for user $USER?"
+ if [ "${GUI}" = true ] ; then
+ $DIALOG --no-wrap --title="$PN" --question --cancel-label='Exit' --ok-label='Set password' --text="User $USER has no password set yet.\nWithout a password you will not be able to log in again.\nSet password for user $USER?"
RC=$?
else
$DIALOG --title "$PN" --no-label Exit --yes-label Continue --yesno "User $USER has no password set yet. Without a password you will not be able to log in again. Set password for user $USER?" 0 0
RC=$?
else
$DIALOG --title "$PN" --no-label Exit --yes-label Continue --yesno "User $USER has no password set yet. Without a password you will not be able to log in again. Set password for user $USER?" 0 0
if ! isgrmlcd ; then
lock_desktop
else
if ! isgrmlcd ; then
lock_desktop
else
- is_passwd_set || askpwd
- [ "$?" = "0" ] && lock_desktop || exit 1
+ if is_passwd_set || askpwd ; then
+ lock_desktop
+ else
+ exit 1
+ fi
fi
## END OF FILE #################################################################
fi
## END OF FILE #################################################################