Created
October 28, 2016 09:26
-
-
Save volkovasystems/f4661b87d44c89275a48631fdabee41d to your computer and use it in GitHub Desktop.
xvfb-run-safe
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
#!/bin/bash | |
# allow settings to be updated via environment | |
: "${xvfb_lockdir:=$HOME/.xvfb-locks}" | |
: "${xvfb_display_min:=99}" | |
: "${xvfb_display_max:=599}" | |
mkdir -p -- "$xvfb_lockdir" || exit | |
i=$xvfb_display_min # minimum display number | |
while (( i < xvfb_display_max )); do | |
if [ -f "/tmp/.X$i-lock" ]; then | |
(( ++i )); continue | |
fi | |
exec 5>"$xvfb_lockdir/$i" || continue | |
if flock -x -n 5; then | |
exec xvfb-run --server-num="$i" "$@" || exit | |
fi | |
(( i++ )) | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment