#!/bin/sh -e if profile=`printcontenv S6_RUNTIME_PROFILE` ; then etc="/etc/cont-profile.d/$profile" else etc=/etc fi dir=/run/s6/legacy-services s6-rmrf "$dir" s6-mkdir -p -m 0755 "$dir" list= notifno= notifyes= for i in `s6-ls "$etc/services.d" 2>/dev/null | s6-sort` ; do if test -d "$etc/services.d/$i" ; then list="$list $i" s6-echo -n -- "services-up: info: copying legacy longrun $i" 1>&2 if test -r "$dir/$i/notification-fd" ; then notifyes="$notifyes $dir/$i" echo 1>&2 else notifno="$notifno $dir/$i" echo ' (no readiness notification)' 1>&2 fi s6-hiercopy "$etc/services.d/$i" "$dir/$i" fi done for file in $list ; do s6-ln -nsf "$dir/$file" "/run/service/$file" done s6-svscanctl -a /run/service if dowait=`printcontenv S6_CMD_WAIT_FOR_SERVICES` && s6-test "$dowait" =~ '^[[:digit:]]+$' -a "$dowait" -gt 0 ; then if maxtime=`printcontenv S6_CMD_WAIT_FOR_SERVICES_MAXTIME` && s6-test "$maxtime" =~ '^[[:digit:]]+$' ; then : ; else maxtime=0 fi # Increase if necessary. Unavoidable race condition, use s6-rc instead! s6-sleep -m 5 r=false if test -n "$notifno" && ! s6-svwait -u -t "$maxtime" -- $notifno ; then r=true fi if test -n "$notifyes" && ! s6-svwait -U -t "$maxtime" -- $notifyes ; then r=true fi if $r && b=`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && s6-test "$b" =~ '^[[:digit:]]+$' -a "$b" -gt 0 ; then echo 'services-up: warning: some legacy longruns failed to start' 1>&2 if test "$b" -ge 2 ; then exit 1 fi fi fi