#!/bin/sh
# -*- coding: utf-8 -*-
#
#    LinOTP - the open source solution for two factor authentication
#    Copyright (C) 2010 - 2019 KeyIdentity GmbH
#
#    This file is part of LinOTP server.
#
#    This program is free software: you can redistribute it and/or
#    modify it under the terms of the GNU Affero General Public
#    License, version 3, as published by the Free Software Foundation.
#
#    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 Affero General Public License for more details.
#
#    You should have received a copy of the
#               GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#    E-mail: linotp@keyidentity.com
#    Contact: www.linotp.org
#    Support: www.keyidentity.com
#

#
# Create the htdigest entries for LinOTP manage page with static user authentication
#
REALM="LinOTP2 admin area"
DIGESTFILE=/etc/linotp2/admins

if [ $# -ne 2 ];
  then
	echo "syntax: linotp-create-digest <username> <password>"
	echo
	echo "This file creates a user entry for LinOTP authentication in the manage area" 
	exit 1
fi

USER="$1"
PASSWORD="$2"

PWDIGEST=`echo -n "$USER:$REALM:$PASSWORD" | md5sum | cut -f1 -d ' '`
echo "$USER:$REALM:$PWDIGEST" > $DIGESTFILE
