Fix check LXC
This commit is contained in:
22
index.js
22
index.js
@@ -79,7 +79,7 @@ async function vpnConnect(vpnName) {
|
|||||||
});
|
});
|
||||||
const res = await response.json();
|
const res = await response.json();
|
||||||
const ip = res.ip;
|
const ip = res.ip;
|
||||||
consoleLog(`[${host}] VPN connection successfully established to ${vpnName} (IP: ${ip}).`, 'info');
|
await consoleLog(`[${host}] VPN connection successfully established to ${vpnName} (IP: ${ip}).`, 'info');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -127,16 +127,18 @@ async function startBot(accountName) {
|
|||||||
commandSuffix += ' --browser ' + process.env.BOT_BROWSER;
|
commandSuffix += ' --browser ' + process.env.BOT_BROWSER;
|
||||||
}
|
}
|
||||||
|
|
||||||
const containerEnv = fs.readFileSync('/proc/1/environ', 'utf8');
|
|
||||||
const isLXCContainer = containerEnv.includes('container=lxc') || containerEnv.includes('container=lxc-libvirt');
|
|
||||||
|
|
||||||
let commandPrefix = `python ./Microsoft-Rewards-bot/ms_rewards_farmer.py --accounts-file ../accounts/${accountName}.json --dont-check-for-updates --shuffle --session --superfast --on-finish exit --no-webdriver-manager --skip-unusual`;
|
let commandPrefix = `python ./Microsoft-Rewards-bot/ms_rewards_farmer.py --accounts-file ../accounts/${accountName}.json --dont-check-for-updates --shuffle --session --superfast --on-finish exit --no-webdriver-manager --skip-unusual`;
|
||||||
if (isLXCContainer) {
|
|
||||||
commandPrefix += ' --virtual-display';
|
|
||||||
}
|
|
||||||
|
|
||||||
consoleLog(`[${host}] Script started for ${accountName}`);
|
consoleLog(`[${host}] Script started for ${accountName}`);
|
||||||
|
|
||||||
|
if (isRootUser()) {
|
||||||
|
console.log('The user is root.');
|
||||||
|
const containerEnv = fs.readFileSync('/proc/1/environ', 'utf8');
|
||||||
|
const isLXCContainer = containerEnv.includes('container=lxc') || containerEnv.includes('container=lxc-libvirt');
|
||||||
|
if (isLXCContainer) {
|
||||||
|
commandPrefix += ' --virtual-display';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
execSync(`timeout 150m bash -c "${commandPrefix} ${commandSuffix}; exit"`, { stdio: 'inherit', shell: '/bin/bash' });
|
execSync(`timeout 150m bash -c "${commandPrefix} ${commandSuffix}; exit"`, { stdio: 'inherit', shell: '/bin/bash' });
|
||||||
}
|
}
|
||||||
@@ -155,6 +157,10 @@ function sleep(ms) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isRootUser() {
|
||||||
|
return process.getuid && process.getuid() === 0;
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await checkUpdate();
|
await checkUpdate();
|
||||||
const vpns = execSync('nmcli connection show | awk \'/vpn/ {print $1}\'').toString().trim().split('\n');
|
const vpns = execSync('nmcli connection show | awk \'/vpn/ {print $1}\'').toString().trim().split('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user