Fix check LXC

This commit is contained in:
2023-06-25 15:02:20 +02:00
parent 95f1119315
commit 014ca1b4f4

View File

@@ -79,7 +79,7 @@ async function vpnConnect(vpnName) {
});
const res = await response.json();
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;
}
}
@@ -127,16 +127,18 @@ async function startBot(accountName) {
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`;
if (isLXCContainer) {
commandPrefix += ' --virtual-display';
}
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 {
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() {
await checkUpdate();
const vpns = execSync('nmcli connection show | awk \'/vpn/ {print $1}\'').toString().trim().split('\n');