#!/bin/sh

set -e

NAME="$(basename "${0}")"
KEY="/var/lib/beszel-hub/beszel_data/id_ed25519"

if [ "$(id -u)" -ne 0 ]
then
	echo "'${NAME}': need root privileges" >&2
	exit 1
fi

if [ ! -e "${KEY}" ]
then
	echo "E: no key available" >&2
	exit 1
fi

if [ ! -e /usr/bin/ssh-keygen ]
then
	echo "E: no openssh-client installed" >&2
	exit 1
fi

ssh-keygen -f "${KEY}" -y
