From 67002a74b5c5cc330cab0b32d5a67b2154ece620 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Thu, 11 Jul 2019 11:43:45 -0700 Subject: [PATCH] Improved Linux install script. --- agents/meshinstall-linux.sh | 21 ++++++++++++--------- package.json | 2 +- views/default-min.handlebars | 2 +- views/default-mobile-min.handlebars | 2 +- webserver.js | 15 ++++++++++++++- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/agents/meshinstall-linux.sh b/agents/meshinstall-linux.sh index c6b5de85..d2224412 100644 --- a/agents/meshinstall-linux.sh +++ b/agents/meshinstall-linux.sh @@ -8,14 +8,17 @@ CheckStartupType() { elif [[ $starttype == 'init' ]]; then # Upstart - if [[ `/sbin/init --version` =~ upstart ]]; then return 2; - # Sysv-init - return 3; - fi + /sbin/init --version && [[ `/sbin/init --version` =~ upstart ]] && return 2 || return 3 + # if [[ `/sbin/init --version` =~ upstart ]]; then return 2; + # Sysv-init + # return 3; + # fi fi return 0; } + + # Add "StartupType=(type)" to .msh file UpdateMshFile() { # Remove all lines that start with "StartupType=" @@ -97,13 +100,13 @@ DownloadAgent() { mkdir -p /usr/local/mesh cd /usr/local/mesh echo "Downloading Mesh agent #$machineid..." - wget $url/meshagents?id=$machineid --no-check-certificate {{{noproxy}}}-O /usr/local/mesh/meshagent + wget $url/meshagents?id=$machineid {{{wgetoptionshttps}}}-O /usr/local/mesh/meshagent || curl {{{curloptionshttps}}}--output /usr/local/mesh/meshagent $url/meshagents?id=$machineid # If it did not work, try again using http if [ $? != 0 ] then url=${url/"https://"/"http://"} - wget $url/meshagents?id=$machineid {{{noproxy}}}-O /usr/local/mesh/meshagent + wget $url/meshagents?id=$machineid {{{wgetoptionshttp}}}-O /usr/local/mesh/meshagent || curl {{{curloptionshttp}}}--output /usr/local/mesh/meshagent $url/meshagents?id=$machineid fi if [ $? -eq 0 ] @@ -111,12 +114,12 @@ DownloadAgent() { echo "Mesh agent downloaded." # TODO: We could check the meshagent sha256 hash, but best to authenticate the server. chmod 755 /usr/local/mesh/meshagent - wget $url/meshsettings?id=$meshid --no-check-certificate {{{noproxy}}}-O /usr/local/mesh/meshagent.msh + wget $url/meshsettings?id=$meshid {{{wgetoptionshttps}}}-O /usr/local/mesh/meshagent.msh || curl {{{curloptionshttps}}}--output /usr/local/mesh/meshagent.msh $url/meshsettings?id=$meshid # If it did not work, try again using http if [ $? -ne 0 ] then - wget $url/meshsettings?id=$meshid {{{noproxy}}}-O /usr/local/mesh/meshagent.msh + wget $url/meshsettings?id=$meshid {{{wgetoptionshttp}}}-O /usr/local/mesh/meshagent.msh || curl {{{curloptionshttp}}}--output /usr/local/mesh/meshagent.msh $url/meshsettings?id=$meshid fi if [ $? -eq 0 ] @@ -145,7 +148,7 @@ DownloadAgent() { elif [ $starttype -eq 3 ] then # initd - wget $url/meshagents?script=2 --no-check-certificate {{{noproxy}}}-O /etc/init.d/meshagent + wget $url/meshagents?script=2 {{{wgetoptionshttps}}}-O /etc/init.d/meshagent || curl {{{curloptionshttps}}}--output /etc/init.d/meshagent $url/meshagents?script=2 chmod +x /etc/init.d/meshagent # creates symlinks for rc.d update-rc.d meshagent defaults diff --git a/package.json b/package.json index 3540be0c..85ce6c49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.7-l", + "version": "0.3.7-n", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default-min.handlebars b/views/default-min.handlebars index 8cbcefa3..3c00286b 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default-mobile-min.handlebars b/views/default-mobile-min.handlebars index edf80fd0..5fc51682 100644 --- a/views/default-mobile-min.handlebars +++ b/views/default-mobile-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}
\ No newline at end of file diff --git a/webserver.js b/webserver.js index ed19cffb..eccd4597 100644 --- a/webserver.js +++ b/webserver.js @@ -2582,7 +2582,20 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { var scriptInfo = obj.parent.meshAgentInstallScripts[req.query.script]; if (scriptInfo == null) { res.sendStatus(404); return; } res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'text/plain', 'Content-Disposition': 'attachment; filename="' + scriptInfo.rname + '"' }); - res.send(scriptInfo.data.split('{{{noproxy}}}').join((domain.agentnoproxy === true)?'--no-proxy ':'')); + var data = scriptInfo.data; + var cmdoptions = { wgetoptionshttp: '', wgetoptionshttps: '', curloptionshttp: '-L ', curloptionshttps: '-L ' } + if (isTrustedCert() == false) { + cmdoptions.wgetoptionshttps += '--no-check-certificate '; + cmdoptions.curloptionshttps += '-k '; + } + if (domain.agentnoproxy === true) { + cmdoptions.wgetoptionshttp += '--no-proxy '; + cmdoptions.wgetoptionshttps += '--no-proxy '; + cmdoptions.curloptionshttp += '--noproxy \'*\' '; + cmdoptions.curloptionshttps += '--noproxy \'*\' '; + } + for (var i in cmdoptions) { data = data.split('{{{' + i + '}}}').join(cmdoptions[i]); } + res.send(data); } else if (req.query.meshcmd != null) { // Send meshcmd for a specific platform back var agentid = parseInt(req.query.meshcmd);