forked from zensquare/evtsys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.nsi
177 lines (130 loc) · 3.46 KB
/
installer.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
!include nsDialogs.nsh
!include LogicLib.nsh
!include x64.nsh
name "EvtSys - Syslog Collector"
outfile "EvtSys Installer.exe"
RequestExecutionLevel "admin"
Var CDialog
Var CUseDHCP
Var CHost
Var CPort
Var CTag
Var CFacility
Var CLevel
Var UseDHCP
Var Host
Var Port
Var Tag
Var Facility
Var Level
Var Flags
PageEx license
LicenseData license
PageExEnd
Page directory
Page custom nsConfigureHosts nsConfigureHostsClose
Page custom nsConfigureLogging nsConfigureLoggingClose
Page instfiles
ShowInstDetails show
ShowUninstDetails show
Section "Stop Service"
ExecWait 'net stop EvtSys'
SectionEnd
Section "Install EvtSys Service"
SetOutPath $INSTDIR
${If} ${RunningX64}
File Release\x64\evtsys.exe
${Else}
File Release\x86\evtsys.exe
${EndIf}
File evtsys.cfg
ExecWait '"$INSTDIR\evtsys.exe" -u'
WriteUninstaller $INSTDIR\uninstaller.exe
${If} $UseDHCP == ${BST_CHECKED}
StrCpy $Flags "-q 1 "
${Else}
StrCpy $Flags '-h "$Host" -p $Port '
${EndIf}
StrCmp $Tag "" +2
StrCpy $Flags "$Flags -t $Tag "
StrCmp $Tag "" +2
StrCpy $Flags "$Flags -l $Level "
StrCmp $Tag "" +2
StrCpy $Flags "$Flags -f $Facility "
ExecWait '"$INSTDIR\evtsys.exe" -i $Flags' $0
${If} $0 != 0
${EndIf}
ExecWait 'net start EvtSys' $0
SectionEnd
Section "un.Uninstall EvtSys Service"
ExecWait 'net stop EvtSys'
ExecWait '"$INSTDIR\evtsys.exe" -u'
Delete $INSTDIR\uninstaller.exe
Delete $INSTDIR\evtsys.exe
SectionEnd
Section "un.Uninstall Complete"
Delete $INSTDIR\evtsys.cfg
RMDir $INSTDIR
SectionEnd
Function .onInit
StrCpy $INSTDIR $programfiles32\evtsys
${If} ${RunningX64}
StrCpy $INSTDIR $programfiles64\evtsys
${EndIf}
FunctionEnd
Function nsConfigureHosts
nsDialogs::Create 1018
Pop $CDialog
${If} $CDialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Configure logging hosts"
${NSD_CreateLabel} 0 15u 60u 12u "Conf VIA DHCP"
${NSD_CreateCheckBox} 60u 15u -50u 12u ""
Pop $CUseDHCP
${NSD_CreateHLine} 0u 32u 100% 1u ""
${NSD_CreateLabel} 0 40u 60u 12u "Target Hosts:"
${NSD_CreateText} 60u 40u -60u 12u ""
Pop $CHost
${NSD_CreateLabel} 60u 55u -60u 12u "Separate multiple hosts with `;` "
${NSD_CreateLabel} 0 70u 60u 12u "Syslog Port:"
${NSD_CreateText} 60u 70u -60u 12u "514"
Pop $CPort
nsDialogs::Show
FunctionEnd
Function nsConfigureHostsClose
${NSD_GetState} $CUseDHCP $UseDHCP
${NSD_GetText} $CHost $Host
${NSD_GetText} $CPort $Port
${If} $UseDHCP != ${BST_CHECKED}
${IF} $Host == ""
MessageBox MB_OK "A Syslog host is required"
Abort
${EndIf}
${EndIf}
FunctionEnd
Function nsConfigureLogging
nsDialogs::Create 1018
Pop $CDialog
${If} $CDialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Optional Logging Settings"
${NSD_CreateLabel} 0 15u 60u 12u "Facility"
${NSD_CreateText} 60u 15u -50u 12u ""
Pop $CFacility
${NSD_CreateLabel} 0 30u 60u 12u "Level:"
${NSD_CreateNumber} 60u 30u -60u 12u ""
Pop $CLevel
${NSD_CreateLabel} 60u 45u -60u 12u "0=All/Verbose, 1=Critical, 2=Error, 3=Warning, 4=Info"
${NSD_CreateLabel} 0 60u 60u 12u "Tag:"
${NSD_CreateText} 60u 60u -60u 12u ""
Pop $CTag
${NSD_CreateLabel} 60u 75u -60u 12u "Include tag as program field in syslog message"
nsDialogs::Show
FunctionEnd
Function nsConfigureLoggingClose
${NSD_GetText} $CTag $Tag
${NSD_GetText} $CLevel $Level
${NSD_GetText} $CFacility $Facility
FunctionEnd