can only change password with env vars now

https://docs.min.io/docs/minio-server-configuration-guide.html#credentials
This commit is contained in:
Girish Ramakrishnan 2022-04-30 15:45:21 -07:00
parent aeeb7473b9
commit a2ea852bd4
2 changed files with 1 additions and 42 deletions

View File

@ -11,6 +11,6 @@ RUN wget https://dl.min.io/server/minio/release/linux-amd64/minio.${VERSION} -O
# https://dl.min.io/client/mc/release/linux-amd64/
RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc.${MC_VERSION} -O /app/code/mc && chmod +x /app/code/mc
COPY env.sh minio-credentials start.sh /app/code/
COPY env.sh start.sh /app/code/
CMD [ "/app/code/start.sh" ]

View File

@ -1,41 +0,0 @@
#!/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 <access key> <secret key>');
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();
// https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateAccessKey.html
if (process.argv[4].length < 5) return console.log('secret key must be atleast 5 characters');
if (!/^[\w+=,.@-]+$/.test(process.argv[3])) return console.log('access key has invalid characters');
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. Restart minio app for new credentials to take effect.\n');
} else {
usage();
}