Remove the boot and shutdown process in helper VM
[snf-image] / snf-image-helper / tasks / 40DeleteSSHKeys.in
index a71027d..9b80630 100644 (file)
@@ -19,7 +19,7 @@
 
 ### BEGIN TASK INFO
 # Provides:            DeleteSSHKeys
-# RunBefore:            UmountImage
+# RunBefore:            EnforcePersonality
 # RunAfter:             MountImage
 # Short-Description:   Remove ssh keys and in some cases recreate them
 ### END TASK INFO
@@ -27,6 +27,9 @@
 set -e
 . "@commondir@/common.sh"
 
+trap task_cleanup EXIT
+report_task_start
+
 # Check if the task should be prevented from running.
 check_if_excluded
 
@@ -69,7 +72,7 @@ if [ ! -e "$config" ]; then
 fi
 
 # Remove non-default keys...
-grep ^HostKey "$config" | while read key_line; do
+grep ^HostKey "$config" || true | while read key_line; do
     key=$(echo $key_line | cut -d" " -f2)
     if [ "$key" = $HOST_KEY -o "$key" = $RSA_KEY -o \
             "$key" = $DSA_KEY -o "$key" = $ECDSA_KEY ]; then
@@ -91,7 +94,10 @@ grep ^HostKey "$config" | while read key_line; do
             fi
         else # do some guessing...
             for i in rsa dsa ecdsa; do
-                echo "$key" | grep _${i}_ && { type="$i"; break; }
+                if echo "$key" | grep _${i}_ > /dev/null; then
+                    type="$i";
+                    break;
+                fi
             done
         fi
         if [ -z "$type" ]; then