mirror of
https://github.com/bitnami/containers.git
synced 2026-03-16 14:57:44 +08:00
Add support for custom scripts (#79)
* Add support for custom scripts Signed-off-by: juan131 <juanariza@vmware.com> * Remove DATA_DIR reference Signed-off-by: juan131 <juanariza@vmware.com> * Fix permissions issue Signed-off-by: juan131 <juanariza@vmware.com>
This commit is contained in:
committed by
GitHub
parent
88a0a564fd
commit
527e9ba179
@@ -17,7 +17,7 @@ set -o pipefail
|
||||
|
||||
# Ensure required directories exist
|
||||
chmod g+rwX "$JENKINS_BASE_DIR"
|
||||
for dir in "$JENKINS_HOME" "${JENKINS_BASE_DIR}/plugins" "$JENKINS_TMP_DIR" "$JENKINS_LOGS_DIR"; do
|
||||
for dir in "$JENKINS_VOLUME_DIR" "$JENKINS_HOME" "${JENKINS_BASE_DIR}/plugins" "$JENKINS_TMP_DIR" "$JENKINS_LOGS_DIR"; do
|
||||
ensure_dir_exists "$dir"
|
||||
configure_permissions_ownership "$dir" -d "775" -f "664"
|
||||
done
|
||||
|
||||
@@ -25,3 +25,5 @@ fi
|
||||
|
||||
# Ensure Jenkins is initialized
|
||||
jenkins_initialize
|
||||
# Allow running custom initialization scripts
|
||||
jenkins_custom_init_scripts
|
||||
|
||||
@@ -338,3 +338,46 @@ jenkins_add_custom_file() {
|
||||
echo "$action $relpath : $reason" >> "${JENKINS_LOGS_DIR}/copy_reference_file.log"
|
||||
fi
|
||||
}
|
||||
|
||||
########################
|
||||
# Run custom initialization scripts
|
||||
# Globals:
|
||||
# DB_*
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
# None
|
||||
#########################
|
||||
jenkins_custom_init_scripts() {
|
||||
if [[ -n $(find /docker-entrypoint-initdb.d/ -type f -regex ".*\.\(sh\|groovy\)") ]] && [[ ! -f "${JENKINS_VOLUME_DIR}/.user_scripts_initialized" ]] ; then
|
||||
info "Loading user's custom files from /docker-entrypoint-initdb.d";
|
||||
for f in /docker-entrypoint-initdb.d/*; do
|
||||
debug "Executing $f"
|
||||
case "$f" in
|
||||
*.sh)
|
||||
if [[ -x "$f" ]]; then
|
||||
if ! "$f"; then
|
||||
error "Failed executing $f"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
warn "Sourcing $f as it is not executable by the current user, any error may cause initialization to fail"
|
||||
. "$f"
|
||||
fi
|
||||
;;
|
||||
*.groovy)
|
||||
cp "$f" "${JENKINS_HOME}/init.groovy.d"
|
||||
jenkins_start_bg
|
||||
jenkins_stop
|
||||
# Rotate the logs in Jenkins
|
||||
mv "$JENKINS_LOG_FILE" "${JENKINS_LOGS_DIR}/jenkins.initscripts.log"
|
||||
rm "${JENKINS_HOME}/init.groovy.d/$(basename $f)"
|
||||
;;
|
||||
*)
|
||||
warn "Skipping $f, supported formats are: .sh .sql .sql.gz"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
touch "${JENKINS_VOLUME_DIR}/.user_scripts_initialized"
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user