1; UnrealIRCd Win32 Installation Script for My Inno Setup Extensions
2; Requires Inno Setup 4.1.6 or later
3
4;#define USE_SSL
5; Uncomment the above line to package an SSL build
6#define USE_ZIP
7; Uncomment the above line to package with ZIP support
8#define USE_CURL
9; Uncomment the above line to package with libcurl support
10
11
12[Setup]
13AppName=UnrealIRCd
14AppVerName=UnrealIRCd3.2.10.7
15AppPublisher=UnrealIRCd Team
16AppPublisherURL=http://www.unrealircd.com
17AppSupportURL=http://www.unrealircd.com
18AppUpdatesURL=http://www.unrealircd.com
19AppMutex=UnrealMutex,Global\UnrealMutex
20DefaultDirName={pf}\Unreal3.2
21DefaultGroupName=UnrealIRCd
22AllowNoIcons=yes
23#ifndef USE_SSL
24LicenseFile=.\gpl.rtf
25#else
26LicenseFile=.\gplplusssl.rtf
27#endif
28Compression=lzma
29SolidCompression=true
30MinVersion=5.0
31OutputDir=../../
32
33; !!! Make sure to update SSL validation (WizardForm.TasksList.Checked[9]) if tasks are added/removed !!!
34[Tasks]
35Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional icons:"
36Name: "quicklaunchicon"; Description: "Create a &Quick Launch icon"; GroupDescription: "Additional icons:"; Flags: unchecked
37Name: "installservice"; Description: "Install as a &service (not for beginners)"; GroupDescription: "Service support:"; Flags: unchecked; MinVersion: 0,4.0
38Name: "installservice/startboot"; Description: "S&tart UnrealIRCd when Windows starts"; GroupDescription: "Service support:"; MinVersion: 0,4.0; Flags: exclusive unchecked
39Name: "installservice/startdemand"; Description: "Start UnrealIRCd on &request"; GroupDescription: "Service support:"; MinVersion: 0,4.0; Flags: exclusive unchecked
40Name: "installservice/crashrestart"; Description: "Restart UnrealIRCd if it &crashes"; GroupDescription: "Service support:"; Flags: unchecked; MinVersion: 0,5.0;
41#ifdef USE_SSL
42Name: "makecert"; Description: "&Create certificate"; GroupDescription: "SSL options:";
43Name: "enccert"; Description: "&Encrypt certificate"; GroupDescription: "SSL options:"; Flags: unchecked;
44#endif
45Name: "fixperm"; Description: "Make Unreal folder writable by current user";
46
47[Files]
48Source: "..\..\wircd.exe"; DestDir: "{app}"; Flags: ignoreversion
49Source: "..\..\WIRCD.pdb"; DestDir: "{app}"; Flags: ignoreversion
50Source: "..\..\.CHANGES.NEW"; DestDir: "{app}"; DestName: "CHANGES.NEW.txt";Flags: ignoreversion
51Source: "..\..\.CONFIG.RANT"; DestDir: "{app}"; DestName: "CONFIG.RANT.txt"; Flags: ignoreversion
52Source: "..\..\.RELEASE.NOTES"; DestDir: "{app}"; DestName: "RELEASE.NOTES.txt"; Flags: ignoreversion
53Source: "..\..\.SICI"; DestDir: "{app}"; DestName: "SICI.txt"; Flags: ignoreversion
54Source: "..\..\badwords.channel.conf"; DestDir: "{app}"; Flags: ignoreversion
55Source: "..\..\badwords.message.conf"; DestDir: "{app}"; Flags: ignoreversion
56Source: "..\..\badwords.quit.conf"; DestDir: "{app}"; Flags: ignoreversion
57Source: "..\..\spamfilter.conf"; DestDir: "{app}"; Flags: ignoreversion
58Source: "..\..\dccallow.conf"; DestDir: "{app}"; Flags: ignoreversion
59Source: "..\..\Changes"; DestDir: "{app}"; DestName: "Changes.txt"; Flags: ignoreversion
60Source: "..\..\Changes.old"; DestDir: "{app}"; DestName: "Changes.old.txt"; Flags: ignoreversion
61Source: "..\..\Donation"; DestDir: "{app}"; DestName: "Donation.txt"; Flags: ignoreversion
62Source: "..\..\help.conf"; DestDir: "{app}"; Flags: ignoreversion
63Source: "..\..\LICENSE"; DestDir: "{app}"; DestName: "LICENSE.txt"; Flags: ignoreversion
64Source: "..\..\Unreal.nfo"; DestDir: "{app}"; Flags: ignoreversion
65Source: "..\..\doc\*.*"; DestDir: "{app}\doc"; Flags: ignoreversion
66Source: "..\..\doc\technical\*.*"; DestDir: "{app}\doc\technical"; Flags: ignoreversion
67Source: "..\..\aliases\*"; DestDir: "{app}\aliases"; Flags: ignoreversion
68Source: "..\..\unreal.exe"; DestDir: "{app}"; Flags: ignoreversion; MinVersion: 0,4.0
69Source: "..\modules\*.dll"; DestDir: "{app}\modules"; Flags: ignoreversion
70Source: "c:\dev\tre\win32\release\tre.dll"; DestDir: "{app}"; Flags: ignoreversion
71Source: "C:\dev\c-ares\msvc90\cares\dll-release\cares.dll"; DestDir: "{app}"; Flags: ignoreversion
72#ifdef USE_SSL
73Source: "c:\openssl\bin\openssl.exe"; DestDir: "{app}"; Flags: ignoreversion
74Source: "c:\openssl\bin\ssleay32.dll"; DestDir: "{app}"; Flags: ignoreversion
75Source: "c:\openssl\bin\libeay32.dll"; DestDir: "{app}"; Flags: ignoreversion
76Source: "c:\dev\setacl.exe"; DestDir: "{app}\tmp"; Flags: ignoreversion
77Source: ".\makecert.bat"; DestDir: "{app}"; Flags: ignoreversion
78Source: ".\encpem.bat"; DestDir: "{app}"; Flags: ignoreversion
79Source: "..\ssl.cnf"; DestDir: "{app}"; Flags: ignoreversion
80#endif
81#ifdef USE_ZIP
82Source: "c:\dev\zlib\zlibwapi.dll"; DestDir: "{app}"; Flags: ignoreversion
83#endif
84#ifdef USE_SSL
85#ifdef USE_CURL
86; curl with ssl support
87Source: "c:\dev\curl-ssl\builds\libcurl-vc-x86-release-dll-sspi\bin\libcurl.dll"; DestDir: "{app}"; Flags: ignoreversion
88Source: "..\..\curl-ca-bundle.crt"; DestDir: "{app}"; Flags: ignoreversion
89#endif
90#else
91#ifdef USE_CURL
92; curl without ssl support
93Source: "C:\dev\curl\builds\libcurl-vc-x86-release-dll-sspi-spnego\bin\libcurl.dll"; DestDir: "{app}"; Flags: ignoreversion
94#endif
95#endif
96;Source: "..\..\..\dbghelp.dll"; DestDir: "{app}"; Flags: ignoreversion
97
98[Dirs]
99Name: "{app}\tmp"
100
101[UninstallDelete]
102Type: files; Name: "{app}\DbgHelp.Dll"
103
104[Code]
105var
106  uninstaller: String;
107  ErrorCode: Integer;
108
109//*********************************************************************************
110// This is where all starts.
111//*********************************************************************************
112function InitializeSetup(): Boolean;
113var
114  d: Integer;
115begin
116  d := StrToInt(GetDateTimeString('yyyymm',#0,#0));
117  if (d > 201512) then
118  begin
119    MsgBox('You are installing the old UnrealIRCd 3.2.x stable series. This branch will receive security fixes only until December 31, 2016. ' +
120           'After that date, all support for the UnrealIRCd 3.2.x series will stop. ' +
121           'Please consider upgrading to UnrealIRCd 4. See https://www.unrealircd.org/docs/UnrealIRCd_3.2.x_deprecated', mbInformation, MB_OK);
122    if (d > 201603) then
123    begin
124      ShellExec('open', 'https://www.unrealircd.org/docs/UnrealIRCd_3.2.x_deprecated', '', '', SW_SHOWNORMAL,ewNoWait,ErrorCode);
125    end;
126  end;
127	Result := true;
128    if ((not RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2F73A7B2-E50E-39A6-9ABC-EF89E4C62E36}'))
129         and (not RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{E824E81C-80A4-3DFF-B5F9-4842A9FF5F7F}'))
130         and (not RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{E7D4E834-93EB-351F-B8FB-82CDAE623003}'))
131         and (not RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3D6AD258-61EA-35F5-812C-B7A02152996E}'))
132         and (not RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{BD95A8CD-1D9F-35AD-981A-3E7925026EBB}'))
133        ) then
134    begin
135      MsgBox('UnrealIRCd requires the Microsoft Visual C++ Redistributable for Visual Studio 2012 to be installed.' #13 +
136             'After you click OK you will be taken to a download page. There, choose Download -> choose the vcredist_x86 version (last of 3 choices). Then download and install it.', mbInformation, MB_OK);
137      ShellExec('open', 'http://www.microsoft.com/en-us/download/details.aspx?id=30679', '', '', SW_SHOWNORMAL,ewNoWait,ErrorCode);
138      MsgBox('Click OK once you have installed the Microsoft Visual C++ Redistributable for Visual Studio 2012 (vcredist_x86) to continue the UnrealIRCd installer', mbInformation, MB_OK);
139
140		end;
141end;
142
143function NextButtonClick(CurPage: Integer): Boolean;
144
145var
146  hWnd: Integer;
147  ResultCode: Integer;
148  ResultXP: boolean;
149  Result2003: boolean;
150  Res: Integer;
151begin
152
153  Result := true;
154  ResultXP := true;
155  Result2003 := true;
156
157  // Prevent the user from selecting both 'Install as service' and 'Encrypt SSL certificate'
158  if CurPage = wpSelectTasks then
159  begin
160    if IsTaskSelected('enccert') and IsTaskSelected('installservice') then
161    begin
162      MsgBox('When running UnrealIRCd as a service there is no way to enter the password for an encrypted SSL certificate, therefore you cannot combine the two. Please deselect one of the options.', mbError, MB_OK);
163      Result := False
164    end
165  end;
166
167end;
168
169procedure CurStepChanged(CurStep: TSetupStep);
170
171var
172  hWnd: Integer;
173  ResultCode: Integer;
174  ResultXP: boolean;
175  Result2003: boolean;
176  Res: Integer;
177  s: String;
178  d: String;
179begin
180if CurStep = ssPostInstall then
181	begin
182     d := ExpandConstant('{app}');
183	   if IsTaskSelected('fixperm') then
184	   begin
185	     // This fixes the permissions in the Unreal3.2 folder by granting full access to the user
186	     // running the install.
187	     s := '-on "'+d+'" -ot file -actn ace -ace "n:'+GetUserNameString()+';p:full;m:set';
188	     Exec(d+'\tmp\setacl.exe', s, d, SW_HIDE, ewWaitUntilTerminated, Res);
189	   end
190	   else
191	   begin
192	     MsgBox('You have chosen to not have the installer automatically set write access. Please ensure that the user running the IRCd can write to '+d+', otherwise the IRCd will fail to load.',mbConfirmation, MB_OK);
193	   end
194  end;
195end;
196
197//*********************************************************************************
198// Checks if ssl cert file exists
199//*********************************************************************************
200
201#ifdef USE_SSL
202procedure CurPageChanged(CurPage: Integer);
203begin
204  if (CurPage = wpSelectTasks)then
205  begin
206     if FileExists(ExpandConstant('{app}\server.cert.pem')) then
207     begin
208        WizardForm.TasksList.Checked[9]:=false;
209     end
210     else
211     begin
212        WizardForm.TasksList.Checked[9]:=true;
213     end
214  end
215end;
216#endif
217
218[Icons]
219Name: "{group}\UnrealIRCd"; Filename: "{app}\wircd.exe"; WorkingDir: "{app}"
220Name: "{group}\Uninstall UnrealIRCd"; Filename: "{uninstallexe}"; WorkingDir: "{app}"
221#ifdef USE_SSL
222Name: "{group}\Make Certificate"; Filename: "{app}\makecert.bat"; WorkingDir: "{app}"
223Name: "{group}\Encrypt Certificate"; Filename: "{app}\encpem.bat"; WorkingDir: "{app}"
224#endif
225Name: "{group}\Documentation"; Filename: "{app}\doc\unreal32docs.html"; WorkingDir: "{app}"
226Name: "{userdesktop}\UnrealIRCd"; Filename: "{app}\wircd.exe"; WorkingDir: "{app}"; Tasks: desktopicon
227Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\UnrealIRCd"; Filename: "{app}\wircd.exe"; WorkingDir: "{app}"; Tasks: quicklaunchicon
228
229[Run]
230Filename: "notepad"; Description: "View example.conf"; Parameters: "{app}\doc\example.conf"; Flags: postinstall skipifsilent shellexec runmaximized
231Filename: "{app}\doc\unreal32docs.html"; Description: "View UnrealIRCd documentation"; Parameters: ""; Flags: postinstall skipifsilent shellexec runmaximized
232Filename: "notepad"; Description: "View Release Notes"; Parameters: "{app}\RELEASE.NOTES.txt"; Flags: postinstall skipifsilent shellexec runmaximized
233Filename: "notepad"; Description: "View Changes"; Parameters: "{app}\Changes.txt"; Flags: postinstall skipifsilent shellexec runmaximized
234Filename: "{app}\unreal.exe"; Parameters: "install"; Flags: runminimized nowait; Tasks: installservice
235Filename: "{app}\unreal.exe"; Parameters: "config startup manual"; Flags: runminimized nowait; Tasks: installservice/startdemand
236Filename: "{app}\unreal.exe"; Parameters: "config startup auto"; Flags: runminimized nowait; Tasks: installservice/startboot
237Filename: "{app}\unreal.exe"; Parameters: "config crashrestart 2"; Flags: runminimized nowait; Tasks: installservice/crashrestart
238#ifdef USE_SSL
239Filename: "{app}\makecert.bat"; Tasks: makecert; Flags: postinstall;
240Filename: "{app}\encpem.bat"; WorkingDir: "{app}"; Tasks: enccert; Flags: postinstall;
241#endif
242
243[UninstallRun]
244Filename: "{app}\unreal.exe"; Parameters: "uninstall"; Flags: runminimized; RunOnceID: "DelService"; Tasks: installservice
245