Commit 9f847963 by Rinat K. Nugaev

Added creating log dir and download from any url

parent 384d427c
......@@ -56,9 +56,11 @@ Break
}
#Getting and defining some vars
#$urldistzabbix where your zabbix_agent archive
$urldistzabbix = "https://support.nugaev.net/files/distrib/zabbix_agent.zip"
#$urldistzabbix = "https://support.nugaev.net/files/distrib/zabbix_agent.zip"
$urldistzabbix = "https://www.zabbix.com/downloads/3.4.6/zabbix_agents_3.4.6.win.zip"
#$temparchivedir where you'll download zabbix_agent archive
$temparchivedir = $env:TEMP
$temparchive = "$env:TEMP\zabbix_agent.zip"
#$PathZabbix folder where you'll install zabbix agent
$PathZabbix = ${env:ProgramFiles} + '\Zabbix'
#$ZabbixConf zabbix agent config
......@@ -70,7 +72,7 @@ $monserverip = (Test-Connection -ComputerName monitoring.nugaev.net -count 1).IP
#Downloading and unzip zabbix agent
Try
{
Start-BitsTransfer -Source $urldistzabbix -Destination $temparchivedir -ErrorAction stop
Start-BitsTransfer -Source $urldistzabbix -Destination $temparchive -ErrorAction stop
}
Catch
{
......@@ -89,8 +91,10 @@ function Unzip
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
Unzip $temparchive\zabbix_agent.zip $PathZabbix
Remove-Item -Force $temparchive\zabbix_agent.zip
Unzip $temparchive $PathZabbix
Remove-Item -Force $temparchive
#Creating zabbix agent log folder
New-Item -ItemType directory -Path $PathZabbix\log
#Getting computer hostname for config file
$HostnameFull ="$env:computername.$env:userdnsdomain"
#Removing dot from end of the hostname (this behavior possible if computer is not domain joined)
......@@ -120,12 +124,14 @@ else
#Defining zabbix install command. It depends on $OsArch variable
$ZabbixInstallCommand = "`"C:\Program Files\Zabbix\bin\$OsArch\zabbix_agentd.exe`" --config `"C:\Program Files\Zabbix\conf\zabbix_agentd.conf`""
$ZabbixInstallCommand = `
"`"C:\Program Files\Zabbix\bin\$OsArch\zabbix_agentd.exe`" --config `"C:\Program Files\Zabbix\conf\zabbix_agentd.conf`""
#Installing Zabbix Service
Try
{
New-Service -Name "Zabbix Agent" -BinaryPathName $ZabbixInstallCommand -DisplayName "Zabbix Agent" -Description "Provides Monitoring" -StartupType "Automatic"
New-Service -Name "Zabbix Agent" -BinaryPathName $ZabbixInstallCommand `
-DisplayName "Zabbix Agent" -Description "Provides Monitoring" -StartupType "Automatic"
}
Catch
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment