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