games/tetrinetx: Added (TetriNET server)

Signed-off-by: bedlam <dave@slackbuilds.org>

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
B. Watson 2023-02-13 20:21:28 +00:00 committed by Willy Sudiarto Raharjo
parent 998d466e2f
commit 1edb88fa29
No known key found for this signature in database
GPG key ID: 3F617144D7238786
9 changed files with 538 additions and 0 deletions

24
games/tetrinetx/README Normal file
View file

@ -0,0 +1,24 @@
tetrinetx (TetriNET server)
tetrinetx provides a server for hosting TetriNet games. TetriNet
is a multiplayer variant of Tetris played over the Internet. Up to
six people may simultaneously connect to a server to participate in
a game.
tetrinetx supports only the original game mode, *not* TetriFAST mode.
Clients attempting to connect in TetriFAST mode will be immediately
disconnected.
If you want to start the tetrinetx service at boot, add code like
this to your /etc/rc.d/rc.local:
if [ -x /etc/rc.d/rc.tetrinetx ]; then
/etc/rc.d/rc.tetrinetx start
fi
The daemon runs as the 'games' user. See the tetrinetx(6) man page for
details.
IPv6 support is a compile-time choice. It's not possible to include
both IPv6 and IPv4 support. The default is IPv6. To build with IPv4
support instead, run the script with IPV4=yes in the environment.

26
games/tetrinetx/doinst.sh Normal file
View file

@ -0,0 +1,26 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
rm $NEW
fi
}
preserve_perms() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ -e $OLD ]; then
cp -a $OLD ${NEW}.incoming
cat $NEW > ${NEW}.incoming
mv ${NEW}.incoming $NEW
fi
config $NEW
}
preserve_perms etc/rc.d/rc.tetrinetx.new
config etc/tetrinetx/game.conf.new
config etc/tetrinetx/game.motd.new
config etc/tetrinetx/game.pmotd.new
config etc/tetrinetx/game.secure.new

View file

@ -0,0 +1,19 @@
#!/bin/sh
# 20230211 bkw: Very dumb/simple rc script for tetrinetx, part
# of the SBo build.
case "$1" in
'start'|'')
su - games -s /bin/sh -c /usr/games/tetrinetx
;;
'stop')
killall tetrinetx
;;
'restart')
$0 stop
sleep 1
exec $0 start
;;
*) echo "usage: $0 start|stop|restart" ; exit 1 ;;
esac

View file

@ -0,0 +1,16 @@
diff -Naur tetrinetx-1.13.16+qirc-1.40c.debpatched/src/net.c tetrinetx-1.13.16+qirc-1.40c/src/net.c
--- tetrinetx-1.13.16+qirc-1.40c.debpatched/src/net.c 2023-02-12 22:55:25.362581596 -0500
+++ tetrinetx-1.13.16+qirc-1.40c/src/net.c 2023-02-12 22:57:05.941572131 -0500
@@ -370,6 +370,12 @@
int answer(sock,ip,binary)
int sock; unsigned long *ip; int binary;
{
+ int new_sock,addrlen; struct sockaddr_in from;
+ addrlen=sizeof(struct sockaddr);
+ new_sock=accept(sock,(struct sockaddr *)&from,&addrlen);
+ if (new_sock<0) return -1;
+ *ip=from.sin_addr.s_addr;
+ *ip=ntohl(*ip);
/* set up all the normal socket crap */
// setsock(new_sock,(binary ? SOCK_BINARY : 0));
return new_sock;

View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
tetrinetx: tetrinetx (TetriNET server)
tetrinetx:
tetrinetx: tetrinetx provides a server for hosting TetriNet games. TetriNet
tetrinetx: is a multiplayer variant of Tetris played over the Internet. Up to
tetrinetx: six people may simultaneously connect to a server to participate in
tetrinetx: a game.
tetrinetx:
tetrinetx: tetrinetx does NOT support the TetriFAST game mode.
tetrinetx:
tetrinetx: This package was built with IPv@IPVER@ support only.
tetrinetx:

159
games/tetrinetx/tetrinetx.6 Normal file
View file

@ -0,0 +1,159 @@
.\" Man page generated from reStructuredText.
.
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.TH "TETRINETX" 6 "2023-02-13" "1.13.16+qirc_1.40c_15" "SlackBuilds.org"
.SH NAME
tetrinetx \- server for tetrinet game
.\" RST source for tetrinetx(6) man page. Convert with:
.
.\" rst2man.py tetrinetx.rst > tetrinetx.6
.
.SH SYNOPSIS
.sp
/etc/rc.d/rc.tetrinetx [ \fBstart\fP | \fBstop\fP | \fBrestart\fP ]
.SH DESCRIPTION
.sp
\fBtetrinetx\fP provides a server for hosting TetriNET games. TetriNET
is a multiplayer variant of Tetris played over the internet. Up to
six people may simultaneously connect to a server to participate in
a game.
.sp
\fBtetrinetx\fP supports only the original TetriNET game mode, not the
TetriFAST mode. Clients attempting to connect with TetriFAST will be
immediately disconnected.
.sp
The actual \fBtetrinetx\fP binary should not normally be run
directly. Instead, use the startup script. If you want to start the
server at boot, include a call to it in your \fI/etc/rc.d/rc.local\fP:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
if [ \-x /etc/rc.d/rc.tetrinetx ]; then
/etc/rc.d/rc.tetrinetx start
fi
.ft P
.fi
.UNINDENT
.UNINDENT
.sp
\&...and possibly in \fI/etc/rc.d/rc.local_shutdown\fP:
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
if [ \-x /etc/rc.d/rc.tetrinetx ]; then
/etc/rc.d/rc.tetrinetx stop
fi
.ft P
.fi
.UNINDENT
.UNINDENT
.SH FILES
.sp
All configuration is done via config files; there are no command\-line
options (other than start/stop/restart, for the init script).
.INDENT 0.0
.TP
.B /etc/tetrinetx/game.conf
The main config file for \fBtetrinetx\fP\&. Human\-readable and editable,
with explanatory comments.
.TP
.B /etc/tetrinetx/game.motd
The "message of the day" shown to regular clients when they connect.
.TP
.B /etc/tetrinetx/game.pmotd
Message shown to playback (spectator) service clients.
.TP
.B /etc/tetrinetx/game.secure
Used to define passwords clients can send to authenticate as server
admins. By default, nothing is defined here (everything is commented out).
.TP
.B /etc/tetrinetx/game.ban, game.allow, game.ban.compromise
Controls who is allowed to connect to the server. These files don\(aqt
ship with the package, but ".example" files are included to show you
how they work.
.TP
.B /var/log/tetrinetx/game.log
Log file for \fBtetrinetx\fP\&.
.TP
.B /var/games/tetrinetx/game.winlist, game.winlist2, game.winlist3
Lists of game winners.
.TP
.B /var/run/tetrinetx/game.pid
PID file for the daemon is normally stored here, although this can be
changed in \fBgame.conf\fP\&. The PID file is deleted when \fBtetrinetx\fP
exits normally (including being killed with \fBSIGTERM\fP).
The init script doesn\(aqt actually use the PID file.
.UNINDENT
.SH NETWORK
.sp
\fBtetrinetx\fP uses the following TCP ports:
.INDENT 0.0
.TP
.B 31457
Standard port used for tetrinet clients.
.TP
.B 31456
Query service. Supposedly can be connected to with a standard IRC client.
See:
.INDENT 7.0
.INDENT 3.5
/usr/doc/tetrinetx\-1.13.16+qirc_1.40c_15/README.qirc.spectators
.UNINDENT
.UNINDENT
.TP
.B 31458
"Playback" port, used for connecting as a spectator. \fBtetrinetx\fP must
have a \fIquery_password\fP set in \fB/etc/tetrinetx/game.secure\fP to enable
spectator connections.
.UNINDENT
.SH LIMITATIONS
.sp
\fBtetrinetx\fP can only be compiled for \fIeither\fP IPv4 \fIor\fP IPv6
support, not both. The SlackBuilds.org build allows choosing this at
build time.
.SH COPYRIGHT
.sp
See the file /usr/doc/tetrinetx\-1.13.16+qirc_1.40c_15/COPYING for license information.
.SH AUTHORS
.sp
\fBtetrinetx\fP was written by Brendan Grieve and Roongroj Phoophuangpairoj.
.sp
This man page written for the SlackBuilds.org project
by B. Watson, and is licensed under the WTFPL.
.SH SEE ALSO
.sp
\fBgtetrinet\fP(6)
.sp
The tetrinetx homepage: \fI\%https://tetrinetx.sourceforge.net/\fP
.\" Generated by docutils manpage writer.
.

View file

@ -0,0 +1,131 @@
#!/bin/bash
# Slackware build script for tetrinetx
# Written by B. Watson (urchlay@slackware.uk)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# The _15 in VERSION is the Debian patchlevel. They're currently
# the only ones maintaining this at all.
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=tetrinetx
VERSION=${VERSION:-1.13.16+qirc_1.40c_15}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
SRCVER="$( echo $VERSION | cut -d_ -f1-2 | tr _ - )"
DEBVER="$( echo $VERSION | cut -d_ -f3 )"
DEBSRCVER="$( echo $VERSION | cut -d+ -f1 )"
# We get two possible filenames for the tarball depending on what
# exactly was used to download it.
TARBALL="$CWD/$PRGNAM-$SRCVER.tar.gz"
if [ ! -e "$TARBALL" ]; then
TARBALL="$( echo "$TARBALL" | sed 's,+,%2B,g' )"
fi
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$SRCVER
tar xvf $TARBALL
cd $PRGNAM-$SRCVER
tar xvf $CWD/${PRGNAM}_${DEBSRCVER}-${DEBVER}.debian.tar.xz
chown -R root:root .
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
# Incorporate all of Debian's changes. This includes IPv6 support,
# and putting the config files in /etc/$PRGNAM and log file in /var.
patch -p1 < debian/patches/debian-changes
# Debian's patch breaks IPv4 support, fix.
patch -p1 < $CWD/restore_ipv4.diff
if [ "${IPV4:-no}" = "yes" ]; then
IPVER=4
else
SLKCFLAGS+=" -DUSE_IPV6"
IPVER=6
fi
PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
# Easier to just do this, than to munge the compile script into doing
# the right thing.
${CC:-gcc} $SLKCFLAGS -o $PRGNAM src/main.c -ladns
mkdir -p $PKG/usr/games $PKG/usr/man/man6 $PKG/etc/$PRGNAM $PKGDOC
install -s -m0755 $PRGNAM $PKG/usr/games
for i in bin/game*.{conf,secure,{p,}motd}; do
cp -a $i $PKG/etc/$PRGNAM/$( basename $i ).new
done
cp -a bin/game.*.example $PKG/etc/$PRGNAM
# The Debian man page is useless, I wrote a better one.
gzip -9c < $CWD/$PRGNAM.6 > $PKG/usr/man/man6/$PRGNAM.6.gz
# Log rotation looks broken: it doesn't restart the daemon after
# rotating the log. tetrinetx doesn't allow a SIGHUP to reopen the
# log, meaning we'd have to call the rc script to restart it. And if
# we do, we kill any games in progress. There's nothing like apache's
# "graceful" restart. Leave it out, and let the user deal with it (or
# not; it would take a long time for the log to fill a modern drive).
#mkdir -p $PKG/etc/logrotate.d
#cp -a debian/logrotate $PKG/etc/logrotate.d/$PRGNAM
# Bare-bones init script written by SlackBuild author.
mkdir -p $PKG/etc/rc.d
install -m0755 -oroot -groot $CWD/rc.$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new
# These dirs have to be writable by the user the daemon runs as.
dirs="$PKG/var/games/$PRGNAM $PKG/var/log/$PRGNAM $PKG/var/run/$PRGNAM"
mkdir -p $dirs
chown games:games $dirs
mkdir -p $PKGDOC
cp -a AUTHORS COPYING ChangeLog README* $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild
mkdir -p $PKG/install
sed "s,@IPVER@,$IPVER," < $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE

View file

@ -0,0 +1,12 @@
PRGNAM="tetrinetx"
VERSION="1.13.16+qirc_1.40c_15"
HOMEPAGE="http://tetrinetx.sourceforge.net/"
DOWNLOAD="https://downloads.sourceforge.net/project/tetrinetx/tetrinetx/1.40c/tetrinetx-1.13.16+qirc-1.40c.tar.gz \
https://deb.debian.org/debian/pool/main/t/tetrinetx/tetrinetx_1.13.16-15.debian.tar.xz"
MD5SUM="32e5306bc26afc9e5acdca9c093947c0 \
7bae8054066d31625944674c4589b530"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES="adns"
MAINTAINER="B. Watson"
EMAIL="urchlay@slackware.uk"

View file

@ -0,0 +1,132 @@
.. RST source for tetrinetx(6) man page. Convert with:
.. rst2man.py tetrinetx.rst > tetrinetx.6
.. |version| replace:: 1.13.16+qirc_1.40c_15
.. |date| date::
=========
tetrinetx
=========
------------------------
server for tetrinet game
------------------------
:Manual section: 6
:Manual group: SlackBuilds.org
:Date: |date|
:Version: |version|
SYNOPSIS
========
/etc/rc.d/rc.tetrinetx [ **start** | **stop** | **restart** ]
DESCRIPTION
===========
**tetrinetx** provides a server for hosting TetriNET games. TetriNET
is a multiplayer variant of Tetris played over the internet. Up to
six people may simultaneously connect to a server to participate in
a game.
**tetrinetx** supports only the original TetriNET game mode, not the
TetriFAST mode. Clients attempting to connect with TetriFAST will be
immediately disconnected.
The actual **tetrinetx** binary should not normally be run
directly. Instead, use the startup script. If you want to start the
server at boot, include a call to it in your */etc/rc.d/rc.local*::
if [ -x /etc/rc.d/rc.tetrinetx ]; then
/etc/rc.d/rc.tetrinetx start
fi
...and possibly in */etc/rc.d/rc.local_shutdown*::
if [ -x /etc/rc.d/rc.tetrinetx ]; then
/etc/rc.d/rc.tetrinetx stop
fi
FILES
=====
All configuration is done via config files; there are no command-line
options (other than start/stop/restart, for the init script).
/etc/tetrinetx/game.conf
The main config file for **tetrinetx**. Human-readable and editable,
with explanatory comments.
/etc/tetrinetx/game.motd
The "message of the day" shown to regular clients when they connect.
/etc/tetrinetx/game.pmotd
Message shown to playback (spectator) service clients.
/etc/tetrinetx/game.secure
Used to define passwords clients can send to authenticate as server
admins. By default, nothing is defined here (everything is commented out).
/etc/tetrinetx/game.ban, game.allow, game.ban.compromise
Controls who is allowed to connect to the server. These files don't
ship with the package, but ".example" files are included to show you
how they work.
/var/log/tetrinetx/game.log
Log file for **tetrinetx**.
/var/games/tetrinetx/game.winlist, game.winlist2, game.winlist3
Lists of game winners.
/var/run/tetrinetx/game.pid
PID file for the daemon is normally stored here, although this can be
changed in **game.conf**. The PID file is deleted when **tetrinetx**
exits normally (including being killed with **SIGTERM**).
The init script doesn't actually use the PID file.
NETWORK
=======
**tetrinetx** uses the following TCP ports:
31457
Standard port used for tetrinet clients.
31456
Query service. Supposedly can be connected to with a standard IRC client.
See:
/usr/doc/tetrinetx-|version|/README.qirc.spectators
31458
"Playback" port, used for connecting as a spectator. **tetrinetx** must
have a *query_password* set in **/etc/tetrinetx/game.secure** to enable
spectator connections.
LIMITATIONS
===========
**tetrinetx** can only be compiled for *either* IPv4 *or* IPv6
support, not both. The SlackBuilds.org build allows choosing this at
build time.
COPYRIGHT
=========
See the file /usr/doc/tetrinetx-|version|/COPYING for license information.
AUTHORS
=======
**tetrinetx** was written by Brendan Grieve and Roongroj Phoophuangpairoj.
This man page written for the SlackBuilds.org project
by B. Watson, and is licensed under the WTFPL.
SEE ALSO
========
**gtetrinet**\(6)
The tetrinetx homepage: https://tetrinetx.sourceforge.net/