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 exit_hook configuration option #10

Merged
merged 2 commits into from
Jun 12, 2017
Merged
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions pdns_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,19 @@ soa_edit() {
fi
}

exit_hook() {

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the white space at the begin/end of the function.

if [[ ! -z "${PDNS_EXIT_HOOK:-}" ]]; then
if [[ -x "${PDNS_EXIT_HOOK}" ]]; then
exec ${PDNS_EXIT_HOOK}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^-- SC2086: Double quote to prevent globbing and word splitting.

else
error "Your ${PDNS_EXIT_HOOK} not an executable"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change this to: error "${PDNS_EXIT_HOOK} is not an executable"

exit 1
fi
fi

}

main() {
# Set hook
hook="$1"
Expand Down Expand Up @@ -325,6 +338,13 @@ main() {
exit 0
fi

# Interface for exit_hook
if [[ "${hook}" = "exit_hook" ]]; then
shift
exit_hook $@
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^-- SC2068: Double quote array expansions to avoid re-splitting elements.

exit 0
fi

# Loop through arguments per 3
for ((i=2; i<=$#; i=i+3)); do
# Setup for this domain
Expand Down