Improved Linux install script.

This commit is contained in:
Ylian Saint-Hilaire 2019-07-11 11:43:45 -07:00
parent abe8e97f24
commit 67002a74b5
5 changed files with 29 additions and 13 deletions

View File

@ -8,14 +8,17 @@ CheckStartupType() {
elif [[ $starttype == 'init' ]];
then
# Upstart
if [[ `/sbin/init --version` =~ upstart ]]; then return 2;
/sbin/init --version && [[ `/sbin/init --version` =~ upstart ]] && return 2 || return 3
# if [[ `/sbin/init --version` =~ upstart ]]; then return 2;
# Sysv-init
return 3;
fi
# 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

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.3.7-l",
"version": "0.3.7-n",
"keywords": [
"Remote Management",
"Intel AMT",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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);