]> skyeroc.xyz Git - dgamelaunch/commitdiff
Improve the conversion script
authorPasi Kallinen <paxed@alt.org>
Fri, 28 Dec 2007 12:41:46 +0000 (12:41 +0000)
committerPasi Kallinen <paxed@alt.org>
Fri, 28 Dec 2007 12:41:46 +0000 (12:41 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@380 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

convert_dgl-login.sh

index e4b44df6ef8d5d4f57ebb8eb38490772458fe504..f524c058f11fc6ab64cc64e67213325e0944f07c 100644 (file)
@@ -1,21 +1,18 @@
 #!/bin/sh
 #
-# This script converts the flat-text file password file
+# This script converts the flat-text password file
 # to the new sqlite3 database.
 #
 
 DBFILE="dgamelaunch.db"
 
-sqlite3 $DBFILE "create table dglusers (id integer primary key, username text, email text, env text, password text, flags integer);"
+if [-e "$DBFILE"]; then
+    echo "$DBFILE already exists.";
+    exit;
+fi
 
-for x in `cat dgl-login`; do
-    username="`echo $x | cut -d':' -f1`";
-    email="`echo $x | cut -d':' -f2`";
-    password="`echo $x | cut -d':' -f3`";
-    env="`echo $x | cut -d':' -f4`";
-    flags="0";
+sqlite3 "$DBFILE" "create table dglusers (id integer primary key, username text, email text, env text, password text, flags integer);"
 
-    cmdstring="insert into dglusers (username, email, env, password, flags) values ('"$username"', '"$email"', '"$env"', '"$password"', "$flags")"
-    sqlite3 $DBFILE "$cmdstring"
-done;
+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
 
+sqlite3 "$DBFILE" ".read dgl-login.tmp"