From 24189a955a10941cf16a4b03de24e79be7a5de48 Mon Sep 17 00:00:00 2001
From: Pasi Kallinen <paxed@alt.org>
Date: Tue, 25 Nov 2008 16:13:50 +0000
Subject: [PATCH] Improve the flat text db -> sqlite3 db conversion script.

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@456 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
---
 convert_dgl-login.sh | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/convert_dgl-login.sh b/convert_dgl-login.sh
index c8cfdd4..94163fe 100644
--- a/convert_dgl-login.sh
+++ b/convert_dgl-login.sh
@@ -4,15 +4,30 @@
 # to the new sqlite3 database.
 #
 
+
+TEMPFILE="dgl-login.tmp"
+FLATDB="dgl-login"
 DBFILE="dgamelaunch.db"
 
+
+if [ -e "$TEMPFILE" ]; then
+    echo "$TEMPFILE already exists.";
+    exit;
+fi
 if [ -e "$DBFILE" ]; then
     echo "$DBFILE already exists.";
     exit;
 fi
+if [ ! -e "$FLATDB" ]; then
+    echo "$FLATDB does not exist.";
+    exit;
+fi
+
 
 sqlite3 "$DBFILE" "create table dglusers (id integer primary key, username text, email text, env text, password text, flags integer);"
 
-cat dgl-login | sed -e "s/'/''/g" -e "s/^\([^:]*\):\([^:]*\):\([^:]*\):/insert into dglusers (username, email, password, env, flags) values ('\1', '\2', '\3', '', 0); /g" > dgl-login.tmp
+cat "$FLATDB" | sed -e "s/'/''/g" -e "s/^\([^:]*\):\([^:]*\):\([^:]*\):/insert into dglusers (username, email, password, env, flags) values ('\1', '\2', '\3', '', 0); /g" > "$TEMPFILE"
 
-sqlite3 "$DBFILE" ".read dgl-login.tmp"
+sqlite3 "$DBFILE" ".read $TEMPFILE"
+
+rm -f "$TEMPFILE"