diff --git a/fixtures/server-config.json b/fixtures/server-config.json index 1710fd007a..24c251234a 100644 --- a/fixtures/server-config.json +++ b/fixtures/server-config.json @@ -18,6 +18,6 @@ }, "storage": { "backend": "mysql", - "db_url": "root@tcp(notarymysql:3306)/notary?parseTime=True" + "db_url": "server@tcp(notarymysql:3306)/notaryserver?parseTime=True" } } diff --git a/fixtures/signer-config.json b/fixtures/signer-config.json index 6c2de985f3..b6be189151 100644 --- a/fixtures/signer-config.json +++ b/fixtures/signer-config.json @@ -11,6 +11,6 @@ }, "storage": { "backend": "mysql", - "db_url": "root@tcp(notarymysql:3306)/notary?parseTime=True" + "db_url": "signer@tcp(notarymysql:3306)/notarysigner?parseTime=True" } } diff --git a/notarymysql/start b/notarymysql/start index 0172c63d44..a12ff6dbb5 100755 --- a/notarymysql/start +++ b/notarymysql/start @@ -1,12 +1,25 @@ #!/bin/bash set -e -DB_NAME='notary' +# Although the Notary-Server and Notary-Signer could use the same +# database, it's better to seperate that for security. +DB_NAME_SERVER='notaryserver' +DB_NAME_SIGNER='notarysigner' +DB_NAME=($DB_NAME_SERVER,$DB_NAME_SIGNER) + DB_TABLE_FILES='tuf_files' DB_TABLE_KEYS='timestamp_keys' DB_USER='root' DB_PASS='' +# Default username and password for Notary-Server +DB_USER_SERVER='server' +DB_PASS_SERVER='' + +# Default username and password for Notary-Signer +DB_USER_SIGNER='signer' +DB_PASS_SIGNER='' + DB_REMOTE_ROOT_NAME='' DB_REMOTE_ROOT_PASS='' DB_REMOTE_ROOT_HOST='' @@ -101,10 +114,15 @@ if [ -n "${DB_USER}" -o -n "${DB_NAME}" ]; then echo "Creating database \"$db\"..." mysql --defaults-file=/etc/mysql/debian.cnf \ -e "CREATE DATABASE IF NOT EXISTS \`$db\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;" - if [ -n "${DB_USER}" ]; then - echo "Granting access to database \"$db\" for user \"${DB_USER}\"..." + if [ -n "${DB_USER_SERVER}" -a $db = $DB_NAME_SERVER ]; then + echo "Granting access to database \"$db\" for user \"${DB_USER_SERVER}\"..." mysql --defaults-file=/etc/mysql/debian.cnf \ - -e "GRANT ALL PRIVILEGES ON \`$db\`.* TO '${DB_USER}' IDENTIFIED BY '${DB_PASS}';" + -e "GRANT ALL PRIVILEGES ON \`$db\`.* TO '${DB_USER_SERVER}' IDENTIFIED BY '${DB_PASS_SERVER}';" + fi + if [ -n "${DB_USER_SIGNER}" -a $db = $DB_NAME_SIGNER ]; then + echo "Granting access to database \"$db\" for user \"${DB_USER_SIGNER}\"..." + mysql --defaults-file=/etc/mysql/debian.cnf \ + -e "GRANT ALL PRIVILEGES ON \`$db\`.* TO '${DB_USER_SIGNER}' IDENTIFIED BY '${DB_PASS_SIGNER}';" fi # Create our Database: mysql -uroot $db < ./initial.sql