mirror of
https://git.cloudron.io/cloudron/minio-app
synced 2025-09-01 23:04:59 +00:00
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
This commit is contained in:
37
minio-credentials
Executable file
37
minio-credentials
Executable file
@@ -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 <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();
|
||||
|
||||
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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user