1. Added -E switch to sudo, to preserve proxy settings 2. Added uninstallAgent console command

1. Added -E switch to sudo, to preserve proxy settings 2. Added uninstallAgent console command

Bryan Roe committed Sep 16, 2019 at 11:11 UTC ee6a3fd65784bd2675e77ebe0a20e91d9039dedc
2 files changed +14 -2
agents/meshcore.js
+12
@@ -1863,6 +1863,18 @@ function createMeshCore(agent)
1863 }
1864 break;
1865 }
1866 + case 'uninstallagent':
1867 + var agentName = process.platform == 'win32' ? 'Mesh Agent' : 'meshagent';
1868 + if (!require('service-manager').manager.getService(agentName).isMe())
1869 + {
1870 + response = 'Uininstall failed, this instance is not the service instance';
1871 + }
1872 + else
1873 + {
1874 + var js = "require('service-manager').manager.getService('" + agentName + "').stop(); require('service-manager').manager.uninstallService('" + agentName + "'); process.exit();";
1875 + this.child = require('child_process').execFile(process.execPath, [process.platform == 'win32' ? (process.execPath.split('\\').pop()) : (process.execPath.split('/').pop()), '-b64exec', Buffer.from(js).toString('base64')], { type: 4, detached: true });
1876 + }
1877 + break;
1878 case 'notify': { // Send a notification message to the mesh
1879 if (args['_'].length != 1) {
1880 response = 'Proper usage: notify "message" [--session]'; // Display correct command usage
views/default.handlebars
+2 -2
@@ -3026,7 +3026,7 @@
3026 var portStr = (serverinfo.port == 443)?'':(":" + serverinfo.port);
3027 if ((features & 0x2000) == 0)
3028 {
3029 - Q('agins_linux_area').value = "(wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh https://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
3029 + Q('agins_linux_area').value = "(wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo -E ./meshinstall.sh https://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
3030 Q('agins_linux_area_un').value = "(wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-check-certificate -O ./meshinstall.sh || wget https://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy --no-check-certificate -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n";
3031 }
3032 else
@@ -3041,7 +3041,7 @@
3041 var portStr = (serverinfo.port == 80) ? '' : (":" + serverinfo.port);
3042 if ((features & 0x2000) == 0)
3043 {
3044 - Q('agins_linux_area').value = "(wget http://" + servername + portStr + domainUrl + "meshagents?script=1 -O ./meshinstall.sh || wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh http://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
3044 + Q('agins_linux_area').value = "(wget http://" + servername + portStr + domainUrl + "meshagents?script=1 -O ./meshinstall.sh || wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo -E ./meshinstall.sh http://" + servername + portStr + domainUrlNoSlash + " '" + meshid.split('/')[2] + "'\r\n";
3045 Q('agins_linux_area_un').value = "(wget http://" + servername + portStr + domainUrl + "meshagents?script=1 -O ./meshinstall.sh || wget http://" + servername + portStr + domainUrl + "meshagents?script=1 --no-proxy -O ./meshinstall.sh) && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh uninstall\r\n";
3046 }
3047 else