Skip to content

Commit d5d1920

Browse files
committed
run.py: new --debug flag
It is highly disrupting to have to add `set -x` manually to the script and rebuild it, each time something goes wrong. Signed-off-by: Yann Dirson <[email protected]>
1 parent 1dc59ef commit d5d1920

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

files/init-container.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
if [ -n "$FAIL_ON_ERROR" ]; then
44
set -e
55
fi
6+
if [ -n "$SCRIPT_DEBUG" ]; then
7+
set -x
8+
fi
69

710
os_release()
811
{

run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def main():
9191
parser.add_argument('--fail-on-error', action='store_true',
9292
help='If container initialisation fails, exit rather than dropping the user '
9393
'into a command shell')
94+
parser.add_argument('--debug', action='store_true',
95+
help='Enable script tracing in container initialization (sh -x)')
9496
parser.add_argument('command', nargs=argparse.REMAINDER,
9597
help='Command to run inside the prepared container')
9698

@@ -132,6 +134,8 @@ def main():
132134
docker_args += ["-e", "NO_EXIT=1"]
133135
if args.fail_on_error:
134136
docker_args += ["-e", "FAIL_ON_ERROR=1"]
137+
if args.debug:
138+
docker_args += ["-e", "SCRIPT_DEBUG=1"]
135139
if args.syslog:
136140
docker_args += ["-v", "/dev/log:/dev/log"]
137141
if args.name:

0 commit comments

Comments
 (0)