3const { execSync } = require('child_process');
4const fs = require('fs');
5const path = require('path');
7const SSH_KEY = `${process.env.HOME}/PreciseITServices.pem`;
8const SSH_USER = 'centos';
9const WHM_HOST = 'precisewebhosting.com.au';
10const OUTPUT_DIR = 'exports/wordpress-inventory';
12if (!fs.existsSync(OUTPUT_DIR)){
13 fs.mkdirSync(OUTPUT_DIR, { recursive: true });
16console.log('========================================');
17console.log('WordPress Quick Inventory');
18console.log('========================================\n');
20// Get list of WordPress sites
21const findCmd = `ssh -i "${SSH_KEY}" ${SSH_USER}@${WHM_HOST} "ls /home/*/public_html/wp-config.php 2>/dev/null"`;
22const wpPaths = execSync(findCmd, { encoding: 'utf8' }).trim().split('\n').filter(p => p);
24console.log(`Found ${wpPaths.length} WordPress sites\n`);
26const sites = wpPaths.map(wpConfigPath => {
27 const wpPath = path.dirname(wpConfigPath);
28 const username = wpPath.split('/')[2];
30 console.log(`ā
${username}`);
36 location: 'public_html'
40const outputFile = path.join(OUTPUT_DIR, 'wordpress_sites.json');
41fs.writeFileSync(outputFile, JSON.stringify(sites, null, 2));
43console.log(`\nā
Inventory saved: ${outputFile}`);
44console.log(`š Ready to migrate ${sites.length} sites\n`);
45console.log('Next step: ./migration-scripts/migrate_wordpress_to_github.sh\n');