Skip to content

Commit

Permalink
Rewrite script/init_db.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuni Kim committed Jul 4, 2011
1 parent 215ad6d commit 61ea08c
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions script/init_db.sh
@@ -1,23 +1,20 @@
#!/bin/sh

DB_SQL=db/init.sql
DB_FILE=db/upload.db

if [ -e ./db ]; then
echo Creating $DB_FILE...
if [ -e $DB_FILE ]; then
echo $DB_FILE is already exists.
echo Usage : script/init_db.sh
exit
fi

if [ -e $DB_FILE ]; then
echo $DB_FILE is already exists.
else
sqlite3 $DB_FILE <<__SQL__
CREATE TABLE upload (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
md5 TEXT NOT NULL,
fname TEXT NOT NULL,
download INTEGER NOT NULL DEFAULT 0
);
__SQL__
echo Done.
fi
else
if [ ! -e $DB_SQL ]; then
echo $DB_SQL is not exists.
echo Usage : script/init_db.sh
exit
fi

echo Creating $DB_FILE...
cat $DB_SQL | sqlite3 $DB_FILE
echo Done.

0 comments on commit 61ea08c

Please sign in to comment.