Indentation fix, cleanup.
[AROS.git] / arch / all-pc / boot / grub / util / grub-md5-crypt.in
blobc030c879305a06729ddacb07e7fee422a3c85179
1 #! /bin/sh
3 # Encrypt a password in MD5 format
4 # Copyright (C) 2000,2002 Free Software Foundation, Inc.
6 # This file is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Replaced by the configure script.
21 prefix=@prefix@
22 exec_prefix=@exec_prefix@
23 sbindir=@sbindir@
25 # Initialize some variables.
26 grub_shell=${sbindir}/grub
27 progname="grub-md5-crypt"
29 # Check the arguments.
30 for option in "$@"; do
31 case "$option" in
32 -h | --help)
33 cat <<EOF
34 Usage: $progname [OPTION]
35 Encrypt a password in MD5 format.
37 -h, --help print this message and exit
38 -v, --version print the version information and exit
39 --grub-shell=FILE use FILE as the grub shell
41 Report bugs to <bug-grub@gnu.org>.
42 EOF
43 exit 0
46 -v | --version)
47 echo "$progname (GNU GRUB ${VERSION})"
48 exit 0
51 --grub-shell=*)
52 grub_shell=`echo "$option" | sed 's/--grub-shell=//'`
56 echo "$progname: unrecognized option \`$option'"
57 echo "Usage: $progname [OPTION]"
58 echo "Try \`$progname --help' for more information."
59 exit 1
61 esac
62 done
64 # Suppress echo backs. I don't know if this is really portable. -okuji
65 stty -echo
67 # Prompt to enter a password.
68 echo -n "Password: "
69 read -r password
70 echo
72 # One more time.
73 echo -n "Retype password: "
74 read -r password2
75 echo
77 # Resume echo backs.
78 stty echo
80 if test "x$password" = x; then
81 echo "Empty password is not permitted."
82 exit 1
85 if test "x$password" != "x$password2"; then
86 echo "Sorry, passwords do not match."
87 exit 1
90 # Run the grub shell.
91 $grub_shell --batch --device-map=/dev/null <<EOF \
92 | grep "^Encrypted: " | sed 's/^Encrypted: //'
93 md5crypt
94 $password
95 quit
96 EOF
98 # Bye.
99 exit 0