Name
sn_agent.AgentScripts
Description
No description available
Script
var AgentScripts = Class.create();
AgentScripts.prototype = {
initialize: function() {
// Define per os classifier and package for dev mode
this.osMap = {
'Ubuntu 18.04': {
'c': 'ubuntu-1804_amd64',
'p': 'deb'
},
'Debian 9': {
'c': 'debian-9_amd64',
'p': 'deb'
},
'Debian 8': {
'c': 'debian-8_amd64',
'p': 'deb'
},
'RHEL/CentOS 7': {
'c': 'el7-x86_64',
'p': 'rpm'
},
'macOS': {
'c': 'macos_x64',
'p': 'pkg'
},
'Windows': {
'c': 'windows-x64',
'p': 'msi'
},
'macOS_arm64': {
'c': 'macos_arm64',
'p': 'pkg'
}
};
this.devMode = '' + gs.getProperty('sn_agent.dev_mode', 'false');
if (this.devMode == 'true') {
this.snInstallBaseURL = 'https://install.service-now.com/glide/distribution/builds/package/agent-client-collector/';
this.agentVersion = '' + gs.getProperty('sn_agent.agent_snapshot_version');
this.agentVersion += '-SNAPSHOT';
} else {
this.snInstallBaseURL = 'https://install.service-now.com/glide/distribution/builds/package/app-signed/';
this.agentVersion = '' + gs.getProperty('sn_agent.agent_version');
}
},
getScript: function(name) {
var gr = new GlideRecord('sn_agent_script');
gr.addQuery('name', name);
gr.query();
if (gr.next()) {
var valwjunk = '' + gr.value;
var valnojunk = valwjunk.replace(/\r/g, "");
return valnojunk;
}
return null;
},
// Functions to fetch file name and url
getUrl: function(os) {
var osEntry = this.osMap[os];
if (!osEntry)
return 'Unsupported os: ' + os;
// Windows does not have detached certificate so only getting one URL
if (this.devMode == 'true' || os == 'Windows')
return this.snInstallBaseURL + this.getFile(os);
else {
// When not in dev mode we need to download both signature file and install file
return this.snInstallBaseURL + this.getFile(os) + ' -O ' + this.snInstallBaseURL + this.getInstallFile(os);
}
},
// Function to get only the installer URL for Manual instruction OS link.
getInstallerSpecificUrl: function(os) {
var osEntry = this.osMap[os];
if (!osEntry)
return 'Unsupported os: ' + os;
return this.snInstallBaseURL + this.getInstallFile(os);
},
getFile: function(os) {
var osEntry = this.osMap[os];
if (!osEntry)
return 'Unsupported os: ' + os;
if (this.devMode == 'true' || os == 'Windows')
return this.getInstallFile(os);
else
return 'agent-client-collector-' + this.agentVersion + '-' + osEntry['c'] + '-' + osEntry['p'] + '-' + osEntry['p'] + '.zip';
},
// Need to get specific install file for the case when we validate signature
getInstallFile: function(os) {
var osEntry = this.osMap[os];
if (!osEntry)
return 'Unsupported os: ' + os;
return 'agent-client-collector-' + this.agentVersion + '-' + osEntry['c'] + '.' + osEntry['p'];
},
type: 'AgentScripts'
};
Sys ID
07e1eef773f10010e6c3de0baaf6a70c