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:
Girish Ramakrishnan 2020-01-16 14:46:41 -08:00
parent f28d63d0b9
commit e0ce87b291
5 changed files with 48 additions and 25 deletions

View File

@ -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" ]

View File

@ -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**

View File

@ -1,14 +0,0 @@
{
"version": "33",
"credential": {
"accessKey": "admin",
"secretKey": "secretkey"
},
"region": "us-east-1",
"logger": {
"console": {
"enable": true,
"level": "error"
}
}
}

37
minio-credentials Executable file
View 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();
}

View File

@ -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