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