From a6f1847b4955f3210f8e2d3d3ad5c0f809d0d916 Mon Sep 17 00:00:00 2001 From: Gorka Lerchundi Osa Date: Sat, 28 Feb 2015 23:05:51 +0100 Subject: [PATCH] allow executing commands within supervised environment --- rootfs/etc/s6/.s6-init/init-stage1 | 5 +++-- rootfs/etc/s6/.s6-init/init-stage2 | 32 +++++++++++++++++------------- rootfs/etc/s6/.s6-svscan/finish | 4 ++-- rootfs/etc/s6/fdholderd/run | 4 ++-- rootfs/init | 5 +++-- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/rootfs/etc/s6/.s6-init/init-stage1 b/rootfs/etc/s6/.s6-init/init-stage1 index 0107e43..789fba8 100644 --- a/rootfs/etc/s6/.s6-init/init-stage1 +++ b/rootfs/etc/s6/.s6-init/init-stage1 @@ -1,4 +1,4 @@ -#!/usr/bin/execlineb -P +#!/usr/bin/execlineb ## ## dump environment into files and a bash script @@ -49,7 +49,8 @@ foreground { s6-sync } background { - /etc/s6/.s6-init/init-stage2 + elgetpositionals + /etc/s6/.s6-init/init-stage2 $@ } unexport ! diff --git a/rootfs/etc/s6/.s6-init/init-stage2 b/rootfs/etc/s6/.s6-init/init-stage2 index 6ef1e3a..4879d44 100644 --- a/rootfs/etc/s6/.s6-init/init-stage2 +++ b/rootfs/etc/s6/.s6-init/init-stage2 @@ -1,4 +1,4 @@ -#!/usr/bin/execlineb -P +#!/usr/bin/execlineb # this file is executed (not as process 1!) as soon as s6-svscan # starts. It should perform all the remaining one-time initialization @@ -6,21 +6,25 @@ if -nt { - ## - ## cont-init.d - ## + elgetpositionals + ifelse { s6-test $# -ne 0 } + { foreground { $@ } s6-svscanctl -t /etc/s6 } - foreground { s6-echo "[cont-init.d] executing container initialization scripts..." } - foreground { - forbacktickx i { - find /etc/cont-init.d -maxdepth 1 -type f ! -name ".*" ! -path /etc/cont-init.d + ## + ## cont-init.d + ## + + foreground { s6-echo "[cont-init.d] executing container initialization scripts..." } + foreground { + forbacktickx i { + find /etc/cont-init.d -maxdepth 1 -type f ! -name ".*" ! -path /etc/cont-init.d + } + import i + foreground { s6-echo "[cont-init.d] ${i}: executing..." } + foreground { with-contenv ${i} } + foreground { s6-echo "[cont-init.d] ${i}: done." } } - import i - foreground { s6-echo "[cont-init.d] ${i}: executing..." } - foreground { with-contenv ${i} } - foreground { s6-echo "[cont-init.d] ${i}: done." } - } - foreground { s6-echo "[cont-init.d] done." } + foreground { s6-echo "[cont-init.d] done." } } # if anything in the if -nt { } block fails, control jumps here. diff --git a/rootfs/etc/s6/.s6-svscan/finish b/rootfs/etc/s6/.s6-svscan/finish index 033f267..4e64a60 100644 --- a/rootfs/etc/s6/.s6-svscan/finish +++ b/rootfs/etc/s6/.s6-svscan/finish @@ -1,2 +1,2 @@ -#!/usr/bin/execlineb -P -/etc/s6/.s6-init/init-stage3 \ No newline at end of file +#!/usr/bin/execlineb +/etc/s6/.s6-init/init-stage3 diff --git a/rootfs/etc/s6/fdholderd/run b/rootfs/etc/s6/fdholderd/run index da82860..4613be2 100644 --- a/rootfs/etc/s6/fdholderd/run +++ b/rootfs/etc/s6/fdholderd/run @@ -1,2 +1,2 @@ -#!/bin/sh -exec s6-notifywhenup s6-fdholder-daemon -1 -i /etc/s6/fdholderd/rules /etc/s6/fdholderd/socket \ No newline at end of file +#!/usr/bin/execlineb +s6-notifywhenup s6-fdholder-daemon -1 -i /etc/s6/fdholderd/rules /etc/s6/fdholderd/socket \ No newline at end of file diff --git a/rootfs/init b/rootfs/init index 413769f..aec130d 100644 --- a/rootfs/init +++ b/rootfs/init @@ -1,2 +1,3 @@ -#!/usr/bin/execlineb -P -/etc/s6/.s6-init/init-stage1 \ No newline at end of file +#!/usr/bin/execlineb +elgetpositionals +/etc/s6/.s6-init/init-stage1 $@