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
16 nginx=/usr/share/nginx
17 if [ ! -d "$nginx" ]; then
18 (echo "nginx folder not found at $nginx.") 1>&2
22 echo 'Making the conf dir $nginx/conf...'
25 echo Generating the server private key...
26 openssl genrsa -out $nginx/conf/server.key 2048
28 echo Generating the CSR...
29 openssl req -new -key $nginx/conf/server.key -out $nginx/conf/server.csr \
30 -subj "/C=AU/ST=WA/L=Perth/O=UWA/OU=Mechatronics/CN=$1"
32 echo Signing the certificate...
33 openssl x509 -req -days 3650 -in $nginx/conf/server.csr \
34 -signkey $nginx/conf/server.key -out $nginx/conf/server.crt