[scripts] move file lock handling for iso_build.sh consumers from crontab

This commit is contained in:
Fabio Erculiani 2012-09-01 13:20:14 +02:00
parent 0b5b0cd946
commit e4cef07575
4 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,5 @@
#!/bin/sh
SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}"
exec "${SABAYON_MOLECULE_HOME}/scripts/iso_build_locked.sh" "daily_iso_build.sh"

View File

@ -0,0 +1,3 @@
#!/bin/sh
ISO_BUILD_LOCK=/tmp/.daily_iso_build.sh.lock

35
scripts/iso_build_locked.sh Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
if [ -z "${1}" ]; then
echo "${0} <build script name>" >&2
exit 1
fi
BUILD_SCRIPT_NAME="${1}"
SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}"
. "${SABAYON_MOLECULE_HOME}/scripts/iso_build.include"
# Pull new data from Git
(
flock --timeout 7200 -x 9
if [ "${?}" != "0" ]; then
echo "[git pull] cannot acquire lock, stale process holding it?" >&2
exit 1
fi
cd /sabayon && git pull --quiet
) 9> "${ISO_BUILD_LOCK}"
# Execute build
(
flock --timeout 7200 -x 9
if [ "${?}" != "0" ]; then
echo "[build] cannot acquire lock, stale process holding it?" >&2
exit 1
fi
"${SABAYON_MOLECULE_HOME}/scripts/${BUILD_SCRIPT_NAME}"
) 9> "${ISO_BUILD_LOCK}"
exit ${?}

View File

@ -0,0 +1,6 @@
#!/bin/sh
SABAYON_MOLECULE_HOME="${SABAYON_MOLECULE_HOME:-/sabayon}"
exec "${SABAYON_MOLECULE_HOME}/scripts/iso_build_locked.sh" \
"weekly_iso_build.sh"