mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +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
|
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() {
|
do_start() {
|
||||||
if [ -f $PIDFILE ] && [ -f /proc/$(cat $PIDFILE)/exe ]; then
|
if [ -f $PIDFILE ] && [ -f /proc/$(cat $PIDFILE)/exe ]; then
|
||||||
echo "already running: pid=$(cat $PIDFILE)" | tee -a $LOGFILE
|
echo "already running: pid=$(cat $PIDFILE)" | tee -a $LOGFILE
|
||||||
|
@ -58,8 +79,14 @@ case $1 in
|
||||||
shift
|
shift
|
||||||
do_start $@
|
do_start $@
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
mkdb)
|
||||||
|
make_db
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
do_start $@
|
usage
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue