xcat-core/xCAT-server-2.0/usr/share/xcat/scripts/setup-server-cert.sh
jbjohnso c99d72a179 Initial xCAT 2.0 import
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
2007-10-26 22:44:33 +00:00

44 lines
1.1 KiB
Bash
Executable File

# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#XCATDIR=`gettab key=xcatconfdir site.value`
if [ -z "$XCATDIR" ]; then
XCATDIR=/etc/xcat
fi
if [ -z "$1" ]; then
echo "Usage: $0 servername"
fi
CNA=$*
XCATCADIR=$XCATDIR/ca
if [ -e $XCATDIR/cert ]; then
echo -n "$XCATDIR/cert already exists, delete and start over (y/n)?"
read ANSWER
if [ "$ANSWER" != "y" ]; then
echo "Aborting at user request"
exit 0
fi
rm -rf $XCATDIR/cert
fi
mkdir -p $XCATDIR/cert
cd $XCATDIR/cert
openssl genrsa -out server-key.pem 2048
openssl req -config $XCATCADIR/openssl.cnf -new -key server-key.pem -out server-req.pem -subj "/CN=$CNA"
cp server-req.pem $XCATDIR/ca/`hostname`.csr
cd -
cd $XCATDIR/ca
# - "make sign" doesn't seem to work on my AIX system???
# - seems to be a problem with the use of the wildcard in the Makefile
# - call cmds directly instead - seems safe
# make sign
openssl ca -config openssl.cnf -in `hostname`.csr -out `hostname`.cert
if [ -f `hostname`.cert ]; then
rm `hostname`.csr
fi
cp `hostname`.cert $XCATDIR/cert/server-cert.pem
cp ca-cert.pem $XCATDIR/cert/ca.pem
cd -