]> git.pond.sub.org Git - empserver/blob - src/scripts/nightly/nightlybuild.sh
03e1a8a460ad9efa613e1df655e6d7d9e5080eb4
[empserver] / src / scripts / nightly / nightlybuild.sh
1 #!/bin/sh
2 #
3 # Blame it on marcolz
4 #
5 # Skip certain parts of this script by exporting the variable
6 # "NIGHTLY_SKIP_STEP" containing the following possible substrings,
7 # preventing the named behaviour:
8 #
9 # REDIRECT      -       Redirect all output to a logfile
10 # CHECKOUT      -       Fill the sandbox with a fresh checkout
11 # PATCH         -       Apply the patches for this system (global + specific)
12 # BUILD         -       Build everything
13 # GENERATE      -       Generate a new world
14 # SERVERSTART   -       Start the server
15 # TESTSCRIPT    -       Run the testscript
16 # SERVERSTOP    -       Stop the server if it was started by this script
17 # CLEANUP       -       Remove the contents of the sandbox
18 # REMOVE_REPOSITORY     Removes the git repository when cleaning up
19 #
20
21 PROGNAME="$0"
22 TERM="${TERM:-vt100}"
23 export TERM
24
25 usage() {
26         echo "Usage: ${PROGNAME} <configfile>" >&2;
27         exit 1;
28 }
29
30 [ $# -lt 1 ] && usage
31
32 [ -f "$1" ] || usage
33
34 # Source config file
35 case "$1"
36 in
37         */*)
38                 . "$1"
39                 ;;
40         *)
41                 . ./"$1"
42                 ;;
43 esac
44
45 [ -f "${SCRIPTDIR}/common.sh" ] || { echo "Broken config ?" >&2; exit 1; }
46 . "${SCRIPTDIR}"/common.sh
47
48
49 STAMP="`date +%Y%m%d%H%M%S`"
50 WORKDIR="${INSTANCE}"
51 [ -n "${EXTRASUFFIX}" ] && WORKDIR="${WORKDIR}.${EXTRASUFFIX}"
52 LOGFILE="${LOGDIR}/${WORKDIR}.${STAMP}"
53
54 #
55 # START REDIRECT
56 #
57 case "${NIGHTLY_SKIP_STEP}"
58 in
59         *REDIRECT*) ;;
60         *)
61
62 # Log everything
63 exec > "${LOGFILE}"
64 exec 2>&1
65
66                 ;;
67 esac
68 #
69 # END REDIRECT
70 #
71
72 case "${BOXDIR}"
73 in
74         /*)
75                 ;;
76         *)
77                 BOXDIR="${SCRIPTDIR}/${BOXDIR}"
78                 ;;
79 esac
80
81 cd "${BOXDIR}" || err "Could not chdir to ${BOXDIR}"
82
83 echo "Nightly build starting at `date`"
84
85
86 #
87 # START CHECKOUT
88 #
89 case "${NIGHTLY_SKIP_STEP}"
90 in
91         *CHECKOUT*) ;;
92         *)
93
94 # Make sandbox
95 if [ -d "${WORKDIR}" ]
96 then
97         ! [ -d "${WORKDIR}"/empserver/.git ]  || err "Invalid sandbox, missing .git directory"
98 else
99         echo making directory
100         mkdir "${WORKDIR}" || warn "Could not create ${BOXDIR}/${WORKDIR}"
101 fi
102 cd "${WORKDIR}" || err "Could not cd to ${BOXDIR}/${WORKDIR}"
103
104 echo "Getting source from GIT:"
105 # Extract source
106 export GITROOT=${GITROOT:= git://git.pond.sub.org/~armbru/empserver}
107 RETR=0
108 if ! [ -d empserver ]
109 then
110         while ! git clone $GITROOT empserver >/dev/null
111         do
112                 sleep "`expr 5 + ${RETR}`"
113                 RETR="`expr 1 + ${RETR}`"
114                 [ "${RETR}" -gt 5 ] && err "git-clone Timeout after ${RETR} retres."
115         done
116         cd empserver || err "Could not cd to ${BOXDIR}/${WORKDIR}/empserver."
117 else
118         cd empserver || err "Could not cd to ${BOXDIR}/${WORKDIR}/empserver."
119         while ! git pull $GITROOT master >/dev/null
120         do
121                 sleep "`expr 5 + ${RETR}`"
122                 RETR="`expr 1 + ${RETR}`"
123                 [ "${RETR}" -gt 5 ] && err "GIT pull Timeout after ${RETR} retres."
124 done
125
126 fi
127
128 echo "Done (GIT)."
129 echo ""
130                 ;;
131 esac
132 #
133 # END CHECKOUT
134 #
135
136 #
137 # START PATCH
138 #
139 cd "${BOXDIR}/${WORKDIR}/empserver" || err "Could not cd to ${BOXDIR}/${WORKDIR}/empserver"
140 case "${NIGHTLY_SKIP_STEP}"
141 in
142         *PATCH*) ;;
143         *)
144
145 echo "Applying global patches from ${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"
146 for i in "${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"/*.patch
147 do
148         [ -r "${i}" ] || continue
149         if git apply "${i}" >/dev/null
150         then
151                 echo "${i}: OK"
152         else
153                 echo "========== ${i}: NOT OK! ${?} =========="
154         fi
155 done
156 echo "Done (patch All)."
157 echo ""
158
159 LOCALPATCHDIRECTORY="${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/${INSTANCE}"
160 if [ -n "${LOCALPATCHDIRECTORY}" -a -d "${LOCALPATCHDIRECTORY}/." ]
161 then
162         echo "Applying system specific patches from ${LOCALPATCHDIRECTORY}:"
163         for i in "${LOCALPATCHDIRECTORY}"/*.patch
164         do
165                 [ -r "${i}" ] || continue
166                 if git apply "${i}" >/dev/null
167                 then
168                         echo "${i}: OK"
169                 else
170                         echo "========== ${i}: NOT OK! ${?} =========="
171                 fi
172         done
173         echo "Done (patch specific)."
174         echo ""
175 fi
176
177 git-pull
178 sh ./bootstrap
179 ./configure --prefix ${BOXDIR}/${WORKDIR}/emp4 ${CONFIGURE_OPTIONS}
180
181                 ;;
182 esac
183 #
184 # END PATCH
185 #
186
187 #
188 # START BUILD
189 #
190 case "${NIGHTLY_SKIP_STEP}"
191 in
192         *BUILD*) ;;
193         *)
194
195
196 # Start the build
197 echo "Building server"
198 if make -k install >/dev/null
199 then
200         warn "make did not return 0"
201 fi
202 echo "Done (make)."
203 echo ""
204
205                 ;;
206 esac
207 #
208 # END BUILD
209 #
210
211 cd "${BOXDIR}/${WORKDIR}" || err "Could not cd to ${BOXDIR}/${WORKDIR}"
212 # Try to run startup utilities
213 for onetime in 1
214 do
215         #
216         # START GENERATE
217         #
218         case "${NIGHTLY_SKIP_STEP}"
219         in
220                 *GENERATE*) ;;
221                 *)
222
223         if [ -d emp4 -a -d emp4/bin -a -d emp4/sbin -a -d emp4/var/empire ]
224         then
225                 echo "Directory structure is ok"
226         else
227                 warn "Directory structure is NOT ok"
228                 break
229         fi
230
231         if [ ! -f emp4/etc/empire/schedule ]
232         then
233                 warn "schedule file is missing"
234                 break
235         fi
236
237         if [ ! -f emp4/etc/empire/econfig ]
238         then
239                 warn "econfig file is missing"
240                 break
241         fi
242
243         if ! emp4/sbin/pconfig >emp4/etc/empire/econfig
244         then
245                 warn "pconfig failed to create econfig file"
246                 break
247         fi
248 echo "Applying global econfig patches from ${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"
249 for i in "${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/All"/*.econfig
250 do
251         [ -r "${i}" ] || continue
252         if "${i}" >>emp4/etc/empire/econfig
253         then
254                 echo "${i}: OK"
255         else
256                 echo "========== ${i}: NOT OK! ${?} =========="
257         fi
258 done
259 echo "Done (econfig patch All)."
260 echo ""
261
262 LOCALPATCHDIRECTORY="${BOXDIR}/${WORKDIR}/empserver/src/scripts/nightly/patches/${INSTANCE}"
263 if [ -n "${LOCALPATCHDIRECTORY}" -a -d "${LOCALPATCHDIRECTORY}/." ]
264 then
265         echo "Applying system specific econfig patches from ${LOCALPATCHDIRECTORY}:"
266         for i in "${LOCALPATCHDIRECTORY}"/*.econfig
267         do
268                 [ -r "${i}" ] || continue
269                 if "${i}" >>emp4/etc/empire/econfig
270                 then
271                         echo "${i}: OK"
272                 else
273                         echo "========== ${i}: NOT OK! ${?} =========="
274                 fi
275         done
276         echo "Done (econfig patch specific)."
277         echo ""
278 fi
279
280         cd emp4/bin || err "Could not cd to emp4/bin"
281
282         echo "Determining type of files in bin directory"
283         file *
284         echo "Done (file *)."
285         echo ""
286
287         cd ../sbin || err "Could not cd to ../sbin"
288
289         echo "Determining type of files in sbin directory"
290         file *
291         echo "Done (file *)."
292         echo ""
293
294         echo "Running files and fairland"
295         echo y | ./files -e ../etc/empire/econfig || warn "Error running files"
296         ./fairland -R 1 -e ../etc/empire/econfig 10 30 >/dev/null || { warn "Error running fairland" ; break ; }
297         [ -s "newcap_script" ] || { warn "fairland did not produce newcap_script" ; break ; }
298         echo "Done (files & fairland)."
299         echo ""
300
301                         ;;
302         esac
303         #
304         # END GENERATE
305         #
306
307         #
308         # START SERVERSTART
309         #
310         case "${NIGHTLY_SKIP_STEP}"
311         in
312                 *SERVERSTART*) ;;
313                 *)
314
315         echo "Removing existing server.log and journal.log"
316         if [ -f "../var/empire/server.log" ]
317         then
318             rm "../var/empire/server.log"
319         fi
320         if [ -f "../var/empire/journal.log" ]
321         then
322             rm "../var/empire/journal.log"
323         fi
324         echo "Removing existing schedule"
325         if [ -f "../etc/empire/schedule" ]
326         then
327             >../etc/empire/schedule
328         fi
329         echo "Starting server with -d in the background"
330         ./emp_server -R 1 -e ../etc/empire/econfig -d 2>/dev/null &
331         PID="$!"
332         sleep 1
333         kill -0 "${PID}" || { warn "emp_server not running ?" ; break ; }
334         echo "Done (emp_server)."
335         echo ""
336
337                         ;;
338         esac
339         #
340         # END SERVERSTART
341         #
342
343         #
344         # START GENERATE (2nd part)
345         #
346         case "${NIGHTLY_SKIP_STEP}"
347         in
348                 *GENERATE*) ;;
349                 *)
350
351         echo "Running newcap_script through empire"
352         runfeed POGO peter < newcap_script >/dev/null 2>&1 ||
353                 {
354                         warn "Could not run newcap_script"
355                         echo "Stopping server"
356                         trykill $PID
357                         break
358                 }
359         echo "Done (newcap_script / empire)."
360         echo ""
361
362         echo "TODO: Replace this with a real test script."
363         echo "Just do some rudimentary testing for now."
364         echo ""
365
366                         ;;
367         esac
368         #
369         # END GENERATE (2nd part)
370         #
371
372         #
373         # START TESTSCRIPT
374         #
375         case "${NIGHTLY_SKIP_STEP}"
376         in
377                 *TESTSCRIPT*) ;;
378                 *)
379
380         for PLAYER in 2 3 4 5 6 7 8 9 10
381         do
382                 echo "explore for player ${PLAYER}"
383                 runfeed $PLAYER << EOF >/dev/null 2>&1
384 break
385 expl c 0,0 1 uh
386 desi 1,-1 +
387 mov c 0,0 205 uh
388 desi 1,-1 g
389 cen *
390 EOF
391                 echo "Done (explore)."
392                 echo ""
393         done
394
395         # Something more elaborate for player 1
396         echo "explore and more for player 1"
397         runfeed 1 << EOF >/dev/null 2>&1
398 break
399 expl c 0,0 1 uh
400 expl c 2,0 1 jh
401 expl c 2,0 1 uh
402 expl c 2,0 1 nh
403 expl c 2,0 1 bh
404 expl c 0,0 1 yh
405 expl c 0,0 1 gh
406 expl c 0,0 1 bh
407 desi * ?ne=- +
408 expl c 2,0 1 njh
409 expl c 2,0 1 nnh
410 expl c 2,0 1 bnh
411 expl c 0,0 1 bbh
412 expl c 0,0 1 yyh
413 expl c 0,0 1 yuh
414 expl c 0,0 1 bnh
415 expl c 2,0 1 yuh
416 expl c 2,0 1 uuh
417 expl c 2,0 1 juh
418 desi * ?ne=- +
419 expl c 2,0 1 nnnh
420 expl c 2,0 1 nnjh
421 expl c 2,0 1 njjh
422 expl c 2,0 1 uujh
423 expl c 0,0 1 bbnh
424 expl c 0,0 1 bnnh
425 expl c 0,0 1 yygh
426 expl c 0,0 1 yuuh
427 desi * ?ne=- +
428 expl c 2,0 1 nnjjh
429 desi * ?ne=- +
430 expl c 2,0 1 nnjjjh
431 desi * ?ne=- +
432 mov u 0,0 75 jh
433 demob 0:2,0 55 y
434 desi 2,0 m
435 mov c 0,0 600 -1,-1
436 desi -1,-1 g
437 mov c 0,0 275 1,-1
438 mov c 2,0 274 1,-1
439 desi 1,-1 m
440 deliver i 2,0 230 u
441 deliver i 1,-1 0 j
442 dist 4,0 2,0
443 thres i 2,0 1
444 des 0,-2 c
445 capital 0,-2
446 des 0,0 g
447 thres d 0,0 1
448 EOF
449
450         echo "Run an update"
451         runfeed POGO peter << EOF
452 power new
453 cen * ?own#0
454 comm * ?own#0
455 reso * ?own#0
456 force
457 EOF
458         echo "Done (force)."
459         echo ""
460
461         sleep 10
462         echo "Check player 1"
463         runfeed 1 << EOF
464 real 0 -8:12,-4:4
465 cen *
466 map #
467 read y
468 EOF
469         echo "Done (check)."
470         echo ""
471
472         echo "Check whether the update did anything"
473         runfeed POGO peter << EOF
474 power new
475 cen * ?own#0
476 comm * ?own#0
477 reso * ?own#0
478 read
479 y
480 EOF
481         echo "Done (check update)."
482         echo ""
483
484         echo "Continue some updates for player 1"
485         echo ""
486
487         echo "Turn 2 for player 1"
488
489         runfeed 1 << EOF >/dev/null 2>&1
490 desi -1,-1 b
491 mov i 2,0 200 4,0
492 mov i 1,-1 4 jh
493 mov c -1,-1 300 4,0
494 mov c -1,-1 300 3,-1
495 mov c 1,-1 175 3,-1
496 deli i 2,0 0 j
497 deli i 1,-1 0 j
498 mov c 2,0 230 5,-1
499 desi 4,0 k
500 desi 3,-1 j
501 dist # 5,-1
502 thre h 4,0 1
503 thre l 3,-1 1
504 desi 5,-1 h
505 EOF
506
507         echo "Run an update"
508         runfeed POGO peter << EOF
509 power new
510 cen * ?own#0
511 comm * ?own#0
512 reso * ?own#0
513 force
514 EOF
515         echo "Done (force)."
516         echo ""
517         sleep 10
518
519         echo "Turn 3 for player 1"
520         runfeed 1 << EOF
521 cen *
522 map #
523 read y
524 build sh 5,-1 frg
525 mov l 5,-1 102 6,-2
526 mov c 4,0 255 6,-2
527 desi 6,-2 l
528 thre l 6,-2 150
529 mov c 2,0 370 -2,2
530 deliver i 2,0 0 j
531 deliver i 1,-1 0 j
532 thres d 1,1 1
533 thres o -2,2 1
534 thres i 2,0 0
535 thres i 1,-1 0
536 desi -2,2 o
537 desi 1,1 g
538 thres c -1:5,-1 768
539 thres c -2:4,0 768
540 thres c 6,-2 250
541 thres c 4,-2 300
542 thres l 4,-2 100
543 thres o 4,-2 50
544 thres d 4,-2 10
545 thres d -1,-1 50
546 thres c 1,1 768
547 prod *
548 EOF
549         echo "Turn 3 for player 8"
550         runfeed 8 << EOF
551 cen *
552 map #
553 read y
554 exp c 0,0 50 gyyygh
555 des -7,-3 )
556 lost *
557 EOF
558
559         echo "Run an update"
560         runfeed POGO peter << EOF
561 power new
562 report *
563 cen * ?own#0
564 comm * ?own#0
565 reso * ?own#0
566 force
567 EOF
568         echo "Done (force)."
569         echo ""
570         sleep 10
571
572         echo "Turn 4 for player 1"
573         runfeed 1 << EOF
574 cen *
575 ship *
576 map #
577 read y
578 des 4,-2 t
579 enlist 3,-1 50
580 mov m 3,-1 50 5,-1
581 load m 0 50
582 nav 0
583 j
584 j
585 h
586 assault 11,-1 0
587 25
588 prod *
589 EOF
590         echo "Turn 4 for player 8"
591         runfeed 8 << EOF
592 cen *
593 map #
594 read y
595 lost *
596 EOF
597         echo "Run an update"
598         runfeed POGO peter << EOF
599 power new
600 report *
601 cen * ?own#0
602 comm * ?own#0
603 reso * ?own#0
604 force
605 EOF
606         echo "Done (force)."
607         echo ""
608         sleep 10
609
610         echo "Turn 5 for player 1"
611         runfeed 1 << EOF
612 real 0 -8:16,-4:4
613 cen *
614 ship *
615 map #
616 read y
617 prod *
618 EOF
619         echo "Run an update"
620         runfeed POGO peter << EOF
621 power new
622 report *
623 cen * ?own#0
624 comm * ?own#0
625 reso * ?own#0
626 force
627 EOF
628
629         echo "Done (force)."
630         echo ""
631         sleep 10
632
633         echo "Turn 6 for player 1"
634         runfeed 1 << EOF
635 real 1 -16:24,-8:8
636 convert 11,-1 76
637 thres c -2,2 769
638 mov c -2,2 47 0,2
639 des 0:2,2 g
640 thres d 0:2,2 1
641 thres c 0:2,2 769
642 des 3,1 g
643 thres d 3,1 1
644 thres c 3,1 769
645 des 0,0 m
646 deliver i 0,0 0 g
647 thres d -1,-1 75
648 thres d 0,0 0
649 mov d 0,0 1 -1,-1
650 thres c 0,-2 100
651 thres c 4:6,-2 210
652 thres c -1,-1 100
653 thres i 4,0 999
654 thres i 3,-1 999
655 des -2,0 j
656 thres c -2,0 769
657 thres l -2,0 1
658 bmap #1
659 nav 0 njnh
660 look 0
661 radar 0
662 radar 11,-1
663 cen *
664 ship *
665 map #
666 read y
667 prod *
668 EOF
669         echo "Turn 6 for player 8"
670         runfeed 8 << EOF
671 exp c 0,0 1 gh
672 exp c 0,0 1 yh
673 exp c 0,0 1 ygh
674 exp c 0,0 1 yyh
675 exp c 0,0 1 yyyh
676 exp c 0,0 1 yyyyh
677 exp c 0,0 1 yygh
678 exp c 0,0 1 yygyh
679 exp c 0,0 1 yygyyh
680 exp c 0,0 1 bh
681 exp c 0,0 1 bgh
682 exp c 0,0 1 nh
683 exp c 0,0 1 njh
684 exp c 0,0 1 yuh
685 exp c 0,0 1 yuyh
686 exp c 0,0 1 yuuh
687 exp c 0,0 1 yuuyh
688 exp c 2,0 1 jh
689 exp c 2,0 1 jjh
690 exp c 2,0 1 jjjh
691 exp c 2,0 1 uh
692 exp c 2,0 1 ujh
693 exp c 2,0 1 ujjh
694 exp c 2,0 1 uyh
695 exp c 2,0 1 uuh
696 exp c 2,0 1 uujh
697 cen *
698 map #
699 read y
700 prod *
701 EOF
702         echo "Run an update"
703         runfeed POGO peter << EOF
704 power new
705 report *
706 cen * ?own#0
707 comm * ?own#0
708 reso * ?own#0
709 force
710 EOF
711
712         echo "Done (force)."
713         echo ""
714         sleep 10
715
716         echo "Turn 7 for player 1"
717         runfeed 1 << EOF
718 build bridge 5,-1 j
719 explore c 5,-1 1 jh
720 mov c 5,-1 76 7,-1
721 thres c 7,-1 77
722 dist * 5,-1
723 des 1,1 m
724 deliver i 1,1 0 g
725 thres d 1,1 0
726 mov d 1,1 1 -1,-1
727 des -1,1 k
728 thres h -1,1 1
729 thres c -1,1 769
730 des -4:-2,-2 o
731 thres o -4:-2,-2 1
732 thres c -4:-2,-2 769
733 des 1,-3 o
734 thres o 1,-3 1
735 thres c 1,-3 769
736 des 4:8,2 g
737 thres d 4:8,2 1
738 thres c 4:8,2 769
739 thres c * ?c_dist=768 769
740 bmap #1
741 radar 11,-1
742 cen *
743 ship *
744 map #
745 read y
746 prod *
747 EOF
748         echo "Turn 7 for player 8"
749         runfeed 8 << EOF
750 des 7,-1 c
751 capital 7,-1
752 des * ?gold>1 g
753 thres d * ?newdes=g 1
754 thres d * ?des=g 1
755 thres d 4,0 0
756 thres d 1,-1 1
757 des -5,-3 o
758 thres o -5,-3 1
759 des -6,-4 o
760 thres o -6,-4 1
761 des 1,-1 m
762 thres i 1,-1 1
763 des 3,1 w
764 dist * 3,1
765 thres c 0:2,0 769
766 thres c 1,-1 769
767 thres c 4,0 350
768 thres c 3,-1 769
769 mov c 2,0 231 jh
770 mov c 0,0 231 jjh
771 mov c 1,-1 231 jh
772 bmap #
773 cen *
774 map #
775 read y
776 prod *
777 EOF
778         echo "Run an update"
779         runfeed POGO peter << EOF
780 power new
781 report *
782 cen * ?own#0
783 comm * ?own#0
784 reso * ?own#0
785 force
786 EOF
787
788         echo "Done (force)."
789         echo ""
790         sleep 10
791
792         echo "Turn 8 for player 1"
793         runfeed 1 << EOF
794 des 0,2 m
795 deliver i 0,2 0 j
796 thres d 0,2 0
797 mov d 0,2 1 -1,-1
798 des 3,1 m
799 deliver i 3,1 0 j
800 thres d 3,1 0
801 mov d 3,1 1 -1,-1
802 des 2,2 k
803 thres h 2,2 1
804 thres d 2,2 0
805 mov d 2,2 1 -1,-1
806 thres d 4,-2 15
807 thres o 4,-2 75
808 thres l 4,-2 150
809 des 5:7,1 g
810 thres d 5:7,1 1
811 thres c 5:7,1 769
812 des 10,2 g
813 thres d 10,2 1
814 thres c 10,2 769
815 radar 11,-1
816 bmap #1
817 cen *
818 ship *
819 map #
820 read y
821 prod *
822 EOF
823         echo "Turn 8 for player 8"
824         runfeed 8 << EOF
825 thres c -3:-1,-1 769
826 des 0:2,0 m
827 thres i 0:2,0 1
828 bmap #
829 cen *
830 map #
831 read y
832 prod *
833 EOF
834
835         echo "Run an update"
836         runfeed POGO peter << EOF
837 power new
838 report *
839 cen * ?own#0
840 comm * ?own#0
841 reso * ?own#0
842 force
843 EOF
844
845         echo "Done (force)."
846         echo ""
847         sleep 10
848
849         echo "Turn 9 for player 1"
850         runfeed 1 << EOF
851 mov u 2,0 10 7,-1
852 des -2,2 i
853 thres l -2,2 600
854 thres h -2,2 300
855 thres s -2,2 1
856 thres o -2,2 0
857 mov o -2,2 1 4,-2
858 thres c * ?des#= 769
859 bmap #1
860 cen *
861 ship *
862 map #
863 read y
864 prod *
865 EOF
866         echo "Turn 9 for player 8"
867         runfeed 8 << EOF
868 thres d 1,-1 0
869 mov d 1,-1 1 4,0
870 des 3,-1 m
871 thres i 3,-1 1
872 thres d 3,-1 0
873 mov d 3,-1 1 4,0
874 thres c -6,-4 769
875 thres c 6,-2 769
876 thres c 1,-3 769
877 des 4,0 b
878 thres d 4,0 100
879 thres d 0:2,0 0
880 mov d 0,0 1 4,0
881 mov d 2,0 1 4,0
882 bmap #
883 cen *
884 map #
885 read y
886 prod *
887 EOF
888
889         echo "Run an update"
890         runfeed POGO peter << EOF
891 power new
892 report *
893 cen * ?own#0
894 comm * ?own#0
895 reso * ?own#0
896 force
897 EOF
898
899         echo "Done (force)."
900         echo ""
901         sleep 10
902
903         echo "Turn 10 for player 1"
904         runfeed 1 << EOF
905 mov h 5,-1 100 7,-1
906 build bridge 7,-1 j
907 explore c 7,-1 1 jh
908 thres c 9,-1 77
909 mov u 7,-1 12 4,0
910 thres u 2,0 579
911 thres u 4,0 869
912 thres u 11,-1 1
913 thres l 6,-2 250
914 des 7,1 d
915 thres l 7,1 200
916 thres h 7,1 100
917 thres o 7,1 20
918 thres g 7,1 1
919 thres d 7,1 0
920 mov d 7,1 1 -1,-1
921 des 5,1 j
922 thres l 5,1 1
923 thres d 5,1 0
924 mov d 5,1 1 -1,-1
925 des 4,2 r
926 thres l 4,2 100
927 thres o 4,2 50
928 thres d 4,2 10
929 des 6,2 w
930 thres d 6,2 0
931 mov d 6,2 1 -1,-1
932 des 8,2 e
933 thres d 8,2 0
934 mov d 8,2 1 -1,-1
935 thres m 8,2 1
936 des 10,2 !
937 thres l 10,2 200
938 thres h 10,2 200
939 thres s 10,2 200
940 thres g 10,2 25
941 thres d 10,2 0
942 mov d 10,2 1 -1,-1
943 des 5,3 p
944 thres l 5,3 75
945 dist #1 5,-1
946 spy 11,-1
947 bmap #1
948 cen *
949 ship *
950 map #
951 read y
952 prod *
953 EOF
954         echo "Turn 10 for player 8"
955         runfeed 8 << EOF
956 des -3,-1 j
957 thres i -3,-1 999
958 thres l -3,-1 1
959 thres c 6,0 769
960 thres d -3,-1 0
961 mov d -3,-1 1 4,0
962 bmap #
963 cen *
964 map #
965 read y
966 prod *
967 EOF
968         echo "Run an update"
969         runfeed POGO peter << EOF
970 power new
971 report *
972 cen * ?own#0
973 comm * ?own#0
974 reso * ?own#0
975 force
976 EOF
977
978         echo "Done (force)."
979         echo ""
980         sleep 10
981
982         echo "Turn 11 for player 1"
983         runfeed 1 << EOF
984 thres l 6,-2 300
985 thres l 5,-1 200
986 thres h 5,-1 200
987 thres i 5,-1 1
988 thres o 5,-1 1
989 thres d 5,-1 1
990 dist #1 6,2
991 bmap #1
992 cen *
993 ship *
994 map #
995 read y
996 prod *
997 EOF
998         echo "Turn 11 for player 8"
999         runfeed 8 << EOF
1000 des -1,-1 m
1001 thres i -1,-1 1
1002 thres d -1,-1 0
1003 mov d -1,-1 1 4,0
1004 bmap #
1005 cen *
1006 map #
1007 read y
1008 prod *
1009 EOF
1010
1011         echo "Done (Rudimentary tests)."
1012         echo ""
1013
1014                         ;;
1015         esac
1016         #
1017         # END TESTSCRIPT
1018         #
1019
1020         #
1021         # START SERVERSTOP
1022         #
1023         case "${NIGHTLY_SKIP_STEP}"
1024         in
1025                 *SERVERSTOP*) ;;
1026                 *)
1027                         case "${NIGHTLY_SKIP_STEP}"
1028                         in
1029                                 *SERVERSTART*) ;;
1030                                 *)
1031
1032         echo "Stopping server"
1033         trykill "${PID}"
1034         echo "Done (kill)."
1035 cd "${BOXDIR}/${WORKDIR}/emp4/var/empire" || err "Could not cd to ${BOXDIR}/${WORKDIR}/emp4/var/empire"
1036         echo "-- Start Server Log --"
1037         cat server.log
1038         echo "-- End of Server Log --"
1039         echo "-- Start Journal Log --"
1040         cat journal.log
1041         echo "-- End of Journal Log --"
1042         echo "Server stopped"
1043                                         ;;
1044                         esac
1045                         ;;
1046         esac
1047         #
1048         # END SERVERSTOP
1049         #
1050 done
1051
1052 #
1053 # START CLEANUP
1054 #
1055 case "${NIGHTLY_SKIP_STEP}"
1056 in
1057         *CLEANUP*) ;;
1058         *)
1059
1060 echo "Cleaning sandbox"
1061 cd "${BOXDIR}" || err "Could not cd back to sandbox root !"
1062 case "${NIGHTLY_SKIP_STEP}"
1063 in
1064         *REMOVE_REPOSITORY*)
1065 rm -rf `find "${WORKDIR}" -maxdepth 1 ! -name .git` || warn "Directory ${WORKDIR} could not be forcibly removed !"
1066                 ;;
1067         *)
1068 rm -r "${WORKDIR}" || warn "Directory ${WORKDIR} could not be cleanly removed !"
1069 rm -rf "${WORKDIR}" || warn "Directory ${WORKDIR} could not be forcibly removed !"
1070 [ -d "${WORKDIR}/." ] && warn "Directory ${WORKDIR} still present"
1071 echo "Done (cleaning)."
1072                 ;;
1073 esac
1074                 ;;
1075 esac
1076 #
1077 # END CLEANUP
1078 #
1079
1080 echo "Nightly build finished at `date`"
1081
1082 exit 0