### 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
set -e
. "@commondir@/common.sh"
+trap task_cleanup EXIT
+report_task_start
+
# Check if the task should be prevented from running.
check_if_excluded
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
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