aur-buildbot/init-tmate.sh

26 lines
750 B
Bash
Executable File

#!/bin/bash
source vars.sh
mkdir -p "${XDG_BUILDBOT_TMATE}"
CONFIG_FILE_LOC="$(mktemp --suffix="-aur-buildbot.conf")"
# Check if tmate sessions are empty
# TODO: implement concurrent builds
if [ -z "$(find "${XDG_BUILDBOT_TMATE}" -maxdepth 0 -empty -exec echo "1" ';')" ]; then
echo "Concurrent builds are not supported yet!"
exit 0
fi
# Write configuration file
cat > "${CONFIG_FILE_LOC}" <<EOF
set-option -g tmate-webhook-url "https://warp.mikroskeem.eu/aur_buildbot"
set-option -g tmate-webhook-userdata "some private data"
EOF
# Start up tmate
tmate -S "${XDG_BUILDBOT_TMATE}/tmate-0.sock" -f "${CONFIG_FILE_LOC}" new-session -d '/usr/bin/python3 webhook-handler.py /bin/bash -i'
# Remove configuration file
rm "${CONFIG_FILE_LOC}"