#!/bin/bash

# SPDX-FileCopyrightText: 2021-2023 KUNBUS GmbH <support@kunbus.com>
#
# SPDX-License-Identifier: GPL-2.0-or-later

function usage {
	echo 'usage: piSerial [-p|-s|-v]

  -p print the generated password
  -s print the serial number
  -v show revpi-piserial version and exit
If no option is specified the serial number and password are printed.'
}

while getopts ":spv" OPTION ; do
	case ${OPTION} in
	s)
		;;
	p)
		;;
	v)
		;;
	*)
		usage
		exit 1;
		;;
	esac
done

if [ -e /dev/tpm0 ] ; then
	exec sudo /usr/sbin/revpi-serial -t /dev/tpm0 "$@";
else
	exec sudo /usr/sbin/revpi-serial -c /dev/i2c-1 "$@";
fi
