+ $IRCSPAM < "maps/$M.irc" || true
+ fi
+ if [ -n "$BUILD_ONE" ]; then
+ exit
+ fi
+}
+
+screenshotthemap()
+{
+ REFNAME=$1
+ url=$2
+ M=$3
+ blobhash=$4
+ commithash=$5
+ if lwp-request -m HEAD "$url$M-$blobhash/$M-000000.jpg"; then
+ continue
+ fi
+
+ if ! unzip -l "$bspdir/$M-$blobhash.pk3" "maps/$M.bsp"; then
+ # no BSP file
+ continue
+ fi
+
+ rm -rf ~/.xonotic/data
+ mkdir -p ~/.xonotic/data
+ (
+ cd ../..
+ if [ -n "$DISPLAY" ]; then
+ misc/tools/xonotic-map-screenshot "$M" $screenshot_override $DRIVERFLAGS +"scr_screenshot_name \"$M-\""
+ else
+ case "$DRIVER" in
+ gl)
+ startx "$PWD/misc/tools/xonotic-map-screenshot" "$M" $screenshot_override $DRIVERFLAGS +"scr_screenshot_name \"$M-\"" -- :8
+ ;;
+ soft|*)
+ startx "$PWD/misc/tools/xonotic-map-screenshot" "$M" $screenshot_override +"vid_soft 1" $DRIVERFLAGS +"scr_screenshot_name \"$M-\"" -- /usr/bin/Xvfb :8 -screen 0 1024x768x24
+ ;;
+ esac
+ fi
+ ) 2>&1 | tee ~/.xonotic/data/autoscreenshot.log
+ good=false
+ if mv ~/.xonotic/data/screenshots "$M-$blobhash"; then
+ ss2spam "$M" "$url?d" "$REFNAME" "$commithash" 0 > ~/.xonotic/data/"$M.ircss"
+ else
+ mkdir "$M-$blobhash"
+ ss2spam "$M" "$url?d" "$REFNAME" "$commithash" 1 > ~/.xonotic/data/"$M.ircss"
+ fi
+ mv ~/.xonotic/data/"$M.ircss" "$M-$blobhash"/
+ mv ~/.xonotic/data/autoscreenshot.log "$M-$blobhash"/
+ chmod 1777 "$M-$blobhash"
+ ln -snf "../$M-$blobhash" "$M" # from ALL branches, so beware!
+ rsync -vaSHP "$M-$blobhash" "$url_ssh"
+ rsync -vaSHP "$M" "$url_ssh""latest/"
+ if [ -n "$IRCSPAM" ]; then
+ # It takes about 5 minutes for the server to update.
+ sleep 360 # Cut it one more minute of slack.
+
+ $IRCSPAM < "$M-$blobhash/$M.ircss" || true
+ fi
+ if [ -n "$BUILD_ONE" ]; then
+ exit