mirror of
https://github.com/hackerschoice/segfault.git
synced 2024-06-16 11:58:43 +00:00
26 lines
516 B
Bash
Executable File
26 lines
516 B
Bash
Executable File
#! /bin/bash
|
|
|
|
# EXIT unless "$2" exists.
|
|
#
|
|
# This is used by Nginx and sf-host to wait until EncFS
|
|
# has fully mounted the encrypted drives.
|
|
|
|
trap "exit 255" SIGTERM
|
|
|
|
sem="$1"
|
|
shift 1
|
|
|
|
[[ ! -f "${sem}" ]] && echo "Waiting for Semaphore '${sem}' before starting '$*'"
|
|
|
|
n=0
|
|
while :; do
|
|
[[ -n $SF_DEBUG ]] && echo "Round #${n}"
|
|
[[ -e "${sem}" ]] && { echo "Found after #${n} rounds..."; exec "$@"; }
|
|
n=$((n+1))
|
|
[[ $n -gt 10 ]] && break
|
|
sleep 1
|
|
done
|
|
|
|
echo "Semaphore '${sem}' does not yet exist. Exiting."
|
|
exit 123
|