33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
const { Client } = require('ssh2');
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 删除容器内默认index.html ===');
|
|
|
|
conn.exec('docker exec huishou rm -f /usr/share/nginx/html/index.html', (err, stream) => {
|
|
if (err) { console.log('ERR:', err); }
|
|
stream.on('close', () => {
|
|
console.log('默认index.html已删除');
|
|
|
|
console.log('\n=== 验证容器内目录 ===');
|
|
conn.exec('docker exec huishou ls -la /usr/share/nginx/html/', (err2, stream2) => {
|
|
if (err2) { console.log('ERR2:', err2); conn.end(); return; }
|
|
stream2.on('data', (d) => console.log(d.toString()));
|
|
stream2.on('close', () => {
|
|
console.log('\n=== 测试网站 ===');
|
|
conn.exec('curl -s http://127.0.0.1:4001/ | head -3', (err3, stream3) => {
|
|
if (err3) { console.log('ERR3:', err3); conn.end(); return; }
|
|
stream3.on('data', (d) => console.log(d.toString()));
|
|
stream3.on('close', () => {
|
|
console.log('\n✅ 修复完成!');
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' }); |