comparison bin/makemotd @ 1:4d6502ffaa5e

Initial revision
author darius
date Sat, 06 Dec 1997 04:36:59 +0000
parents
children
comparison
equal deleted inserted replaced
0:52b8d91ecc32 1:4d6502ffaa5e
1 #!/bin/sh
2 #
3 # generates a motd with highscores
4 #
5 # first argument is the old playerfile, if a second argument exists it is
6 # assumed to be NETREKDIR.
7 #
8 # NOTE: the Old playerfile is assumed to be a gzipped file! This is because
9 # the dbbackup script gzips it.
10 #
11
12 if [ $# -eq 0 ]; then
13 echo "Syntax: '$0 <old player file> [NETREKDIR]'"
14 exit 1
15 else
16 OLDPLAYERS=$1
17 fi
18
19 if [ X$2 != X ]; then
20 NETREKDIR=$2
21 elif [ X${NETREKDIR} = X ]; then
22 if [ -f "../etc/conf.netrekdir" ]; then
23 NETREKDIR=`cat "../etc/conf.netrekdir"`
24 else
25 echo "No NETREKDIR variable found, exiting."
26 exit 1
27 fi
28 fi
29
30 if [ ! -f ${NETREKDIR}/bin/hs ]; then
31 echo "$0: Highscores program not found, exiting."
32 echo "$0: (expecting: ${NETREKDIR}/bin/hs)"
33 exit 1
34 fi
35
36 if [ ! -f ${NETREKDIR}/bin/hr ]; then
37 echo "$0: Honorroll program not found, exiting."
38 echo "$0: (expecting: ${NETREKDIR}/bin/hr)"
39 exit 1
40 fi
41
42 if [ ! -f ${NETREKDIR}/${OLDPLAYERS} ]; then
43 echo "$0: Old player db not found, exiting."
44 echo "$0: (expecting: ${NETREKDIR}/${OLDPLAYERS})"
45 exit 1
46 else
47 echo -n "$0: Unzipping ${NETREKDIR}/${OLDPLAYERS}..."
48 gzip -d ${NETREKDIR}/${OLDPLAYERS}
49 echo "Done."
50 fi
51
52 if [ ! -f ${NETREKDIR}/etc/motd.body ]; then
53 echo "$0: \"motd.body\" file not found, exiting."
54 echo "$0: (expecting: ${NETREKDIR}/etc/motd.body)"
55 exit 1
56 fi
57
58 exit
59
60 cat ${NETREKDIR}/etc/motd.body > ${NETREKDIR}/etc/motd
61 echo "Scores last updated: `date`" >> motd
62 ${NETREKDIR}/bin/hs -n 35 -c 0 ${NETREKDIR}/${OLDPLAYERS} ${NETREKDIR}/etc/db.players >> ${NETREKDIR}/etc/motd
63 ${NETREKDIR}/bin/hr 120 -m -f ${NETREKDIR}/etc/db.players >> ${NETREKDIR/etc/motd
64
65 echo -n "$0: gzipping ${NETREKDIR}/${OLDPLAYERS}..."
66 gzip -9 ${NETREKDIR}/${OLDPLAYERS}
67 echo "Done."