Browse Source

Some easy fixes

Signed-off-by: Laurent Bercot <[email protected]>
Laurent Bercot 3 years ago
parent
commit
d941dac1d3

+ 1 - 1
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/command/printcontenv

@@ -9,5 +9,5 @@ if test "0$S6_KEEP_ENV" -ne 0 ; then
   eval s6-echo -- \$$1
 else
   exec 2>/dev/null
-  exec s6-cat < "/run/s6/container_environment/$1"
+  s6-cat < "/run/s6/container_environment/$1" && echo
 fi

+ 7 - 7
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init

@@ -11,7 +11,7 @@ fi
 s6-rc-compile -v1 /run/s6/db "$etc/s6-overlay/s6-rc.d" /package/admin/s6-overlay-@VERSION@/etc/s6-rc/sources
 s6-rc-init -c /run/s6/db /run/service
 
-if timeout=`printcontenv S6_CMD_WAIT_FOR_SERVICES_MAXTIME` ; then : ; else
+if timeout=`printcontenv S6_CMD_WAIT_FOR_SERVICES_MAXTIME` && test "$timeout" -ge 0 ; then : ; else
   timeout=5000
 fi
 
@@ -20,16 +20,16 @@ s6-rc -v2 -u -t "$timeout" -- change "$top"
 r=$?
 set -e
 
-if test "$r" -ne 0 && b=`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` ; then
-  if test "$b" -eq 2 ; then
-    echo 1 > /run/s6-linux-init-container-results/exitcode
+if test "$r" -ne 0 && b=0`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && test "$b" -ne 0 ; then
+  echo '/run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs/current if you have in-container logging) for more information.' 1>&2
+  if test "$b" -ge 2 ; then
+    echo '/run/s6/basedir/scripts/rc.init: fatal: stopping the container.' 1>&2
+    echo "$r" > /run/s6-linux-init-container-results/exitcode
     exec /run/s6/basedir/bin/halt
-  elif test "$b" -eq 1 ; then
-    echo '/run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs if you have in-container logging) for more information.' 1>&2
   fi
 fi
 
-if test -n "$1" ; then
+if test "$#" -ne 0 ; then
   set +e
   arg0=`printcontenv S6_CMD_ARG0`
   $arg0 "$@"

+ 1 - 1
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/etc/s6-rc/scripts/cont-finish

@@ -11,7 +11,7 @@ if ! kimeout=`printcontenv S6_KILL_FINISH_MAXTIME` ; then
 fi
 
 for file in `s6-ls "$etc/cont-finish.d" 2>/dev/null | s6-sort` ; do
-  echo "[s6-overlay] cont-finish: running $etc/cont-finish.d/$file"
+  echo "cont-finish: info: running $etc/cont-finish.d/$file" 1>&2
   s6-maximumtime -k "$kimeout" "$etc/cont-finish.d/$file"
 done
 

+ 9 - 6
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/etc/s6-rc/scripts/cont-init

@@ -1,6 +1,6 @@
 #!/bin/sh -e
 
-r=0
+r=false
 
 if profile=`printcontenv S6_RUNTIME_PROFILE` ; then
   etc="/etc/cont-profile.d/$profile"
@@ -9,17 +9,20 @@ else
 fi
 
 for file in `s6-ls "$etc/cont-init.d" 2>/dev/null | s6-sort` ; do
-  echo "[s6-overlay] cont-init: running $etc/cont-init.d/$file"
+  echo "cont-init: info: running $etc/cont-init.d/$file" 1>&2
   set +e
   "$etc/cont-init.d/$file"
   b="$?"
   set -e
-  echo "[s6-overlay] cont-init: $etc/cont-init.d/$file exited $b"
+  echo "cont-init: info: $etc/cont-init.d/$file exited $b" 1>&2
   if test "$b" -ne 0 ; then
-    r=1
+    r=true
   fi
 done
 
-if test "$r" -ne 0 && b=`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && test "0$b" -eq 2 ; then
-  exit 1
+if $r && b=0`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && test "$b" -ne 0 ; then
+  echo 'cont-init: warning: some scripts exited nonzero' 1>&2
+  if test "$b" -ge 2 ; then
+    exit 1
+  fi
 fi

+ 12 - 9
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/etc/s6-rc/scripts/fix-attrs

@@ -1,7 +1,7 @@
 #!/bin/sh -e
 
-got=0
-err=0
+got=false
+err=false
 
 if profile=`printcontenv S6_RUNTIME_PROFILE` ; then
   etc="/etc/cont-profile.d/$profile"
@@ -10,10 +10,10 @@ else
 fi
 
 apply () {
-  echo "[s6-overlay] fix-attrs: applying $1"
-  got=1
+  echo "fix-attrs: info: applying $1" 1>&2
+  got=true
   if ! /package/admin/s6-overlay-@VERSION@/libexec/fix-attrs < "$1" ; then
-    err=1
+    err=true
   fi
 }
 
@@ -21,9 +21,12 @@ for file in `s6-ls "$etc/fix-attrs.d" 2>/dev/null | s6-sort` ; do
   apply "$etc/fix-attrs.d/$file"
 done
 
-if test "$got" -ne 0 ; then
-  echo '[s6-overlay] fix-attrs: warning: fix-attrs is deprecated, please fix volume permissions in Dockerfile instead' 1>&2
+if $got ; then
+  echo 'fix-attrs: warning: fix-attrs is deprecated, please fix volume permissions in your container manager instead' 1>&2
 fi
-if test "$err" -ne 0 && b=`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && test "$b" -eq 2 ; then
-  exit 1
+if $err && b=0`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && test "$b" -ne 0 ; then
+  echo 'fix-attrs: warning: some fix files failed to apply' 1>&2
+  if test "$b" -ge 2 ; then
+    exit 1
+  fi
 fi

+ 0 - 3
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/etc/s6-rc/scripts/services-down

@@ -4,8 +4,6 @@ dir=/run/s6/legacy-services
 list=
 links=
 
-echo '[s6-overlay] legacy-services: bringing all services down...'
-
 for i in `s6-ls "$dir"` ; do
   links="$links /run/service/$i"
   list="$list $dir/$i"
@@ -23,5 +21,4 @@ if test -n "$list" ; then
   s6-svwait -D -t "$grace" -- $list
 fi
 
-s6-echo '[s6-overlay] legacy-services:   ... done'
 exit 0

+ 11 - 9
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/etc/s6-rc/scripts/services-up

@@ -7,7 +7,6 @@ else
 fi
 
 dir=/run/s6/legacy-services
-echo "[s6-overlay] legacy-services: copying and starting services in $etc/services.d"
 
 s6-rmrf "$dir"
 s6-mkdir -p -m 0755 "$dir"
@@ -17,10 +16,13 @@ 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
@@ -36,21 +38,21 @@ if test 0`printcontenv S6_CMD_WAIT_FOR_SERVICES` -ne 0 ; then
   if ! maxtime=`printcontenv S6_CMD_WAIT_FOR_SERVICES_MAXTIME` ; then
     maxtime=0
   fi
-  echo "[s6-overlay] legacy-services: waiting for services to get ready..."
 
   # Increase if necessary. Unavoidable race condition, use s6-rc instead!
   s6-sleep -m 5
 
-  r=0
+  r=false
   if test -n "$notifno" && ! s6-svwait -u -t "$maxtime" -- $notifno ; then
-    r=1
+    r=true
   fi
   if test -n "$notifyes" && ! s6-svwait -U -t "$maxtime" -- $notifyes ; then
-    r=1
+    r=true
   fi
-  if test "$r" -ne 0 && b=`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && test "$b" -eq 2 ; then
-    echo "[s6-overlay] legacy-services:   ... failed"
-    exit 1
+  if $r && b=0`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` && test "$b" -ne 0 ; then
+    echo 'services-up: warning: some legacy longruns failed to start' 1>&2
+    if test "$b" -ge 2 ; then
+      exit 1
+    fi
   fi
-  echo "[s6-overlay] legacy-services:   ... done"
 fi

+ 2 - 2
layout/rootfs-overlay/package/admin/s6-overlay-@VERSION@/libexec/stage0

@@ -34,9 +34,9 @@ else
   syncopt=''
 fi
 
-s6-linux-init-maker -D top -c "$basedir" -NCt2 -p "$PATH" -f /package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel $dumpopt $logopt $graceopt $syncopt
+s6-linux-init-maker -D top -c "$basedir" -NCt2 -p "$PATH" -f /package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel $dumpopt $logopt $graceopt $syncopt -- "$basedir"
 
-if test "0$S6_KEEP_ENV" -ne 0 ; then
+if test -z "$dumpopt" ; then
   s6-rename "$basedir/env" "$basedir/env.orig"
   s6-dumpenv "$basedir/env"
   for file in `s6-ls "$basedir/env.orig"` ; do