5 (echo "Usage: $0 common-name") 1>&2
9 # Check running as root
10 if [ "$(whoami)" != "root" ]; then
11 (echo "Run $0 as root.") 1>&2
15 echo 'Making the conf dir /usr/share/nginx/conf...'
16 mkdir -p /usr/share/nginx/conf
18 echo Generating the server private key...
19 openssl genrsa -out /usr/share/nginx/conf/server.key 2048
21 echo Generating the CSR...
22 openssl req -new -key /usr/share/nginx/conf/server.key \
23 -out /usr/share/nginx/conf/server.csr \
24 -subj "/C=AU/ST=WA/L=Perth/O=UWA/OU=Mechatronics/CN=$1"
26 echo Signing the certificate...
27 openssl x509 -req -days 3650 -in /usr/share/nginx/conf/server.csr \
28 -signkey /usr/share/nginx/conf/server.key \
29 -out /usr/share/nginx/conf/server.crt