Add an endless loop to poudboot to rebuild at intervals.
This commit is contained in:
parent
9d16e1d42e
commit
eb547bf1bf
@ -6,6 +6,9 @@ IFS=$'\n\t'
|
|||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
: ${LOCKFILE:="/var/run/poudboot.lock"}
|
: ${LOCKFILE:="/var/run/poudboot.lock"}
|
||||||
|
: ${INFO_DIR:="/opt/poudriere/run_info"}
|
||||||
|
: ${PORT_UPDATE_SECONDS:="86400"}
|
||||||
|
: ${BUILD_SECONDS:="7200"}
|
||||||
|
|
||||||
############## Setup #########################
|
############## Setup #########################
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ function build {
|
|||||||
function cmd_start {
|
function cmd_start {
|
||||||
abort_if_jobs_running
|
abort_if_jobs_running
|
||||||
|
|
||||||
|
while true; do
|
||||||
for conf in /opt/poudriere/build_configs/*; do
|
for conf in /opt/poudriere/build_configs/*; do
|
||||||
(
|
(
|
||||||
# Allow command failures without quitting the script because some
|
# Allow command failures without quitting the script because some
|
||||||
@ -78,19 +82,38 @@ function cmd_start {
|
|||||||
set +e
|
set +e
|
||||||
|
|
||||||
source "$conf"
|
source "$conf"
|
||||||
|
local RUN_DIR="$INFO_DIR/$JAIL-$PORTS-$SET"
|
||||||
|
local TIMES_FILE="$RUN_DIR/times"
|
||||||
|
mkdir -p "$RUN_DIR"
|
||||||
|
local PORTUPDATE=0
|
||||||
|
local LASTBUILD=0
|
||||||
|
if [ -e "$TIMES_FILE" ]; then
|
||||||
|
source "$TIMES_FILE"
|
||||||
|
fi
|
||||||
|
local now=$(date +%s)
|
||||||
|
if [ $((now - PORTUPDATE)) -gt "$PORT_UPDATE_SECONDS" ]; then
|
||||||
|
log "Updating ports for $JAIL-$PORTS-$SET"
|
||||||
|
portshaker -U
|
||||||
|
portshaker -M
|
||||||
|
PORTUPDATE=$(date +%s)
|
||||||
|
fi
|
||||||
|
if [ $((now - LASTBUILD)) -gt "$BUILD_SECONDS" ]; then
|
||||||
|
log "Building ports for $JAIL-$PORTS-$SET"
|
||||||
build -j "$JAIL" -p "$PORTS" -z "$SET" -f /usr/local/etc/poudriere.d/$JAIL-$PORTS-$SET-pkglist
|
build -j "$JAIL" -p "$PORTS" -z "$SET" -f /usr/local/etc/poudriere.d/$JAIL-$PORTS-$SET-pkglist
|
||||||
)
|
LASTBUILD=$(date +%s)
|
||||||
done
|
|
||||||
|
|
||||||
# Cleanup old unused dist files
|
# Cleanup old unused dist files
|
||||||
for conf in /opt/poudriere/build_configs/*; do
|
|
||||||
(
|
|
||||||
source "$conf"
|
|
||||||
poudriere distclean -y -p "$PORTS" -f /usr/local/etc/poudriere.d/$JAIL-$PORTS-$SET-pkglist
|
poudriere distclean -y -p "$PORTS" -f /usr/local/etc/poudriere.d/$JAIL-$PORTS-$SET-pkglist
|
||||||
|
poudriere logclean -y 180
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > "$TIMES_FILE" <<EOF
|
||||||
|
PORTUPDATE=$PORTUPDATE
|
||||||
|
LASTBUILD=$LASTBUILD
|
||||||
|
EOF
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
sleep 300
|
||||||
poudriere logclean -y 180
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function cmd_stop {
|
function cmd_stop {
|
||||||
|
Loading…
Reference in New Issue
Block a user