--- tetrinetx-1.13.16.orig/src/main.h +++ tetrinetx-1.13.16/src/main.h @@ -47,7 +47,11 @@ /* Defines */ #define TETVERSION "1.13" /* What Tetrinet version we are for */ -#define SERVERBUILD "16+qirc-1.40b" /* What build we are at */ +#ifdef USE_IPV6 +#define SERVERBUILD "16+qirc-1.40c-IPv6" /* What build we are at */ +#else +#define SERVERBUILD "16+qirc-1.40c" /* What build we are at */ +#endif #define NICKLEN 30 /* Maximum length of Nickname */ #define VERLEN 10 /* Maximum length of Tetrinet version */ #define UHOSTLEN 121 /* Maximum length of Hostname */ @@ -240,7 +244,11 @@ struct net_t { int sock; /* Socket this player is on */ +#ifdef USE_IPV6 + struct in6_addr addr; +#else IP addr; /* IP address of player */ +#endif unsigned int port; /* Port number they connected to */ char nick[NICKLEN+1]; /* Nickname of player */ char team[TEAMLEN+1]; /* Teamname of player */ --- tetrinetx-1.13.16.orig/src/net.h +++ tetrinetx-1.13.16/src/net.h @@ -37,6 +37,9 @@ #define SOCK_NONSOCK 0x10 /* used for file i/o on debug */ #define SOCK_STRONGCONN 0x20 /* don't report success until sure */ +/* some hard-coded values are better with #define :) */ +#define MAXHOSTNAMELEN 80 + /* this is used by the net module to keep track of sockets and what's queued on them */ struct sock_list { @@ -51,15 +54,10 @@ /*#define MAXSOCKS MAXNET*2*/ struct sock_list *socklist; /* enough to be safe */ -/* i read somewhere that memcpy() is broken on some machines */ -/* it's easy to replace, so i'm not gonna take any chances, because it's -*/ -/* pretty important that it work correctly here */ +/* XXX: deleted, see .c for explanations. void my_memcpy(char *dest,char *src,int len); - - -/* bzero() is bsd-only, so here's one for non-bsd systems */ void my_bzero(char *dest,int len); +*/ /* initialize the socklist */ @@ -75,7 +73,11 @@ /* get my ip number */ +#ifdef USE_IPV6 +void getmyip(struct in6_addr *ip); +#else IP getmyip(void); +#endif void neterror(char *s); @@ -106,7 +108,11 @@ */ /* by open_listen ... returns hostname of the caller & the new socket */ /* does NOT dispose of old "public" socket! */ +#ifdef USE_IPV6 +int answer(int sock,struct in6_addr *ip,int binary); +#else int answer(int sock,unsigned long *ip,int binary); +#endif /* attempts to read from all the sockets in socklist */ --- tetrinetx-1.13.16.orig/src/config.h +++ tetrinetx-1.13.16/src/config.h @@ -1,22 +1,17 @@ -/* - config.h - - Definitions in here are pretty safe to modify. Generally user defined - stuff anyway ;) - -*/ +// CONFIG +#define FILE_MOTD "/etc/tetrinetx/game.motd" +#define FILE_PMOTD "/etc/tetrinetx/game.pmotd" +#define FILE_CONF "/etc/tetrinetx/game.conf" +#define FILE_BAN "/etc/tetrinetx/game.ban" +#define FILE_ALLOW "/etc/tetrinetx/game.allow" +#define FILE_SECURE "/etc/tetrinetx/game.secure" +#define FILE_BAN_COMPROMISE "/etc/tetrinetx/game.ban.compromise" -/* Location of the various external files */ -#define FILE_MOTD "game.motd" /* Message of the Day File */ -#define FILE_PMOTD "game.pmotd" /* Playback motd */ -#define FILE_CONF "game.conf" /* Game configuration File */ -#define FILE_WINLIST "game.winlist" /* Winlist storage file */ -#define FILE_WINLIST2 "game.winlist2" /* Winlist storage file */ -#define FILE_WINLIST3 "game.winlist3" /* Winlist storage file */ +// LOG & PID +#define FILE_LOG "/var/log/tetrinetx/game.log" +#define FILE_PID "/var/run/tetrinetx/game.pid" -#define FILE_BAN "game.ban" /* List of Banned IP's */ -#define FILE_BAN_COMPROMISE "game.ban.compromise" /* List of Banned IP's */ -#define FILE_ALLOW "game.allow" /* List of allow IP's */ -#define FILE_LOG "game.log" /* Logfile */ -#define FILE_PID "game.pid" /* Default PID */ -#define FILE_SECURE "game.secure" /* Security file */ +// SCORES +#define FILE_WINLIST "/var/games/tetrinetx/game.winlist" +#define FILE_WINLIST2 "/var/games/tetrinetx/game.winlist2" +#define FILE_WINLIST3 "/var/games/tetrinetx/game.winlist3" --- tetrinetx-1.13.16.orig/src/main.c +++ tetrinetx-1.13.16/src/main.c @@ -200,15 +200,23 @@ char is_explicit_banned(struct net_t *n) { /* I should use regex, but I've not used it before, and it was late. Easier to write a quick one of my own */ +#ifdef USE_IPV6 + char ip_str[INET6_ADDRSTRLEN], host[INET6_ADDRSTRLEN]; +#else char ip_str[UHOSTLEN+1], host[UHOSTLEN+1]; char n1[4], n2[4], n3[4], n4[4]; +#endif int i, j; int found; +#ifdef USE_IPV6 + inet_ntop(AF_INET6, &n->addr, (char *)ip_str, INET6_ADDRSTRLEN); +#else sprintf(n1,"%lu", (unsigned long)(n->addr&0xff000000)/(unsigned long)0x1000000); sprintf(n2,"%lu", (unsigned long)(n->addr&0x00ff0000)/(unsigned long)0x10000); sprintf(n3,"%lu", (unsigned long)(n->addr&0x0000ff00)/(unsigned long)0x100); sprintf(n4,"%lu", (unsigned long)n->addr&0x000000ff); sprintf(ip_str, "%s.%s.%s.%s", n1, n2, n3, n4); +#endif found = 0; i = 0; @@ -228,8 +236,12 @@ int is_banned(struct net_t *n) { /* I should use regex, but I've not used it before, and it was late. Easier to write a quick one of my own */ +#ifdef USE_IPV6 + char ip_str[INET6_ADDRSTRLEN], host[INET6_ADDRSTRLEN]; +#else char ip_str[UHOSTLEN+1], host[UHOSTLEN+1]; char n1[4], n2[4], n3[4], n4[4]; +#endif int i, j; int found, allow; allow = 0; @@ -247,11 +259,15 @@ return(0); +#ifdef USE_IPV6 + inet_ntop(AF_INET6, &n->addr, (char *)ip_str, INET6_ADDRSTRLEN); +#else sprintf(n1,"%lu", (unsigned long)(n->addr&0xff000000)/(unsigned long)0x1000000); sprintf(n2,"%lu", (unsigned long)(n->addr&0x00ff0000)/(unsigned long)0x10000); sprintf(n3,"%lu", (unsigned long)(n->addr&0x0000ff00)/(unsigned long)0x100); sprintf(n4,"%lu", (unsigned long)n->addr&0x000000ff); sprintf(ip_str, "%s.%s.%s.%s", n1, n2, n3, n4); +#endif found = 0; i = 0; @@ -404,7 +420,11 @@ gnet=malloc(sizeof(struct net_t)); gnet->next=NULL; n=gnet; +#ifdef USE_IPV6 + getmyip(&n->addr); +#else n->addr=getmyip(); +#endif n->type=NET_TELNET; n->channel = malloc(sizeof(struct channel_t)); n->channel->name[0] = '\0'; @@ -452,7 +472,11 @@ /* no existing entry */ n->next = malloc(sizeof(struct net_t)); n = n->next; +#ifdef USE_IPV6 + getmyip(&n->addr); +#else n->addr=getmyip(); +#endif n->type=NET_QUERY; n->next=NULL; n->channel = malloc(sizeof(struct channel_t)); @@ -496,7 +520,11 @@ /* no existing entry */ n->next = malloc(sizeof(struct net_t)); n = n->next; +#ifdef USE_IPV6 + getmyip(&n->addr); +#else n->addr=getmyip(); +#endif n->type=NET_PLAYBACK; n->next=NULL; n->channel = malloc(sizeof(struct channel_t)); @@ -2317,6 +2345,19 @@ return 1; } +#ifdef USE_IPV6 +int net_query_IPconvert(struct net_t *n, char *host) +{ + char ip_str[INET6_ADDRSTRLEN]; + + inet_ntop(AF_INET6, &n->addr, (char *)ip_str, INET6_ADDRSTRLEN); + if (n->host[0] == 0 || strlen(n->host) >= UHOSTLEN) + sprintf(host, "%s",ip_str); + else + strcpy(host, n->host); + return 1; +} +#else int net_query_IPconvert(struct net_t *n, char *host) { unsigned char x1, x2, x3, x4; @@ -2333,6 +2374,7 @@ strcpy(host, n->host); return 1; } +#endif /* Trim weird useless chars at the end */ int net_query_TrimStr(char *p) @@ -3468,8 +3510,12 @@ /* Someone has just connected. So lets answer them */ void net_query(struct net_t *n, char *buf) { +#ifdef USE_IPV6 + struct in6_addr ip; +#else IP ip; /* unsigned char x1, x2, x3, x4; */ +#endif struct net_t *net; net=malloc(sizeof(struct net_t)); @@ -3481,7 +3527,11 @@ net->sock=answer(n->sock,&ip,0); setopt(net->sock, 0); +#ifdef USE_IPV6 + memcpy(&net->addr, &ip, sizeof(ip)); +#else net->addr=ip; +#endif net->port=n->port; net->securitylevel=LEVEL_NORMAL; net->status=STAT_NOTPLAYING; @@ -3490,6 +3540,9 @@ strcpy(net->nick, "(telnet)"); do_async_dns(net); net->type = NET_WAITINGFORDNS; +#ifdef USE_IPV6 +net_donedns(net); +#endif } void net_query_donedns (struct net_t *net) { @@ -3646,8 +3699,12 @@ /* Someone has just connected. So lets answer them */ void net_playback(struct net_t *n, char *buf) { +#ifdef USE_IPV6 + struct in6_addr ip; +#else IP ip; /* unsigned char x1, x2, x3, x4; */ +#endif struct net_t *net; net=malloc(sizeof(struct net_t)); @@ -3659,7 +3716,11 @@ net->sock=answer(n->sock,&ip,0); setopt(net->sock, 0); +#ifdef USE_IPV6 + memcpy(&net->addr, &ip, sizeof(ip)); +#else net->addr=ip; +#endif net->port=n->port; net->securitylevel=LEVEL_NORMAL; net->status=STAT_NOTPLAYING; @@ -3669,6 +3730,9 @@ strcpy(net->nick, "(telnet)"); do_async_dns(net); net->type = NET_WAITINGFORDNS; +#ifdef USE_IPV6 +net_donedns(net); +#endif } void net_playback_donedns(struct net_t *net) { @@ -4348,7 +4412,11 @@ /* Someone has just connected. So lets answer them */ void net_telnet(struct net_t *n, char *buf) { +#ifdef USE_IPV6 + static struct in6_addr ip; +#else unsigned long ip; +#endif struct net_t *net; @@ -4361,7 +4429,11 @@ net->sock=answer(n->sock,&ip,0); setopt(net->sock, 0); /* Save the port stuff */ +#ifdef USE_IPV6 + memcpy(&net->addr, &ip, sizeof(ip)); +#else net->addr=ip; +#endif net->port=n->port; net->securitylevel=LEVEL_NORMAL; net->status=STAT_NOTPLAYING; @@ -4373,11 +4445,23 @@ net->timeout_ingame = 30; do_async_dns(net); net->type = NET_WAITINGFORDNS; +#ifdef USE_IPV6 +net_donedns(net); +#endif /* net has not been added to socket list */ /* EOF on this will be EOF on unknown socket */ } +#ifdef USE_IPV6 +void do_async_dns (struct net_t *n) { + char ip_str[INET6_ADDRSTRLEN]; + + inet_ntop(AF_INET6, &n->addr, (char *)ip_str, INET6_ADDRSTRLEN); + sprintf(n->host, "%s", ip_str); + sprintf(n->ip, "%s", ip_str); +} +#else void do_async_dns (struct net_t *n) { char n1[4], n2[4], n3[4], n4[4]; char buf[1024]; @@ -4393,11 +4477,14 @@ res_id = query_do(buf); add_rnet(n, res_id); } +#endif void net_donedns(struct net_t *net) { if (net->type != NET_WAITINGFORDNS) return; +#ifndef USE_IPV6 rem_rnet(net); +#endif switch(net->port) { case TELNET_PORT: { net_telnet_donedns (net); break; } case QUERY_PORT: { net_query_donedns (net); break; } --- tetrinetx-1.13.16.orig/src/net.c +++ tetrinetx-1.13.16/src/net.c @@ -6,21 +6,25 @@ /* i read somewhere that memcpy() is broken on some machines */ -/* it's easy to replace, so i'm not gonna take any chances, because it's -*/ +/* it's easy to replace, so i'm not gonna take any chances, because it's */ /* pretty important that it work correctly here */ -void my_memcpy(dest,src,len) +/* XXX until the contrary is proved, I'll use ISO C functions instead of + * my_*. */ +/* void my_memcpy(dest,src,len) char *dest,*src; int len; { while (len--) *dest++=*src++; } +*/ /* bzero() is bsd-only, so here's one for non-bsd systems */ +/* XXX but memset is ISO C, replaced. void my_bzero(dest,len) char *dest; int len; { while (len--) *dest++=0; } +*/ /* initialize the socklist */ void init_net() @@ -52,14 +56,39 @@ void getmyhostname(s) char *s; { - struct hostent *hp; char *p; + /* struct hostent *hp; */ + char *p; - p=getenv("HOSTNAME"); if (p!=NULL) { - strncpy(s,p, UHOSTLEN); - s[UHOSTLEN] = 0; - if (strchr(s,'.')!=NULL) return; + if ( (p=getenv("HOSTNAME")) != NULL ) + { + strncpy(s, p, UHOSTLEN); + s[UHOSTLEN] = '\0'; + if (strchr(s,'.') == NULL) + { + strncat(s,".localnet", UHOSTLEN - strlen(s)); + setenv("HOSTNAME",(const char*)s, 1); + } + return; } - gethostname(s,80); + else if (gethostname(s,MAXHOSTNAMELEN) == 0) + { + s[UHOSTLEN] = '\0'; + if (strchr(s,'.') == NULL) + { + strncat(s,".localnet", UHOSTLEN - strlen(s)); + setenv("HOSTNAME",(const char*)s, 1); + } + return; + } + else + { + memset(s,'\0',UHOSTLEN); + strncpy(s, "localhost.localnet", UHOSTLEN); + s[UHOSTLEN] = '\0'; + setenv("HOSTNAME",(const char*)s,1); + return; + } +/* gethostname(s,MAXHOSTNAMELEN); if (strchr(s,'.')!=NULL) return; hp=gethostbyname(s); if (hp==NULL) @@ -73,9 +102,27 @@ s[UHOSTLEN] = 0; if (strchr(s,'.')==NULL) fatal("Can't determine your hostname!",0); +*/ } /* get my ip number */ +#ifdef USE_IPV6 +void getmyip(struct in6_addr *ip) +{ + struct addrinfo hints, *res; + char s[121]; + + gethostname(s,120); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + if (getaddrinfo(s, NULL, &hints, &res)) { + fatal("Hostname self-lookup failed.",0); + } + memcpy(ip, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); +} +#else IP getmyip() { struct hostent *hp; char s[121]; IP ip; struct in_addr *in; @@ -88,6 +135,7 @@ ip=(IP)(in->s_addr); return ip; } +#endif void neterror(s) char *s; @@ -185,7 +233,13 @@ int getsock(options) int options; { - int sock=socket(AF_INET,SOCK_STREAM,0); + int sock; +#ifdef USE_IPV6 + if ( (sock = socket(AF_INET6,SOCK_STREAM,0)) <0 ) + sock=socket(AF_INET,SOCK_STREAM,0); +#else + sock=socket(AF_INET,SOCK_STREAM,0); +#endif if (sock<0) fatal("Can't open a socket at all!",0); setsock(sock,options); return sock; } @@ -228,10 +282,28 @@ int open_listen_socket(port,bindip) int *port; char *bindip; { +#ifdef USE_IPV6 + int sock,addrlen; struct sockaddr_in6 name; + + sock=getsock(SOCK_LISTEN); + memset((char *)&name,'\0',sizeof(struct sockaddr_in6)); + name.sin6_family=AF_INET6; + name.sin6_port=htons(*port); /* 0 = just assign us a port */ + if (bind(sock,(struct sockaddr *)&name,sizeof(name))<0) { +printf("ERROR\n"); + killsock(sock); return -1; + } + /* what port are we on? */ + addrlen=sizeof(name); + if (getsockname(sock,(struct sockaddr *)&name,&addrlen)<0) { + killsock(sock); return -1; + } + *port=ntohs(name.sin6_port); +#else int sock,addrlen; struct sockaddr_in name; sock=getsock(SOCK_LISTEN); - my_bzero((char *)&name,sizeof(struct sockaddr_in)); + memset((char *)&name,'\0',sizeof(struct sockaddr_in)); name.sin_family=AF_INET; name.sin_port=htons(*port); /* 0 = just assign us a port */ name.sin_addr.s_addr=getip(bindip); @@ -246,6 +318,7 @@ killsock(sock); return -1; } *port=ntohs(name.sin_port); +#endif if (listen(sock,5)<0) { printf("Erk\n"); killsock(sock); return -1; } return sock; } @@ -280,19 +353,28 @@ /* short routine to answer a connect received on a socket made previously */ +#ifdef USE_IPV6 int answer(sock,ip,binary) -int sock; unsigned long *ip; int binary; +int sock; struct in6_addr *ip; int binary; { - int new_sock,addrlen; struct sockaddr_in from; - addrlen=sizeof(struct sockaddr); + int new_sock,addrlen; struct sockaddr_in6 from; + addrlen=sizeof(struct sockaddr_in6); new_sock=accept(sock,(struct sockaddr *)&from,&addrlen); if (new_sock<0) return -1; - *ip=from.sin_addr.s_addr; - *ip=ntohl(*ip); + memcpy(ip, &from.sin6_addr, sizeof(struct in6_addr)); /* set up all the normal socket crap */ // setsock(new_sock,(binary ? SOCK_BINARY : 0)); return new_sock; } +#else +int answer(sock,ip,binary) +int sock; unsigned long *ip; int binary; +{ + /* set up all the normal socket crap */ + // setsock(new_sock,(binary ? SOCK_BINARY : 0)); + return new_sock; +} +#endif /* attempts to read from all the sockets in socklist */ /* fills s with up to 1023 bytes if available, and returns 0 */ @@ -437,7 +519,7 @@ s[0]=0; return slist->sock; } if (slist->flags & SOCK_BINARY) { - my_memcpy(s,xx,*len); + memcpy(s,xx,*len); return slist->sock; } if (slist->flags & SOCK_LISTEN) return slist->sock; --- tetrinetx-1.13.16.orig/bin/game.secure +++ tetrinetx-1.13.16/bin/game.secure @@ -8,15 +8,15 @@ # Any text after a # is ignored, and can be used as comments. # op_password [] - Typing /op will give player op status -op_password=pass4word +#op_password=pass4word # query_password [] - For query irc client -query_password=pass4word +#query_password=pass4word # spec_password [] - Use this as team name for gameplay watch -spec_password=pass4word +#spec_password=pass4word # spec_op_password [] - Use this as team name for gameplay watch with extended capability (unused in this release) -spec_op_password=pass4word +#spec_op_password=pass4word # End of File --- tetrinetx-1.13.16.orig/bin/game.conf +++ tetrinetx-1.13.16/bin/game.conf @@ -8,10 +8,10 @@ # Any text after a # is ignored, and can be used as comments. # pidfile [game.pid] - Where should the Process ID be written -pidfile=game.pid +pidfile=/var/run/tetrinetx/game.pid # bindip [0.0.0.0] - What IP should server be bound to (0.0.0.0 means all) -bindip=0.0.0.0 +#bindip=0.0.0.0 # maxchannels [1] - How many channels should be available on server maxchannels=8 --- tetrinetx-1.13.16.orig/debian/dirs +++ tetrinetx-1.13.16/debian/dirs @@ -0,0 +1,5 @@ +etc/tetrinetx +usr/games +var/run/tetrinetx +var/log/tetrinetx +var/games/tetrinetx --- tetrinetx-1.13.16.orig/debian/examples +++ tetrinetx-1.13.16/debian/examples @@ -0,0 +1 @@ +bin/*.example --- tetrinetx-1.13.16.orig/debian/rules +++ tetrinetx-1.13.16/debian/rules @@ -0,0 +1,75 @@ +#!/usr/bin/make -f + +CFLAGS=-O2 -DUSE_IPV6 -fno-strength-reduce -Wall -fsigned-char -I/usr/include -L/usr/lib +DESTDIR=$(CURDIR)/debian/tetrinetx/ +OWNDIRS= $(DESTDIR)var/games/tetrinetx \ + $(DESTDIR)var/run/tetrinetx \ + $(DESTDIR)var/log/tetrinetx \ + $(DESTDIR)etc/tetrinetx + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +configure: configure-stamp +configure-stamp: + dh_testdir + + cp debian/config.h src/ + + touch configure-stamp + +build: build-stamp + +build-stamp: configure-stamp bin/tetrinetx + dh_testdir + touch build-stamp + +bin/tetrinetx: $(wildcard src/*.[ch]) + $(CC) $(CFLAGS) src/main.c -o $@ -ladns + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + -rm -f src/.deps/main.P bin/tetrinetx + + dh_clean + +install: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + install -o games -g games -m 0755 bin/tetrinetx $(DESTDIR)/usr/games/tetrinetx + install -o games -g games -m 0644 bin/game.motd bin/game.pmotd bin/game.conf $(DESTDIR)etc/tetrinetx + install -o games -g games -m 0600 bin/game.secure $(DESTDIR)etc/tetrinetx + chown -R games:games $(OWNDIRS) + +binary-indep: + +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs + dh_installexamples + chmod 0644 $(DESTDIR)usr/share/doc/tetrinetx/examples/* + dh_installinit + dh_installlogrotate + dh_installman + dh_installchangelogs ChangeLog + dh_link + dh_strip + dh_compress + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-arch +.PHONY: build clean binary-arch binary install configure --- tetrinetx-1.13.16.orig/debian/control +++ tetrinetx-1.13.16/debian/control @@ -0,0 +1,18 @@ +Source: tetrinetx +Section: games +Priority: optional +Maintainer: Julien Danjou +Build-Depends: debhelper (>> 5.0.0), libadns1-dev +Standards-Version: 3.7.2 + +Package: tetrinetx +Architecture: any +Depends: ${shlibs:Depends} +Description: Game server for Tetrinet + Provides a server for hosting Tetrinet games. Tetrinet is a variant of + Tetris played over the internet. Up to six people may simultaneously connect + to a server to participate in a game. + . + For more information about the Tetrinet game, visit http://www.tetrinet.org/ + . + You can use gtetrinet as a tetrinet client (http://gtetrinet.sf.net/) --- tetrinetx-1.13.16.orig/debian/logrotate +++ tetrinetx-1.13.16/debian/logrotate @@ -0,0 +1,9 @@ +/var/log/tetrinetx/*.log { + weekly + missingok + rotate 52 + compress + delaycompress + notifempty + create 640 games games +} --- tetrinetx-1.13.16.orig/debian/compat +++ tetrinetx-1.13.16/debian/compat @@ -0,0 +1 @@ +5 --- tetrinetx-1.13.16.orig/debian/init +++ tetrinetx-1.13.16/debian/init @@ -0,0 +1,78 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: tetrinetx +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Init script for tetrinetx +### END INIT INFO + +SCRIPT=$0 +ACTION=$1 + +NAME="tetrinetx" +DESC="Tetrinet Server" +PIDF="/var/run/tetrinetx/game.pid" +LOGF="/var/log/tetrinetx/game.log" +CONF="/etc/tetrinetx/game.conf" +BINX="/usr/games/tetrinetx" + +test -x $BINX || exit 0 + +if [ "`echo $ACTION | cut -d- -f2`" != "now" ]; then + test -f /etc/default/tetrinetx || exit 0 + # handle guys wo do not want to run tetrinetx through init.d + . /etc/default/tetrinetx + RUNIT=`echo $RUN_AT_STARTUP | tr '[a-z]' '[A-Z]'` + if [ "$RUNIT" = "NO" ]; then + exit 0 + fi +fi + +case "$ACTION" in + start|start-now) + echo -n "Starting ${DESC}: " + start-stop-daemon --start -q --pidfile $PIDF \ + -c games:games --exec $BINX 2>&1 >> $LOGF + if [ "$?" -eq "1" ]; then + echo "${NAME} already running, not started." + exit 0 + else + echo "${NAME}." + fi + ;; + stop|stop-now) + echo -n "Stopping ${DESC}: " + start-stop-daemon --stop -q --pidfile $PIDF \ + --retry 10 --exec $BINX 2>&1 >> $LOGF + if [ "$?" -eq "1" ]; then + echo "${NAME} not running, not stopped." + exit 0 + else + echo "${NAME}." + fi + ;; + restart|force-reload) + echo -n "Restarting ${DESC}: " + start-stop-daemon --stop -q --pidfile $PIDF \ + --retry 10 --exec $BINX 2>&1 >> $LOGF + if [ "$?" -eq "1" ]; then + echo "${NAME} not running, not stopped." + fi + start-stop-daemon --start -q --pidfile $PIDF \ + -c games:games --exec $BINX 2>&1 >> $LOGF + if [ "$?" -eq "1" ]; then + echo "${NAME} already running, not started." + exit 0 + else + echo "${NAME}." + fi + ;; + *) + echo "Usage: $SCRIPT {start[-now]|stop[-now]|restart|force-reload}" + exit 1 + ;; +esac + +exit 0 --- tetrinetx-1.13.16.orig/debian/copyright +++ tetrinetx-1.13.16/debian/copyright @@ -0,0 +1,27 @@ +This package was debianized by Helios de Creisquer on +Mon, 2 Sep 2002 15:17:32 +0200. + +It was downloaded from http://tetrinetx.sourceforge.net/ + +Upstream Authors: Brendan Grieve , + Roongroj Phoophuangpairoj + + +Copyright: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + + This package is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian GNU/Linux systems, the complete text of the GNU General Public +License can be found in `/usr/share/common-licenses/GPL'. + --- tetrinetx-1.13.16.orig/debian/changelog +++ tetrinetx-1.13.16/debian/changelog @@ -0,0 +1,105 @@ +tetrinetx (1.13.16-12.1) unstable; urgency=low + + * Non-maintainer upload to solve release goal. + * Add LSB dependency header to init.d scripts (Closes: #467487). + + -- Petter Reinholdtsen Thu, 3 Apr 2008 23:23:44 +0200 + +tetrinetx (1.13.16-12) unstable; urgency=low + + * Move manpage to correct section (Closes: #404994) + * Bump to debhelper 5 + + -- Julien Danjou Thu, 12 Apr 2007 15:28:30 +0200 + +tetrinetx (1.13.16-11) unstable; urgency=low + + * Fix grammatical errors in manpage (Closes: #362469) + * Switch to debhelper 4 + * Bump standards version + * Update FSF address + + -- Julien Danjou Sun, 6 Aug 2006 13:47:02 +0200 + +tetrinetx (1.13.16-10) unstable; urgency=low + + * Add a light manpage (Closes: #270440) + + -- Julien Danjou Thu, 9 Sep 2004 15:02:26 +0200 + +tetrinetx (1.13.16-9) unstable; urgency=low + + * New Maintainer + * Clean debian/rules + * Bump standards version to 3.6.1.0 + * Remove spurious message (Closes: #255034) + * Remove setuid flag since it is not needed + + -- Julien Danjou Tue, 17 Aug 2004 15:26:31 +0200 + +tetrinetx (1.13.16-8) unstable; urgency=low + + * Changed init script which used the HUP signal to reload tetrinetx, + but that signal was not catched in tetrinetx, do we dont use HUP anymore + (closes: #175448), Thanks to Ben Armstrong. + + * Changed Standards-Version to 3.5.8 + + -- Helios de Creisquer Fri, 24 Jan 2003 15:34:42 +0100 + +tetrinetx (1.13.16-7) unstable; urgency=low + + * Corrected the way hostname determination was handled, corrected + a very stupid segfault (closes: #168630) + + -- Helios de Creisquer Mon, 11 Nov 2002 15:09:56 +0100 + +tetrinetx (1.13.16-6) unstable; urgency=low + + * Corrected behavior of ipv6 patch: if v6 stack is not present, falling + back to V4 instead of exiting (closes: #168061) + * Corrected the way hostname determination was handled, now run even if no + '.' was found in hostname, by appending '.localnet' to it. + + -- Helios de Creisquer Fri, 08 Nov 2002 11:55:55 +0100 + +tetrinetx (1.13.16-5) unstable; urgency=low + + * Corrected prerm script to _not_ call invoke-rc.d when upgrading from + version < -5 (closes: #165945) + * Changed description, explaining a little bit what tetrinet is + (closes: #166109) + + -- Helios de Creisquer Thu, 24 Oct 2002 09:39:20 +0200 + +tetrinetx (1.13.16-4) unstable; urgency=low + + * Corrected init script stop which exited 1 when no tetrinetx was present, + and make the initscript do nothing until /etc/default/tetrinetx is edited + (closes: #165945) + + -- Helios de Creisquer Wed, 23 Oct 2002 02:12:46 +0200 + +tetrinetx (1.13.16-3) unstable; urgency=low + + * Added -fsigned-char for architectures where default is + unsigned (closes: #164609) + * Convert package to "daemon", tits change location of pids, logs and others + to standard daemon (vs game) locations, added an init script. + * Added IPv6 support patch from version6.net (closes: #165623) + + -- Helios de Creisquer Fri, 18 Oct 2002 20:49:41 +0200 + +tetrinetx (1.13.16-2) unstable; urgency=low + + * Changed way of compiling, limitating dependencies (closes: #164417) + + -- Helios de Creisquer (aka creis) Sat, 12 Oct 2002 15:34:45 +0200 + +tetrinetx (1.13.16-1) unstable; urgency=low + + * Initial Release. + + -- Helios de Creisquer (aka creis) Mon, 2 Sep 2002 15:17:32 +0200 + + --- tetrinetx-1.13.16.orig/debian/README.Debian +++ tetrinetx-1.13.16/debian/README.Debian @@ -0,0 +1,8 @@ +Tetrinetx uses /etc/default/tetrinetx to know whether it should be ran +at startup [ or whenever invoking the init.d script ] or not, reading +the variable RUN_AT_STARTUP. + +By default, this variable contains "NO", so if you want to start +tetrinetx at startup, modify /etc/default/tetrinetx and make this +variable say "YES". + --- tetrinetx-1.13.16.orig/debian/manpages +++ tetrinetx-1.13.16/debian/manpages @@ -0,0 +1 @@ +debian/tetrinetx.6 --- tetrinetx-1.13.16.orig/debian/config.h +++ tetrinetx-1.13.16/debian/config.h @@ -0,0 +1,17 @@ +// CONFIG +#define FILE_MOTD "/etc/tetrinetx/game.motd" +#define FILE_PMOTD "/etc/tetrinetx/game.pmotd" +#define FILE_CONF "/etc/tetrinetx/game.conf" +#define FILE_BAN "/etc/tetrinetx/game.ban" +#define FILE_ALLOW "/etc/tetrinetx/game.allow" +#define FILE_SECURE "/etc/tetrinetx/game.secure" +#define FILE_BAN_COMPROMISE "/etc/tetrinetx/game.ban.compromise" + +// LOG & PID +#define FILE_LOG "/var/log/tetrinetx/game.log" +#define FILE_PID "/var/run/tetrinetx/game.pid" + +// SCORES +#define FILE_WINLIST "/var/games/tetrinetx/game.winlist" +#define FILE_WINLIST2 "/var/games/tetrinetx/game.winlist2" +#define FILE_WINLIST3 "/var/games/tetrinetx/game.winlist3" --- tetrinetx-1.13.16.orig/debian/prerm +++ tetrinetx-1.13.16/debian/prerm @@ -0,0 +1,19 @@ +#!/bin/sh +set -e + +ACTION=$1 ; shift + +case "$ACTION" in + failed-upgrade) + VERSION=$1 ; shift + DEBVER=`echo $VERSION | cut -d- -f2` + if [ "$DEBVER" -lt "5" ]; then + # dont try to stop -> do nothing and return success. + echo -n "Version prior to 5 are not daemonized correctly: " + echo "Not running tetrinetx init script." + exit 0 + fi + # else let the debhelper stuff acting. +esac + +#DEBHELPER# --- tetrinetx-1.13.16.orig/debian/docs +++ tetrinetx-1.13.16/debian/docs @@ -0,0 +1,2 @@ +README +README.qirc.spectators --- tetrinetx-1.13.16.orig/debian/default +++ tetrinetx-1.13.16/debian/default @@ -0,0 +1,6 @@ +# +# RUN_AT_STARTUP +# "NO" : Default, /etc/init.d/tetrinetx will exit silently. +# "YES" : /etc/init.d/tetrinetx will start tetrinetx daemon. +# +RUN_AT_STARTUP="NO" --- tetrinetx-1.13.16.orig/debian/tetrinetx.6 +++ tetrinetx-1.13.16/debian/tetrinetx.6 @@ -0,0 +1,40 @@ +.\" Hey, EMACS: -*- nroff -*- +.\" First parameter, NAME, should be all caps +.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection +.\" other parameters are allowed: see man(7), man(1) +.TH tetrinetx 6 "September 2004" +.\" Please adjust this date whenever revising the manpage. +.\" +.\" Some roff macros, for reference: +.\" .nh disable hyphenation +.\" .hy enable hyphenation +.\" .ad l left justify +.\" .ad b justify to both left and right margins +.\" .nf disable filling +.\" .fi enable filling +.\" .br insert line break +.\" .sp insert n+1 empty lines +.\" for manpage-specific macros, see man(7) +.SH NAME +tetrinetx \- TetriNET server +.SH SYNOPSIS +.B tetrinetx +.br +.SH DESCRIPTION +This manual page documents briefly the +.B tetrinetx +command. +This manual page was written for the Debian distribution +because the original program does not have a manual page. +.PP +.\" TeX users may be more comfortable with the \fB\fP and +.\" \fI\fP escape sequences to invode bold face and italics, +.\" respectively. +\fBtetrinetx\fP provides a server for hosting Tetrinet games. +Tetrinet is a variant of Tetris played over the internet. +Up to six people may simultaneously connect to a server to participate in a game. +.SH OPTIONS +This program does not allow any option. +.SH AUTHOR +This manual page was written by Julien Danjou , +for the Debian project (but may be used by others).