88 lines
2.7 KiB
JavaScript
88 lines
2.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const { spawn } = require('child_process');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
console.log('🔍 Checking MinIO Client installation...');
|
|
|
|
function checkMinio() {
|
|
return new Promise((resolve) => {
|
|
const minio = spawn('mc', ['--version'], { stdio: 'pipe' });
|
|
|
|
let output = '';
|
|
let error = '';
|
|
|
|
minio.stdout.on('data', (data) => {
|
|
output += data.toString();
|
|
});
|
|
|
|
minio.stderr.on('data', (data) => {
|
|
error += data.toString();
|
|
});
|
|
|
|
minio.on('close', (code) => {
|
|
if (code === 0) {
|
|
const versionMatch = output.match(/mc version (RELEASE\.\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}Z)/);
|
|
if (versionMatch) {
|
|
console.log(`✅ MinIO Client is installed: ${versionMatch[1]}`);
|
|
resolve(true);
|
|
} else {
|
|
console.log('✅ MinIO Client is installed (version unknown)');
|
|
resolve(true);
|
|
}
|
|
} else {
|
|
console.log('❌ MinIO Client is not installed or not in PATH');
|
|
resolve(false);
|
|
}
|
|
});
|
|
|
|
minio.on('error', () => {
|
|
console.log('❌ MinIO Client is not installed or not in PATH');
|
|
resolve(false);
|
|
});
|
|
});
|
|
}
|
|
|
|
function showInstallInstructions() {
|
|
console.log('\n📥 MinIO Client Installation Instructions:');
|
|
console.log('==========================================');
|
|
|
|
if (process.platform === 'darwin') {
|
|
console.log('\n🍎 macOS:');
|
|
console.log(' brew install minio/stable/mc');
|
|
console.log(' # Or download from: https://min.io/download');
|
|
} else if (process.platform === 'win32') {
|
|
console.log('\n🪟 Windows:');
|
|
console.log(' # Download from: https://min.io/download');
|
|
console.log(' # Extract and add to PATH');
|
|
} else if (process.platform === 'linux') {
|
|
console.log('\n🐧 Linux:');
|
|
console.log(' # Ubuntu/Debian:');
|
|
console.log(' wget https://dl.min.io/client/mc/release/linux-amd64/mc');
|
|
console.log(' chmod +x mc');
|
|
console.log(' sudo mv mc /usr/local/bin/');
|
|
console.log(' # Or: curl https://dl.min.io/client/mc/release/linux-amd64/mc -o mc && chmod +x mc && sudo mv mc /usr/local/bin/');
|
|
}
|
|
|
|
console.log('\n📚 After installation:');
|
|
console.log(' 1. Run: mc alias set garage https://your-garage-endpoint access-key secret-key');
|
|
console.log(' 2. Test with: mc ls garage/bucket-name');
|
|
console.log('\n🔗 Documentation: https://min.io/docs/minio/linux/reference/minio-mc.html');
|
|
}
|
|
|
|
async function main() {
|
|
const isInstalled = await checkMinio();
|
|
|
|
if (!isInstalled) {
|
|
showInstallInstructions();
|
|
process.exit(1);
|
|
} else {
|
|
console.log('\n🎉 MinIO Client is ready to use!');
|
|
console.log('💡 You can now run: npm start');
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|
|
|