@@ -839,19 +839,35 @@ case $cmd in
839839	pidfile=$( pidfn " ${name} " ) 
840840	echo  $$  >  " $pidfile " 
841841
842- 	while  !  " $script " ;  do 
843-             log " ${name} : setup failed, waiting for network changes ..." 
844- 
845- 	    #  Timeout and retry after 60 seconds, on SIGTERM, or when
846- 	    #  any network event is caught.
847- 	    timeout -s TERM -k 1 60 sh -c \
848- 		    ' ip monitor address route 2>/dev/null | head -n1 >/dev/null'   ||  true 
849- 
850- 	    #  On IP address/route changes, wait a few seconds more to ensure
851- 	    #  the system has ample time to react and set things up for us.
852- 	    log " ${name} : retrying ..." 
853- 	    sleep 2
854- 	done 
842+ 	#  Try setup once first
843+ 	if  !  " $script " ;  then 
844+ 	    #  Get image transport to decide if retries make sense
845+ 	    image=$( awk ' /^# meta-image:/ {print $3}'   " $script "   2> /dev/null ||  echo  " " ) 
846+ 	    case  " $image "   in 
847+ 		oci:*  | oci-archive:*  | docker-archive:*  | docker-daemon:*  | dir:*  | containers-storage:*  | ostree:*  | sif:*  | /* )
848+ 		    #  Local transport - exit immediately on failure
849+ 		    log " ${name} : setup failed for local image $image " 
850+ 		    rm -f " $pidfile " 
851+ 		    exit  1
852+ 		    ;;
853+ 		* )
854+ 		    #  Remote transport (docker://, ftp://, http://, https://, etc.) - retry on network changes
855+ 		    while  !  " $script " ;  do 
856+ 			log " ${name} : setup failed, waiting for network changes ..." 
857+ 
858+ 			#  Timeout and retry after 60 seconds, on SIGTERM, or when
859+ 			#  any network event is caught.
860+ 			timeout -s TERM -k 1 60 sh -c \
861+ 				' ip monitor address route 2>/dev/null | head -n1 >/dev/null'   ||  true 
862+ 
863+ 			#  On IP address/route changes, wait a few seconds more to ensure
864+ 			#  the system has ample time to react and set things up for us.
865+ 			log " ${name} : retrying ..." 
866+ 			sleep 2
867+ 		    done 
868+ 		    ;;
869+ 	    esac 
870+ 	fi 
855871
856872	rm -f " $pidfile " 
857873	;;
0 commit comments