-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (JupyterHub): Uploaded run-hooks.sh
- Loading branch information
1 parent
592a514
commit 44d23e0
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
# The run-hooks.sh script looks for *.sh scripts to source | ||
# and executable files to run within a passed directory | ||
|
||
if [ "$#" -ne 1 ]; then | ||
echo "Should pass exactly one directory" | ||
return 1 | ||
fi | ||
|
||
if [[ ! -d "${1}" ]] ; then | ||
echo "Directory ${1} doesn't exist or is not a directory" | ||
return 1 | ||
fi | ||
|
||
echo "Running hooks in: ${1} as uid: $(id -u) gid: $(id -g)" | ||
for f in "${1}/"*; do | ||
# Hadling a case when the directory is empty | ||
[ -e "${f}" ] || continue | ||
case "${f}" in | ||
*.sh) | ||
echo "Sourcing shell script: ${f}" | ||
# shellcheck disable=SC1090 | ||
source "${f}" | ||
# shellcheck disable=SC2181 | ||
if [ $? -ne 0 ] ; then | ||
echo "${f} has failed, continuing execution" | ||
fi | ||
;; | ||
*) | ||
if [ -x "${f}" ] ; then | ||
echo "Running executable: ${f}" | ||
"${f}" | ||
# shellcheck disable=SC2181 | ||
if [ $? -ne 0 ] ; then | ||
echo "${f} has failed, continuing execution" | ||
fi | ||
else | ||
echo "Ignoring non-executable: ${f}" | ||
fi | ||
;; | ||
esac | ||
done | ||
echo "Done running hooks in: ${1}" |