summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/INSTALL1
-rwxr-xr-xsql/create_db.sh71
2 files changed, 72 insertions, 0 deletions
diff --git a/sql/INSTALL b/sql/INSTALL
new file mode 100644
index 0000000..e78334c
--- /dev/null
+++ b/sql/INSTALL
@@ -0,0 +1 @@
+Run the ./create_db.sh shell script to create the database.
diff --git a/sql/create_db.sh b/sql/create_db.sh
new file mode 100755
index 0000000..5b3fe17
--- /dev/null
+++ b/sql/create_db.sh
@@ -0,0 +1,71 @@
+Â#!/bin/sh
+
+drop="y"
+echo "Drop existing database and user? (y/n) [$drop]"
+read x
+
+if [ "$x" ] ; then
+ drop=$x
+fi
+
+dbname="PassMan"
+echo "Name of database to create [$dbname]:"
+read x
+
+if [ "$x" ] ; then
+ dbname=$x
+fi
+
+uname="PassMan"
+echo "Name of database user to create [$uname]:"
+read x
+
+if [ "$x" ] ; then
+ uname=$x
+fi
+
+pword="PassMan"
+echo "Password of database user [$pword]:"
+read x
+
+if [ "$x" ] ; then
+ pword=$x
+fi
+
+script=/tmp/$$
+rm -f $script
+touch $script
+
+if [ "$drop" = "y" ] ; then
+ cat >> $script << END_OF_DROP
+drop database $dbname;
+delete from mysql.user where username='$uname';
+END_OF_DROP
+fi
+
+cat >> $script << END_OF_SQL
+
+create database $dbname;
+grant all on $dbname to '$uname'@'localhost' identified by '$pword';
+use $dbname;
+
+create table pm_user
+(
+ name varchar(256) not null,
+ password varchar(256) not null,
+ constraint pk_pm_user primary key(name)
+);
+
+create table pm_store
+(
+ name varchar(256) not null,
+ description varchar(1024) not null,
+ username varchar(256) not null,
+ password varchar(256) not null
+ constraint pk_pm_user primary key(name, description)
+);
+
+END_OF_SQL
+
+cat $script
+rm -f $script