Tue Jan 21, 2014 10:32 am
Thu Mar 27, 2014 6:11 pm
# Change/create root password
change_root_pass () {
newpass=$(yad --form --field "Password:H" --field "Retype Password:H" --separator="@_@" --title "Password" --image="dialog-password" --button=OK:0 --button=Cancel:1)
if [[ $? = 1 ]] ; then
return
fi
if [ $(echo $newpass | awk -F"@_@" '{print $1}') != $(echo $newpass | awk -F"@_@" '{print $2}') ] ; then
try_again_1
return
else
# Redirect stderr to keep the output of the passwd command.
exec 2>&1
echo $newpass | sed 's/@_@/\n/g' | chroot /target passwd
# Resume logging errors in file
exec 2>>"$error_log"
fi
}
try_again_1 () {
yad --image="gtk-dialog-warning" --title "Error" --button=Yes:0 --button=No:1 \
--text "Entries do not match. Do you want to try again?\n(If you say No, password will not be changed.)"
if [[ $? = 0 ]] ; then
change_root_pass
fi
}
yad --title="Change Root password" --button=Yes:0 --button=No:1 \
--text="Would you like to change the Root password?
This is highly Recommended. "
if [[ $? = 0 ]]; then
change_root_pass
fi
# Change user password
change_user_pass () {
newpass=$(yad --form --field "Password:H" --field "Retype Password:H" --separator="@_@" --title "Password" --image="dialog-password" --button=OK:0 --button=Cancel:1)
if [[ $? = 1 ]] ; then
return
fi
if [ $(echo $newpass | awk -F"@_@" '{print $1}') != $(echo $newpass | awk -F"@_@" '{print $2}') ] ; then
try_again_1
return
else
# Redirect stderr to keep the output of the passwd command.
exec 2>&1
echo $newpass | sed 's/@_@/\n/g' | chroot /target passwd "$newname"
# Resume logging errors in file
exec 2>>"$error_log"
fi
}
try_again_1 () {
yad --image="gtk-dialog-warning" --title "Error" --button=Yes:0 --button=No:1 \
--text "Entries do not match. Do you want to try again?\n(If you say No, password will not be changed.)"
if [[ $? = 0 ]] ; then
change_user_pass
fi
}
yad --title="Change user password" --button=Yes:0 --button=No:1 \
--text="Would you like to change the user's password?
This is highly Recommended. "
if [[ $? = 0 ]]; then
change_user_pass
fi