Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script debugging options #156

Merged
merged 1 commit into from
Sep 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ freeipa-server container directly:
The first time this container runs, it invokes `ipa-client-install`
with the given admin password.

# Debugging

The container scripts provide some options for debugging:

- Enable shell script tracing in both the top-level `init-data` script
and the `ipa-server-configure-first` script by setting the
`$DEBUG_TRACE` environment variable.

- Disable container exit after script failure by setting the
`$DEBUG_NO_EXIT` environment variable. After failure, the
container will continue running, and can be entered for debugging
with e.g. `docker exec -it freeipa-server-container bash`.

Example usage:

docker run [...] -e DEBUG_TRACE=1 -e DEBUG_NO_EXIT=1 freeipa-server

# Copyright 2014--2016 Jan Pazdziora

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
20 changes: 20 additions & 0 deletions init-data
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

set -e

# Turn on tracing of this script
test -z "$DEBUG_TRACE" || set -x

cd /

case "$1" in
Expand Down Expand Up @@ -49,6 +52,23 @@ else
touch /run/ipa/exit-on-error
fi

# Debugging: Turn on tracing of ipa-server-configure-first script
test -z "$DEBUG_TRACE" || touch /run/ipa/debug-trace

# Debugging: Don't power off if IPA install/upgrade fails
for i in ipa-server-configure-first.service ipa-server-upgrade.service; do
if [ -n "$DEBUG_NO_EXIT" ]; then
# Create service drop-in to override `FailureAction`
mkdir -p /data/etc/systemd/system/${i}.d
echo -e "[Service]\nFailureAction=none" > \
/data/etc/systemd/system/${i}.d/50-no-poweroff.conf
else
# Debugging off: Remove service drop-in
rm -f /data/etc/systemd/system/${i}.d/50-no-poweroff.conf
fi

done

DATA=/data
COMMAND=
if [ -n "$1" ] ; then
Expand Down
2 changes: 2 additions & 0 deletions ipa-server-configure-first
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ trap mark_exit_code ERR EXIT

set -e

test ! -f /run/ipa/debug-trace || set -x

HOSTNAME=$( cat /data/hostname )

function update_server_ip_address () {
Expand Down