90 lines
2.6 KiB
JavaScript
90 lines
2.6 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
const { spawn } = require('child_process');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
console.log('🔍 Checking rclone installation...');
|
|
|
|
function checkRclone() {
|
|
return new Promise((resolve) => {
|
|
const rclone = spawn('rclone', ['version'], { stdio: 'pipe' });
|
|
|
|
let output = '';
|
|
let error = '';
|
|
|
|
rclone.stdout.on('data', (data) => {
|
|
output += data.toString();
|
|
});
|
|
|
|
rclone.stderr.on('data', (data) => {
|
|
error += data.toString();
|
|
});
|
|
|
|
rclone.on('close', (code) => {
|
|
if (code === 0) {
|
|
const versionMatch = output.match(/rclone v(\d+\.\d+\.\d+)/);
|
|
if (versionMatch) {
|
|
console.log(`✅ Rclone is installed: ${versionMatch[1]}`);
|
|
resolve(true);
|
|
} else {
|
|
console.log('✅ Rclone is installed (version unknown)');
|
|
resolve(true);
|
|
}
|
|
} else {
|
|
console.log('❌ Rclone is not installed or not in PATH');
|
|
resolve(false);
|
|
}
|
|
});
|
|
|
|
rclone.on('error', () => {
|
|
console.log('❌ Rclone is not installed or not in PATH');
|
|
resolve(false);
|
|
});
|
|
});
|
|
}
|
|
|
|
function showInstallInstructions() {
|
|
console.log('\n📥 Rclone Installation Instructions:');
|
|
console.log('=====================================');
|
|
|
|
if (process.platform === 'darwin') {
|
|
console.log('\n🍎 macOS:');
|
|
console.log(' brew install rclone');
|
|
console.log(' # Or download from: https://rclone.org/downloads/');
|
|
} else if (process.platform === 'win32') {
|
|
console.log('\n🪟 Windows:');
|
|
console.log(' # Download from: https://rclone.org/downloads/');
|
|
console.log(' # Extract and add to PATH');
|
|
} else if (process.platform === 'linux') {
|
|
console.log('\n🐧 Linux:');
|
|
console.log(' # Ubuntu/Debian:');
|
|
console.log(' curl https://rclone.org/install.sh | sudo bash');
|
|
console.log(' # Or: sudo apt install rclone');
|
|
console.log(' # CentOS/RHEL:');
|
|
console.log(' sudo yum install rclone');
|
|
}
|
|
|
|
console.log('\n📚 After installation:');
|
|
console.log(' 1. Run: rclone config');
|
|
console.log(' 2. Create a new remote named "music"');
|
|
console.log(' 3. Choose S3 provider');
|
|
console.log(' 4. Enter your Garage S3 credentials');
|
|
console.log('\n🔗 Documentation: https://rclone.org/s3/');
|
|
}
|
|
|
|
async function main() {
|
|
const isInstalled = await checkRclone();
|
|
|
|
if (!isInstalled) {
|
|
showInstallInstructions();
|
|
process.exit(1);
|
|
} else {
|
|
console.log('\n🎉 Rclone is ready to use!');
|
|
console.log('💡 You can now run: npm start');
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|
|
|