mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
add cmd to build the database and main table
This commit is contained in:
parent
ddcc338ed7
commit
e3053370d0
1 changed files with 28 additions and 1 deletions
|
@ -12,6 +12,27 @@ LOGFILE=/tmp/xwrelay_log.txt
|
|||
|
||||
date > $LOGFILE
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 start | stop | restart | mkdb"
|
||||
}
|
||||
|
||||
make_db() {
|
||||
createdb xwgames
|
||||
cat | psql xwgames --file - <<EOF
|
||||
CREATE TABLE games (
|
||||
cid integer,
|
||||
cookie VARCHAR(32),
|
||||
connName VARCHAR(64) UNIQUE PRIMARY KEY,
|
||||
nTotal INTEGER,
|
||||
nHere INTEGER,
|
||||
lang INTEGER,
|
||||
isPublic BOOLEAN,
|
||||
ctime TIMESTAMP,
|
||||
mtime TIMESTAMP
|
||||
);
|
||||
EOF
|
||||
}
|
||||
|
||||
do_start() {
|
||||
if [ -f $PIDFILE ] && [ -f /proc/$(cat $PIDFILE)/exe ]; then
|
||||
echo "already running: pid=$(cat $PIDFILE)" | tee -a $LOGFILE
|
||||
|
@ -58,8 +79,14 @@ case $1 in
|
|||
shift
|
||||
do_start $@
|
||||
;;
|
||||
|
||||
mkdb)
|
||||
make_db
|
||||
;;
|
||||
|
||||
*)
|
||||
do_start $@
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue