Find the answer to your Linux question:
Results 1 to 2 of 2
Hello everybody. I'm trying to make a bash script, that allows me to: - Start grub-md5-crypt - Enter a password - Add the md5-value for that password to /boot/grub/menu.lst automatically ...
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    8

    [SOLVED] [Bash] command output as variable (in GRUB)

    Hello everybody.

    I'm trying to make a bash script, that allows me to:
    - Start grub-md5-crypt
    - Enter a password
    - Add the md5-value for that password to /boot/grub/menu.lst automatically

    My problem is, that grub-md5-crypt is kinda weird, and gives an output like this:
    Code:
    $ grub-md5-crypt
      Password: (requires user action)
      Retype password: (requires user action)
      [md5-sum]
    I would like to just copy the md5-sum, and add it to my menu.lst.

    Does anybody know, how to do that? I was thinking about using grep, but haven't had any success yet.
    I've noticed, that all md5-sums created by that command starts with $1$, if that should be any help.

  2. #2
    Just Joined!
    Join Date
    Mar 2010
    Posts
    8
    Okay, I figured it out myself:
    Using var=$(openssl passwd -1) instead of var=$(grub-md5-crypt) I finally got it to work.

    To help others, here's my script to make and add a MD5-encrypted password to /boot/grub/menu.lst:
    Code:
    ##!/bin/bash
    grub=/boot/grub/menu.lst
    var=$(openssl passwd -1)
    echo password --md5 $var >> $grub
    Executing the above script in a console will work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...