diff --git a/client/src/account/API.js b/client/src/account/API.js index 3512477f3..a882162bc 100644 --- a/client/src/account/API.js +++ b/client/src/account/API.js @@ -86,13 +86,13 @@ export default class API extends Component { -
-
-
- +
+
+
+
-
-
+
+

{t('getSubscribers')}

@@ -118,12 +118,12 @@ export default class API extends Component {
-
-
-

+
+
+

-
-
+
+

{t('thisApiCallEitherInsertsANewSubscription')}

@@ -175,12 +175,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('thisApiCallMarksASubscriptionAs')}

@@ -214,12 +214,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('thisApiCallDeletesASubscription')}

@@ -252,12 +252,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('thisApiCallCreatesANewCustomFieldForA')}

@@ -310,12 +310,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('thisApiCallGetListOfBlacklistedEmails')}

@@ -342,12 +342,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('thisApiCallEitherAddEmailsToBlacklist')}

@@ -375,12 +375,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('thisApiCallEitherDeleteEmailsFrom')}

@@ -408,12 +408,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('retrieveTheListsThatTheUserWithEmailHas')}

@@ -433,12 +433,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('retrieveTheListsThatTheNamespaceWith')}

@@ -458,12 +458,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('createsANewListOfSubscribers')}

@@ -530,12 +530,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('deletesAListOfSubscribers')}

@@ -559,12 +559,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('forcesTheRssFeedCheckToImmediatelyCheck')}

@@ -584,12 +584,12 @@ export default class API extends Component {
-
-
- +
+
+
-
-
+
+

{t('sendSingleEmailByTemplateWithGiven')}

diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index e57125707..d2a0ed186 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -44,6 +44,8 @@ MYSQL_PASSWORD=${MYSQL_PASSWORD:-'mailtrain'} WITH_ZONE_MTA=${WITH_ZONE_MTA:-'true'} POOL_NAME=${POOL_NAME:-$(hostname)} LOG_LEVEL=${LOG_LEVEL:-'info'} +ADMIN_PASSWORD=${ADMIN_PASSWORD:-'test'} +ADMIN_ACCESS_TOKEN=${ADMIN_ACCESS_TOKEN:-''} # Warning for users that already rely on the MAILTRAIN_SETTING variable # Can probably be removed in the future. @@ -191,4 +193,6 @@ if [ "$WITH_LDAP" = "true" ]; then fi fi +NODE_ENV=production node setup/docker-entrypoint-db-setup.js "$ADMIN_PASSWORD" "$ADMIN_ACCESS_TOKEN" + NODE_ENV=production node index.js diff --git a/server/setup/docker-entrypoint-db-setup.js b/server/setup/docker-entrypoint-db-setup.js new file mode 100644 index 000000000..731e7fb76 --- /dev/null +++ b/server/setup/docker-entrypoint-db-setup.js @@ -0,0 +1,38 @@ +'use strict'; + +const log = require('../lib/log'); +const dbcheck = require('../lib/dbcheck'); +const knex = require('../lib/knex'); +const {getAdminId} = require("../../shared/users"); +const bluebird = require('bluebird'); +const bcrypt = require('bcrypt-nodejs'); +const bcryptHash = bluebird.promisify(bcrypt.hash.bind(bcrypt)); + +async function init() { + const args = process.argv.slice(2); + + if (args.length !== 2) { + log.error('Usage: NODE_ENV=production node setup/docker-entrypoint-db-setup.js ') + return; + } + + const passwd = args[0]; + const accessToken = args[1]; + + await dbcheck(); + await knex.migrate.latest(); + + + const hashedPasswd = await bcryptHash(passwd, null, null); + await knex('users').where({id: getAdminId()}).update({password: hashedPasswd}); + + if (accessToken !== '') { + await knex('users').where({id: getAdminId()}).update({access_token: accessToken}); + } + + process.exit(0); +} + +init().catch(err => {log.error('', err); process.exit(1); }); + +