B #247: Retry CD-ROM mount

Closes #247
pull/252/head
Vlastimil Holer 3 years ago
parent 484e436596
commit bc0743fcf8
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -192,24 +192,38 @@ function get_new_context {
log debug "Mounting CD-ROM ${dev_context} on ${MOUNT_DIR}" log debug "Mounting CD-ROM ${dev_context} on ${MOUNT_DIR}"
case "${distro}" in # Retry mounting several times
Linux) # https://github.com/OpenNebula/addon-context-linux/issues/247
mount -o ro "${dev_context}" "${MOUNT_DIR}" 2>/dev/null _timeout=6
;; while [ "$_timeout" -gt 0 ] ; do
BSD) case "${distro}" in
mount_cd9660 "${dev_context}" "${MOUNT_DIR}" 2>/dev/null Linux)
;; mount -o ro "${dev_context}" "${MOUNT_DIR}" 2>/dev/null
*) ;;
echo "ERROR: Unsupported distro ${distro}" BSD)
exit 1 mount_cd9660 "${dev_context}" "${MOUNT_DIR}" 2>/dev/null
esac ;;
*)
if [ "$?" != '0' ]; then echo "ERROR: Unsupported distribution - ${distro}" >&2
exit 1
esac
if [ $? -eq 0 ] ;then
_mount_dir_mounted=yes
break
else
# sleep and retry
_timeout=$(( _timeout - 1 ))
log debug "Mount failed (retries left: (${_timeout})"
sleep 1
fi
done
if [ "${_timeout}" -eq 0 ] || [ "${_mount_dir_mounted}" != 'yes' ]; then
log err "Error: Failed to mount ${dev_context}" 2 log err "Error: Failed to mount ${dev_context}" 2
exit 1 exit 1
fi fi
_mount_dir_mounted=yes
context_sh $MOUNT_DIR context_sh $MOUNT_DIR
elif find '/context' -mindepth 1 -print 2>/dev/null | grep -q .; then elif find '/context' -mindepth 1 -print 2>/dev/null | grep -q .; then

Loading…
Cancel
Save