forked from kalipso/infrastructure
Add unlock-boot script
This commit is contained in:
30
scripts/unlock-boot.sh
Normal file
30
scripts/unlock-boot.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
||||
sshoptions="-o StrictHostKeyChecking=no -o ServerAliveInterval=1 -o ServerAliveCountMax=1 -p 222 -T"
|
||||
HOSTNAME=$1
|
||||
|
||||
echo
|
||||
diskkey=$(sops -d machines/$HOSTNAME/disk.key)
|
||||
|
||||
if [ $# = 1 ]
|
||||
then
|
||||
echo "$diskkey" | ssh $sshoptions root@$HOSTNAME-initrd "systemd-tty-ask-password-agent" #storage
|
||||
|
||||
echo "$diskkey" | ssh $sshoptions root@$HOSTNAME-initrd "systemd-tty-ask-password-agent" #root
|
||||
|
||||
elif [ $# = 2 ]
|
||||
then
|
||||
IP=$2
|
||||
|
||||
echo "$diskkey" | ssh $sshoptions root@$IP "systemd-tty-ask-password-agent" #storage
|
||||
|
||||
echo "$diskkey" | ssh $sshoptions root@$IP "systemd-tty-ask-password-agent" #root
|
||||
|
||||
else
|
||||
echo
|
||||
echo "Unlock the root disk on a remote host."
|
||||
echo "Usage: $0 <hostname> [ip]"
|
||||
echo "If an IP is not provided, the hostname will be used as the IP address."
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user