blob: 5b3fe173f7e17f0d218c0fffbf3fbf41a700443d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
|