File:
[LON-CAPA] /
loncom /
request_ssl_key.sh
Revision
1.2:
download - view:
text,
annotated -
select for diffs
Tue Jan 27 01:23:26 2009 UTC (16 years, 3 months ago) by
raeburn
Branches:
MAIN
CVS tags:
version_2_9_X,
version_2_9_99_0,
version_2_9_1,
version_2_9_0,
version_2_8_X,
version_2_8_99_1,
version_2_8_99_0,
version_2_8_2,
version_2_8_1,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0,
version_2_10_X,
version_2_10_1,
version_2_10_0_RC2,
version_2_10_0_RC1,
version_2_10_0,
loncapaMITrelate_1,
language_hyphenation_merge,
language_hyphenation,
bz6209-base,
bz6209,
bz5969,
bz2851,
PRINT_INCOMPLETE_base,
PRINT_INCOMPLETE,
HEAD,
GCI_3,
GCI_2,
GCI_1,
BZ5971-printing-apage,
BZ5434-fox,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse,
BZ4492-feature_Support_horizontal_radioresponse,
BZ4492-Support_horizontal_radioresponse
- Need to check for the existence (an ownership) of /home/httpd/lonCerts if run as www.
- If the script is actually run from within /home/httpd/lonCerts, lonKey.pem doesn't need to be copied (and shouldn't be removed).
#!/bin/bash
MAILADDR=certificate@lon-capa.org # Email the cert request here.
DESTDIR=/home/httpd/lonCerts # Destination for the key file.
DESTUID=www # Who will own the private key.
DESTGROUP=www # Group that will own the private key.
if [ $(whoami) != "$DESTUID" ] && [ $(whoami) != "root" ]; then
echo "This script needs to be run either as $DESTUID or root"
exit
fi
if [ $(whoami) != "root" ] ; then
if [ -d "$DESTDIR" ] ; then
CURROWNER=`stat -c %U $DESTDIR`
if [ -L "$DESTDIR" ] ; then
echo "$DESTDIR is a symbolic link. You need to remove the link and (as root) create $DESTDIR as a directory owned by $DESTUID:$DESTGROUP."
exit
elif [ $CURROWNER != $DESTUID ] ; then
echo "$DESTUID is not the owner of $DESTDIR. As root you need to change ownership of this directory to $DESTUID:$DESTGROUP."
exit
fi
else
echo "You need to create a directory: $DESTDIR (as root) and then change ownership of this directory so it is owned by $DESTUID:$DESTGROUP."
exit
fi
fi
openssl req -newkey rsa:1024 -passout pass:loncapa \
-keyout lonKey.enc -keyform PEM \
-out CertRequest.pem -outform PEM
openssl rsa -passin pass:loncapa -in lonKey.enc -out lonKey.pem
if [ $(pwd) != "$DESTDIR" ] ; then
if [ !-d "$DESTDIR" ] ; then
install -d -m 0750 -o $DESTUID -g $DESTGROUP $DESTDIR
fi
install -m 0400 -o $DESTUID -g $DESTGROUP lonKey.pem $DESTDIR
rm lonKey.pem
else
chmod 0400 lonKey.pem
fi
rm lonKey.enc
mail <CertRequest.pem -s "Certificate Request" $MAILADDR
rm CertRequest.pem
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>