1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-21 10:43:36 +00:00

1. Added Wayland helper

2. Fixed agent customization support for Docker/PseudoService
This commit is contained in:
Bryan Roe
2023-01-20 13:10:05 -08:00
parent 7ea36ae572
commit aa4590ce53
3 changed files with 178 additions and 16 deletions

View File

@@ -120,6 +120,126 @@ if (process.platform == 'linux')
return (uu);
}
function waylandStatus()
{
var wayland = true;
if (require('fs').existsSync('/etc/gdm/custom.conf'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("cat /etc/gdm/custom.conf | grep WaylandEnable= | tr '\\n' '`' | awk -F'`' '");
child.stdin.write('{');
child.stdin.write(' wayland=1;');
child.stdin.write(' for(n=1;n<NF;++n) ');
child.stdin.write(' {');
child.stdin.write(' if($n~/^#/) { continue; }')
child.stdin.write(' gsub(/ /, "", $n);');
child.stdin.write(' if($n~/^WaylandEnable=/)');
child.stdin.write(' {');
child.stdin.write(' split($n, dummy, "WaylandEnable=");');
child.stdin.write(' if(dummy[2]=="false")');
child.stdin.write(' {');
child.stdin.write(' wayland=0;');
child.stdin.write(' }');
child.stdin.write(' break;');
child.stdin.write(' }');
child.stdin.write(' }');
child.stdin.write(' print wayland;');
child.stdin.write("}'\nexit\n");
child.waitExit();
if (child.stdout.str.trim() == '0')
{
wayland = false;
}
}
if (require('fs').existsSync('/etc/gdm3/custom.conf'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write("cat /etc/gdm3/custom.conf | grep WaylandEnable= | tr '\\n' '`' | awk -F'`' '");
child.stdin.write('{');
child.stdin.write(' wayland=1;');
child.stdin.write(' for(n=1;n<NF;++n) ');
child.stdin.write(' {');
child.stdin.write(' if($n~/^#/) { continue; }')
child.stdin.write(' gsub(/ /, "", $n);');
child.stdin.write(' if($n~/^WaylandEnable=/)');
child.stdin.write(' {');
child.stdin.write(' split($n, dummy, "WaylandEnable=");');
child.stdin.write(' if(dummy[2]=="false")');
child.stdin.write(' {');
child.stdin.write(' wayland=0;');
child.stdin.write(' }');
child.stdin.write(' break;');
child.stdin.write(' }');
child.stdin.write(' }');
child.stdin.write(' print wayland;');
child.stdin.write("}'\nexit\n");
child.waitExit();
if (child.stdout.str.trim() == '0')
{
wayland = false;
}
}
return (wayland);
}
function disableWayland()
{
if (waylandStatus())
{
if (require('fs').existsSync('/etc/gdm/custom.conf'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('sed "s/#WaylandEnable=false/WaylandEnable=false/g" /etc/gdm/custom.conf > /etc/gdm/custom_2.conf\n');
child.stdin.write("mv /etc/gdm/custom_2.conf /etc/gdm/custom.conf\n");
child.stdin.write("\nexit\n");
child.waitExit();
}
if (require('fs').existsSync('/etc/gdm3/custom.conf'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('sed "s/#WaylandEnable=false/WaylandEnable=false/g" /etc/gdm3/custom.conf > /etc/gdm3/custom_2.conf\n');
child.stdin.write("mv /etc/gdm3/custom_2.conf /etc/gdm3/custom.conf\n");
child.stdin.write("\nexit\n");
child.waitExit();
}
}
}
function enableWayland()
{
if (!waylandStatus())
{
if (require('fs').existsSync('/etc/gdm/custom.conf'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('sed "s/WaylandEnable=false/#WaylandEnable=false/g" /etc/gdm/custom.conf > /etc/gdm/custom_2.conf\n');
child.stdin.write("mv /etc/gdm/custom_2.conf /etc/gdm/custom.conf\n");
child.stdin.write("\nexit\n");
child.waitExit();
}
if (require('fs').existsSync('/etc/gdm3/custom.conf'))
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
child.stdin.write('sed "s/WaylandEnable=false/#WaylandEnable=false/g" /etc/gdm3/custom.conf > /etc/gdm3/custom_2.conf\n');
child.stdin.write("mv /etc/gdm3/custom_2.conf /etc/gdm3/custom.conf\n");
child.stdin.write("\nexit\n");
child.waitExit();
}
}
}
function waylandDM()
{
if (require('fs').existsSync('/etc/gdm/custom.conf')) { return ('gdm'); }
if (require('fs').existsSync('/etc/gdm3/custom.conf')) { return ('gdm3'); }
return ('');
}
module.exports =
{
createVirtualSession: spawnVirtualSession,
@@ -127,6 +247,10 @@ if (process.platform == 'linux')
users: getUsers,
loginUids: loginUids,
allowed: allowedUIDs,
waylandStatus: waylandStatus,
disableWayland: disableWayland,
enableWayland: enableWayland,
waylandDM: waylandDM
}
}
else