Early draft of upgrade script, handles everything but Applications section.
[shibboleth/sp.git] / configs / keygen.sh
index 0096d42..451125d 100755 (executable)
@@ -1,32 +1,36 @@
-#! /bin/sh\r
-\r
-while getopts h:y:b c\r
-     do\r
-         case $c in\r
-           b)         BATCH=1;;\r
-           h)         FQDN=$OPTARG;;\r
-           y)         DAYS=$OPTARG;;\r
-           \?)        echo keygen [-h hostname/cn for cert] [-y years to issue cert]\r
-                      exit 1;;\r
-         esac\r
-     done\r
-\r
-if  [ -e sp-key.pem ] || [ -e sp-cert.pem ] ; then\r
-    if [ -z $BATCH ] ; then  \r
-        echo The files sp-key.pem and/or sp-cert.pem already exist!\r
-        exit 2\r
-    fi\r
-    exit 0\r
-fi\r
-\r
-if [ -z $FQDN ] ; then\r
-    FQDN=`hostname`\r
-fi\r
-\r
-if [ -z $DAYS ] ; then\r
-    DAYS=10\r
-fi\r
-\r
-DAYS=$(($DAYS*365))\r
-\r
-openssl req -x509 -days $DAYS -newkey rsa:2048 -nodes -keyout sp-key.pem -out sp-cert.pem -subj /CN=$FQDN -extensions usr_cert -set_serial 0\r
+#! /bin/sh
+
+while getopts h:y:b c
+     do
+         case $c in
+           b)         BATCH=1;;
+           h)         FQDN=$OPTARG;;
+           y)         DAYS=$OPTARG;;
+           \?)        echo keygen [-h hostname/cn for cert] [-y years to issue cert]
+                      exit 1;;
+         esac
+     done
+
+if  [ -e sp-key.pem ] || [ -e sp-cert.pem ] ; then
+    if [ -z $BATCH ] ; then  
+        echo The files sp-key.pem and/or sp-cert.pem already exist!
+        exit 2
+    fi
+    exit 0
+fi
+
+if [ -z $FQDN ] ; then
+    FQDN=`hostname`
+fi
+
+if [ -z $DAYS ] ; then
+    DAYS=10
+fi
+
+DAYS=$(($DAYS*365))
+
+if [ -z $BATCH ] ; then
+    openssl req -x509 -days $DAYS -newkey rsa:2048 -nodes -keyout sp-key.pem -out sp-cert.pem -subj /CN=$FQDN -extensions usr_cert -set_serial 0
+else
+    openssl req -x509 -days $DAYS -newkey rsa:2048 -nodes -keyout sp-key.pem -out sp-cert.pem -subj /CN=$FQDN -extensions usr_cert -set_serial 0 2> /dev/null
+fi