#!/usr/bin/bash

#
# Copyright 2014-2024 Senderek Web Security, Ireland. All rights reserved.
#                <https://senderek.ie/opensource/secureboot2>
#
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#
# Author:       Ralf Senderek <innovation@senderek.ie>
#
# license:      GNU General Public License version 3 or higher
# description:  asks for a passphrase for an encrypted filesystem
# processname:  securebootpassword 
# config:       none
# date:         7/5/2024
#

# Short-description:	asks for a passphrase while booting
# Description: 		securebootpassword is used by secureboot2 to provide a passphrase 
#                       that can be entered at the terminal tty8



##########################################################################
start() {
     /bin/systemd-tty-ask-password-agent --query  --plymouth
     /bin/systemd-tty-ask-password-agent --query  --console
}


##########################################################################
stop() {
     killall systemd-tty-ask-password-agent
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop) 
	stop
	;;
  restart)
	restart
	;;
  force-reload)
	restart
	;;
  *)
	echo "Usage: /usr/lib/secureboot/securebootpassword [start|stop|restart]"
	exit 1
esac

exit $RET

