12 lines
520 B
Bash
12 lines
520 B
Bash
#!/usr/bin/env bash
|
|
# Inherit the same open lock across bootstrap, orchestrator and nested stages.
|
|
if [[ ${EUID:-$(id -u)} -eq 0 ]]; then
|
|
if [[ ! ${IOMATEX_INSTALL_LOCK_FD:-} =~ ^[0-9]+$ ]] ||
|
|
[[ $(readlink "/proc/$$/fd/${IOMATEX_INSTALL_LOCK_FD:-999}" 2>/dev/null) != /run/lock/iomatex-installer.lock ]]; then
|
|
mkdir -p /run/lock
|
|
exec 9>/run/lock/iomatex-installer.lock
|
|
flock -n 9 || { echo 'ERROR: another Iomatex installation is running.' >&2; exit 1; }
|
|
export IOMATEX_INSTALL_LOCK_FD=9
|
|
fi
|
|
fi
|