diff --git a/ansible/roles/poudriere/files/poudboot b/ansible/roles/poudriere/files/poudboot index 53c5ca0..2bc68b7 100644 --- a/ansible/roles/poudriere/files/poudboot +++ b/ansible/roles/poudriere/files/poudboot @@ -18,7 +18,7 @@ load_rc_config $name command=/usr/sbin/daemon pidfile=/var/run/${name}.pid -command_args="-p $pidfile -u root -f -S -T $name nice -n 10 poudboot start" +command_args="-p $pidfile -u root -f -S -T $name nice -n 10 lockf -t 0 /var/run/$name.lock /root/.cargo/bin/poudboot /opt/poudriere/poudboot.sqlite3" export PATH="${PATH}:/usr/local/bin" run_rc_command "$1" diff --git a/ansible/roles/poudriere/files/poudboot.bash b/ansible/roles/poudriere/files/poudboot.bash deleted file mode 100644 index 375115c..0000000 --- a/ansible/roles/poudriere/files/poudboot.bash +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash -# -# Run poudriere at system boot. Useful for virtual machines so launching the VM also kicks off a build. -set -euo pipefail -IFS=$'\n\t' -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -: ${LOCKFILE:="/var/run/poudboot.lock"} -: ${INFO_DIR:="/opt/poudriere/run_info"} -: ${PORT_UPDATE_SECONDS:="86400"} -: ${CLEAN_SECONDS:="1209600"} -: ${BUILD_SECONDS:="7200"} -: ${LOG_RETENTION_DAYS:="30"} - -############## Setup ######################### - -# function cleanup { -# for f in "${folders[@]}"; do -# log "Deleting $f" -# rm -rf "$f" -# done -# } -# folders=() -# for sig in EXIT INT QUIT HUP TERM; do -# trap "set +e; cleanup" "$sig" -# done - -function die { - local status_code="$1" - shift - (>&2 echo "${@}") - exit "$status_code" -} - -function log { - (>&2 echo "${@}") -} - -function run_locked { - if [ "${RUN_LOCKED:-}" != "RUN" ]; then - exec env RUN_LOCKED=RUN lockf -t 0 $LOCKFILE $0 $@ - fi - -} - -############## Program ######################### - -function main { - local COMMAND="$1" - - if [ "$COMMAND" = "start" ]; then - run_locked "${@}" - shift 1 - cmd_start "${@}" - elif [ "$COMMAND" = "stop" ]; then - shift 1 - cmd_stop "${@}" - else - die 1 "Unrecognized command: $COMMAND" - fi -} - -function abort_if_jobs_running { - if [[ $(sudo poudriere status) != *"No running builds"* ]]; then - echo "There is already a poudriere build in progress, exiting." - exit 0 - fi -} - -function build { - poudriere pkgclean -v -y "$@" - poudriere bulk -J "${POUDRIERE_JOBS:-1}" "$@" -} - -function cmd_start { - abort_if_jobs_running - - while true; do - for conf in /opt/poudriere/build_configs/*; do - ( - # Allow command failures without quitting the script because some - # package sets might fail whereas others may succeed based on which - # packages are in each set. - set +e - - 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 - LASTBUILD=$(date +%s) - fi - - cat > "$TIMES_FILE" < "$GLOBAL_TIMES_FILE" <