From e0ce87b29186d00ada913820b7249c34d107208e Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 16 Jan 2020 14:46:41 -0800 Subject: [PATCH] config dir is dead minio now stores the config as part of the storage system under .minio.sys when passed config dir, it merely "migrates" config.json to the new system and renames config.json to config.json.deprecated --- Dockerfile | 2 +- POSTINSTALL.md | 7 +++++-- config.json | 14 -------------- minio-credentials | 37 +++++++++++++++++++++++++++++++++++++ start.sh | 13 +++++-------- 5 files changed, 48 insertions(+), 25 deletions(-) delete mode 100644 config.json create mode 100755 minio-credentials diff --git a/Dockerfile b/Dockerfile index 46316aa..be650d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN mkdir -p /app/code \ WORKDIR /app/code -ADD config.json /app/code/config.json ADD start.sh /app/code/start.sh +ADD minio-credentials /app/code/minio-credentials CMD [ "/app/code/start.sh" ] diff --git a/POSTINSTALL.md b/POSTINSTALL.md index f651585..4bfa1ec 100644 --- a/POSTINSTALL.md +++ b/POSTINSTALL.md @@ -2,7 +2,10 @@ This application does not integrate with Cloudron authentication. Please use the following credentials to login: -* AccessKey: `admin` -* SecretKey: `secretkey` +* AccessKey: `minioadmin` +* SecretKey: `minioadmin` + +See the [documentation](https://cloudron.io/documentation/apps/minio/) to change +the admin credentials. **Please change the credentials immediately** diff --git a/config.json b/config.json deleted file mode 100644 index 0f53336..0000000 --- a/config.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "version": "33", - "credential": { - "accessKey": "admin", - "secretKey": "secretkey" - }, - "region": "us-east-1", - "logger": { - "console": { - "enable": true, - "level": "error" - } - } -} diff --git a/minio-credentials b/minio-credentials new file mode 100755 index 0000000..6dedaef --- /dev/null +++ b/minio-credentials @@ -0,0 +1,37 @@ +#!/usr/bin/env node + +'use strict'; + +const fs = require('fs'); + +const MINIO_CONFIG = '/app/data/data/.minio.sys/config/config.json'; + +function usage() { + console.log('Usage:\n'); + console.log('\tminio-credentials get'); + console.log('\tminio-credentials set '); + console.log(); +} + +let config = JSON.parse(fs.readFileSync(MINIO_CONFIG, 'utf8')); +let adminCredentials = config['credentials']['_']; +let accessKey = adminCredentials.filter(kv => kv.key === 'access_key')[0]; +let secretKey = adminCredentials.filter(kv => kv.key === 'secret_key')[0]; + +if (process.argv[2] === 'get') { + console.log('Access Key:', accessKey.value); + console.log('Secret Key:', secretKey.value); +} else if (process.argv[2] === 'set') { + if (process.argv.length !== 5) return usage(); + + accessKey.value = process.argv[3]; + if (process.argv[4].length < 8) return console.log('secret key must be atleast 8 characters'); + + secretKey.value = process.argv[4]; + + fs.writeFileSync(MINIO_CONFIG, JSON.stringify(config), 'utf8'); + console.log('Credentials updated\n. Restart minio app for new credentials to take effect.\n'); +} else { + usage(); +} + diff --git a/start.sh b/start.sh index 2dd5863..8024448 100755 --- a/start.sh +++ b/start.sh @@ -2,16 +2,13 @@ set -eu -mkdir -p /app/data/data /app/data/certs /app/data/config +mkdir -p /app/data/data /run/minio/config /run/minio/certs -if ! [ -f /app/data/config/config.json ]; then - cp /app/code/config.json /app/data/config/config.json -fi - -echo "Changing ownership" +echo "==> Changing ownership" chown -R cloudron:cloudron /app/data -echo "Starting minio" -exec /usr/local/bin/gosu cloudron:cloudron /app/code/minio server --config-dir /app/data/config --certs-dir /app/data/certs --address :8000 /app/data/data +# the --config-dir is deprecated and not used. but without it, minio will try to create $HOME/.minio :/ same for --certs-dir +echo "==> Starting minio" +exec /usr/local/bin/gosu cloudron:cloudron /app/code/minio --certs-dir /run/minio/certs --config-dir /run/minio/config --quiet server --address :8000 /app/data/data