[scripts] move file lock handling for iso_build.sh consumers from crontab
This commit is contained in:
parent
0b5b0cd946
commit
e4cef07575
5
scripts/daily_iso_build_locked.sh
Executable file
5
scripts/daily_iso_build_locked.sh
Executable 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"
|
3
scripts/iso_build.include
Normal file
3
scripts/iso_build.include
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
ISO_BUILD_LOCK=/tmp/.daily_iso_build.sh.lock
|
35
scripts/iso_build_locked.sh
Executable file
35
scripts/iso_build_locked.sh
Executable 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 ${?}
|
6
scripts/weekly_iso_build_locked.sh
Executable file
6
scripts/weekly_iso_build_locked.sh
Executable 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"
|
Loading…
Reference in New Issue
Block a user