#!/bin/sh -e

# If not on a tty, then get rid of possibly disrupting stderr output
if ! tty -s; then
    exec 2>/dev/null
fi

test -x /sbin/splashy_update

# We get some variables from cryptsetup:
# $cryptsource	the device node, like "/dev/sda3"
# $crypttarget	the device mapper name, like "sda3_crypt".

prompt="Enter passphrase to unlock"
if [ -n "$crypttarget" ]; then
    prompt="$prompt the disk $crypttarget"
fi
if [ -n "$cryptsource" ]; then
    prompt="$prompt ($cryptsource)"
fi

splash_input_password(){
    /sbin/splashy_update "getpass $1"
}

password="`splash_input_password \"$prompt: \"`"

echo -n "$password"
