Skip to content

Commit

Permalink
allow empty postgresql administration password on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskrause committed Mar 12, 2013
1 parent 2fa2ee1 commit 5dc4e71
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
6 changes: 3 additions & 3 deletions annis-service/nbactions-Adminstration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</goals>
<properties>
<exec.classpathScope>runtime</exec.classpathScope>
<exec.args>-Dannis.home=src/main/distribution/ -classpath %classpath annis.administration.AnnisAdminRunner list</exec.args>
<exec.args>-Dannis.home=src/main/distribution/ -classpath %classpath annis.administration.AnnisAdminRunner init -d test -u test -p test</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
Expand All @@ -20,7 +20,7 @@
</goals>
<properties>
<exec.classpathScope>runtime</exec.classpathScope>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dannis.home=src/main/distribution/ -classpath %classpath annis.administration.AnnisAdminRunner list</exec.args>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dannis.home=src/main/distribution/ -classpath %classpath annis.administration.AnnisAdminRunner init -d test -u test -p test</exec.args>
<jpda.listen>true</jpda.listen>
<exec.executable>java</exec.executable>
</properties>
Expand All @@ -32,7 +32,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.1.1:exec</goal>
</goals>
<properties>
<exec.args>${profiler.args} -Dannis.home=src/main/distribution/ -classpath %classpath annis.administration.AnnisAdminRunner list</exec.args>
<exec.args>${profiler.args} -Dannis.home=src/main/distribution/ -classpath %classpath annis.administration.AnnisAdminRunner init -d test -u test -p test</exec.args>
<profiler.action>profile</profiler.action>
<exec.executable>${profiler.java}</exec.executable>
</properties>
Expand Down
14 changes: 14 additions & 0 deletions annis-service/src/main/distribution/sql/annopool/schema.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
-- (modified) source tables

DROP TABLE IF EXISTS repository_metadata CASCADE;
CREATE TABLE repository_metadata
(
name varchar NOT NULL PRIMARY KEY,
"value" varchar NOT NULL
);

DROP TABLE IF EXISTS corpus CASCADE;
CREATE TABLE corpus
(
id integer PRIMARY KEY,
Expand All @@ -23,6 +25,7 @@ COMMENT ON COLUMN corpus.pre IS 'pre-order value';
COMMENT ON COLUMN corpus.post IS 'post-order value';
COMMENT ON COLUMN corpus.path_name IS 'path of this corpus in the corpus tree (names)';

DROP TABLE IF EXISTS corpus_annotation CASCADE;
CREATE TABLE corpus_annotation
(
corpus_ref integer NOT NULL REFERENCES corpus (id) ON DELETE CASCADE,
Expand All @@ -36,6 +39,7 @@ COMMENT ON COLUMN corpus_annotation.namespace IS 'optional namespace of annotati
COMMENT ON COLUMN corpus_annotation.name IS 'annotation key';
COMMENT ON COLUMN corpus_annotation.value IS 'annotation value';

DROP TABLE IF EXISTS text CASCADE;
CREATE TABLE text
(
corpus_ref integer REFERENCES corpus(id),
Expand All @@ -49,8 +53,10 @@ COMMENT ON COLUMN text.id IS 'primary key';
COMMENT ON COLUMN text.name IS 'informational name of the primary data text';
COMMENT ON COLUMN text.text IS 'raw text data';

DROP TYPE IF EXISTS annotype CASCADE;
CREATE TYPE annotype AS ENUM ('node', 'edge', 'segmentation');
-- collect all node annotations
DROP TABLE IF EXISTS annotation_pool CASCADE;
CREATE TABLE annotation_pool (
id bigserial,
toplevel_corpus integer REFERENCES corpus(id),
Expand All @@ -63,6 +69,7 @@ CREATE TABLE annotation_pool (
UNIQUE(namespace, "name", val, "type", toplevel_corpus)
);

DROP TABLE IF EXISTS facts CASCADE;
CREATE TABLE facts (
fid bigserial,
id bigint,
Expand Down Expand Up @@ -115,6 +122,7 @@ COMMENT ON COLUMN facts.edge_type IS 'edge type of this component';
COMMENT ON COLUMN facts.edge_namespace IS 'optional namespace of the edges’ names';
COMMENT ON COLUMN facts.edge_name IS 'name of the edges in this component';

DROP TABLE IF EXISTS media_files CASCADE;
CREATE TABLE media_files
(
file bytea NOT NULL,
Expand All @@ -127,6 +135,7 @@ CREATE TABLE media_files


-- stats
DROP TABLE IF EXISTS corpus_stats CASCADE;
CREATE TABLE corpus_stats
(
name varchar,
Expand All @@ -142,6 +151,7 @@ CREATE TABLE corpus_stats
);


DROP VIEW IF EXISTS corpus_info CASCADE;
CREATE VIEW corpus_info AS SELECT
name,
id,
Expand All @@ -151,6 +161,7 @@ CREATE VIEW corpus_info AS SELECT
FROM
corpus_stats;

DROP TYPE IF EXISTS resolver_visibility CASCADE;
CREATE TYPE resolver_visibility AS ENUM (
'permanent',
'visible',
Expand All @@ -159,6 +170,7 @@ CREATE TYPE resolver_visibility AS ENUM (
'preloaded'
);

DROP TABLE IF EXISTS resolver_vis_map CASCADE;
CREATE TABLE resolver_vis_map
(
"id" serial PRIMARY KEY,
Expand All @@ -184,6 +196,7 @@ COMMENT ON COLUMN resolver_vis_map.visibility IS 'defines the visibility state o
COMMENT ON COLUMN resolver_vis_map.order IS 'the order of the layers, in which they shall be shown';
COMMENT ON COLUMN resolver_vis_map.mappings IS 'which annotations in this corpus correspond to fields expected by the visualization, e.g. the tree visualizer expects a node label, which is called "cat" by default but may be changed using this field';

DROP TABLE IF EXISTS annotations CASCADE;
CREATE TABLE annotations
(
id bigserial NOT NULL,
Expand All @@ -199,6 +212,7 @@ CREATE TABLE annotations
PRIMARY KEY (id)
);

DROP TABLE IF EXISTS user_config CASCADE;
CREATE TABLE user_config
(
id varchar NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ protected void createDatabase(String database)
+ " ENCODING = 'UTF8' TEMPLATE template0");
}

protected void setupDatabase()
protected void setupDatabase(boolean asAdmin)
{
installPlPgSql();
if(asAdmin)
{
installPlPgSql();
}
createFunctionUniqueToplevelCorpusName();
}

Expand Down Expand Up @@ -246,31 +249,35 @@ public boolean checkDatabaseSchemaVersion() throws AnnisException
}

@Override

public void initializeDatabase(String host, String port, String database,
String user, String password, String defaultDatabase, String superUser,
String superPassword)
{
log.info("Creating Annis database and user.");
// connect as super user to the default database to create new user and database
setDataSource(createDataSource(host, port,
if(superPassword != null)
{
setDataSource(createDataSource(host, port,
defaultDatabase, superUser, superPassword));

dropDatabase(database);
dropUser(user);
createUser(user, password);
createDatabase(database);


// switch to new database, but still as super user to install stored procedure compute_rank_level
setDataSource(createDataSource(host, port, database,
superUser, superPassword));
setupDatabase();


dropDatabase(database);
dropUser(user);
createUser(user, password);
createDatabase(database);


setupDatabase(true);
}

// switch to new database as new user for the rest
setDataSource(createDataSource(host, port, database,
user, password));

if(superPassword == null)
{
// do setup as normal user
setupDatabase(false);
}

createSchema();
createSchemaIndexes();
populateSchema();
Expand Down
7 changes: 7 additions & 0 deletions doc/doxygen/admin/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ export PATH=$PATH:$ANNIS_HOME/bin
annis-admin.sh init -u <username> -d <dbname> -p
-P <postgres password>
\endcode
You can omit the PostgreSQL administrator password option (`-P`). Then the database and user must already
exists. E.g. you should execute the following as PostgreSQL administrator:
\code{.sql}
CREATE LANGUAGE plpgsql; -- ignore the error if the language is already installed
CREATE USER myuser PASSWORD 'mypassword';
CREATE DATABASE mydb OWNER myuser ENCODING 'UTF8';
\endcode
7. Now you can import some corpora:
\code{.sh}
annis-admin.sh import path/to/corpus1 path/to/corpus2 ...
Expand Down

0 comments on commit 5dc4e71

Please sign in to comment.