-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.nsi
218 lines (166 loc) · 7.05 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
;--------------------------------
;General
;Name and file
Name "Slowjudge"
OutFile "Slowjudge_Installer.exe"
;--------------------------------
;Version Information
VIProductVersion "1.1.0.2"
VIAddVersionKey "ProductName" "Slowjudge"
VIAddVersionKey "Comments" "An easy to maintain contest platform"
VIAddVersionKey "CompanyName" "moshiur-bd"
VIAddVersionKey "LegalTrademarks" "https://github.com/moshiur-bd/SlowJudge"
VIAddVersionKey "FileDescription" "Slowjudge"
VIAddVersionKey "FileVersion" "1.1.0.2"
;----------------------------------
;Request application privileges for Windows Vista
RequestExecutionLevel admin
;build source code at compile time
!system "evaluator\build.bat"
;Default installation folder
InstallDir "C:\Slowjudge"
;Read from Registry if available
InstallDirRegKey HKCU "Software\slowjudge" "store"
;Define necessary variables to hold directory
Var WebDir
Var XamppDir
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;-------------------------------------------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_HEADER_TEXT "Choose a location where slowjudge will be installed"
!define MUI_PAGE_HEADER_SUBTEXT "This is the location where slowjudge will store submission & IO files"
!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the directory where you want slowjudge to be installed."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Enter Directory"
!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_HEADER_TEXT "Select Xampp Directory"
!define MUI_PAGE_HEADER_SUBTEXT "Slowjudge Requires Xampp to operate. If you haven't installed Xampp, Install it first and then provide select the location here"
!define MUI_DIRECTORYPAGE_TEXT_TOP "Please select the directory where you have istalled Xampp"
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Xampp Directory"
!define MUI_DIRECTORYPAGE_VARIABLE $XamppDir
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
;-------------------------------------------------------------------------------------------
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English" ; The first language is the default language
;-------------------------------
;--------------------------------
;Installer Sections
Section "Install - Website" SecWeb
StrCpy $WebDir "$XamppDir\htdocs\slowjudge"
SetOutPath "$WebDir"
File /r "web-end\*"
;Store installation folder
WriteRegStr HKCU "Software\slowjudge" "xamppdir" $XamppDir
WriteRegStr HKCU "Software\slowjudge" "webdir" $WebDir
SectionEnd
Section "Install - Solution Evaluator" SecEval
;create sandbox folder to run submissions
SetOutPath "C:\sandbox"
;copy necessary files
SetOutPath "$INSTDIR\checker"
File "evaluator\checker\TrailingWhiteSpaceAllowed.exe"
SetOutPath "$INSTDIR"
File "evaluator\Timer.class"
File "evaluator\Judge.class"
File "evaluator\cpu.exe"
File "evaluator\compiler.exe"
File "evaluator\watcher.exe"
File "dependency\mysql-connector-java-5.0.8-bin.jar"
;create necessary folders
SetOutPath "$INSTDIR\in"
SetOutPath "$INSTDIR\out"
SetOutPath "$INSTDIR\src"
SetOutPath "$INSTDIR\sub"
File "evaluator\sub\forbid.c"
;create registry entry for $INSTDIR
WriteRegStr HKCU "Software\slowjudge" "store" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
Section "Replace php.ini" SecReplacePhpIni
SetOutPath "$XamppDir\php"
File "dependency\php.ini"
SectionEnd
Section "Create StartMenu-Shortcut" SecStartMenuShortCut
SetOutPath "$INSTDIR"
CreateShortCut "$SMPROGRAMS\slowjudge.lnk" "$INSTDIR\server.bat"
SectionEnd
Section "Create Desktop-Shortcut " SecDesktopShortCut
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\slowjudge.lnk" "$INSTDIR\server.bat"
SectionEnd
Section "Auto start" SecAutoStart
SetOutPath "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "slowjudge" "$INSTDIR\server.bat"
SectionEnd
Section "-Delete Auto Start" SecDeleteAutoStart
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "slowjudge"
SectionEnd
Section "-Create Server.bat" SecCreateServerBatch
SetOutPath "$INSTDIR"
FileOpen $0 "$INSTDIR\server.bat" w
FileWrite $0 'set path=%path%;C:\Program Files\Java\jdk1.8.0_102\bin;C:\Program Files (x86)\CodeBlocks\MinGW\bin;$\r$\n'
FileWrite $0 'set slowjudgeback=$INSTDIR\$\r$\n'
FileWrite $0 'set classpath=%slowjudgeback%;%slowjudgeback%mysql-connector-java-5.0.8-bin.jar;$\r$\n'
FileWrite $0 'start $XamppDir\mysql_start.bat$\r$\n'
FileWrite $0 'start $XamppDir\apache_start.bat$\r$\n'
FileWrite $0 'timeout /t 20$\r$\n'
FileWrite $0 'start /SEPARATE /MIN /D $INSTDIR\ "" java Judge $INSTDIR\ slowjudge-contest-engine slowjudge-contest-$\r$\n'
FileClose $0
SectionEnd
;--------------------------------
; ;Installer Functions
Function .onSelChange
${If} ${SectionIsSelected} ${SecAutoStart}
!insertmacro UnselectSection ${SecDeleteAutoStart}
${Else}
!insertmacro SelectSection ${SecDeleteAutoStart}
${EndIf}
FunctionEnd
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
;by default autstart will be selected and deletautostart will be deselected
!insertmacro UnselectSection ${SecDeleteAutoStart}
!insertmacro SelectSection ${SecAutoStart}
ReadRegStr $XamppDir HKCU "Software\slowjudge" "xamppdir"
StrCmp $XamppDir "" 0 +2
StrCpy $XamppDir "C:\xampp"
StrCpy $WebDir "$XamppDir\htdocs\slowjudge"
FunctionEnd
;--------------------------------
;Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecWeb} "Php files to power slowjudge web end"
!insertmacro MUI_DESCRIPTION_TEXT ${SecEval} "Backend to Evaluation solutions and Run contest. This folder also will store all the problem and IO and solutions."
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortCut} "Creates Start Menu shortcut"
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortCut} "Creates Desktop shortcut"
!insertmacro MUI_DESCRIPTION_TEXT ${SecAutoStart} "Runs slowjudge server at system startup. Unselecting this will disable auto start"
!insertmacro MUI_DESCRIPTION_TEXT ${SecReplacePhpIni} "New php.ini fine tunes php for slowjudge. It increases some limitations like file upload sizes, session timeouts & memory limitation"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
Delete "$INSTDIR\Uninstall.exe"
Delete "$DESKTOP\slowjudge.lnk"
Delete "$SMPROGRAMS\slowjudge.lnk"
RMDir "$INSTDIR"
RMDir "$WebDir"
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "slowjudge"
SectionEnd
;--------------------------------
;Uninstaller Functions
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
ReadRegStr $WebDir HKCU "Software\slowjudge" "webdir"
FunctionEnd