1 |
# $Id: install.nsi 257 2024-10-04 05:34:27Z nishi $ |
2 |
|
3 |
VIFileVersion "1.0.0.0" |
4 |
VIProductVersion "1.0.0.0" |
5 |
VIAddVersionKey "FileVersion" "${VERSION}" |
6 |
VIAddVersionKey "LegalCopyright" "Public domain. Original by Nishi" |
7 |
VIAddVersionKey "FileDescription" "Tewi HTTPd Installer" |
8 |
|
9 |
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Japanese.nlf" |
10 |
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf" |
11 |
|
12 |
Name "Tewi HTTPd" |
13 |
OutFile "install.exe" |
14 |
InstallDir "C:\Tewi" |
15 |
Icon "../Binary/tewi-install.ico" |
16 |
LicenseData ../LICENSE |
17 |
|
18 |
LangString EXEC_ONLY ${LANG_ENGLISH} "Install the executable only" |
19 |
LangString EXEC_ONLY ${LANG_JAPANESE} "実行機能のみをインストールする" |
20 |
LangString SERV_TOO ${LANG_ENGLISH} "Install the service too (NT-only)" |
21 |
LangString SERV_TOO ${LANG_JAPANESE} "サービスもインストールする(NTのみ)" |
22 |
LangString WAIT_STOP ${LANG_ENGLISH} "Waiting for 1 second so service can stop" |
23 |
LangString WAIT_STOP ${LANG_JAPANESE} "サービスが止まるのを待っています" |
24 |
|
25 |
!include "x64.nsh" |
26 |
!include "LogicLib.nsh" |
27 |
!include "Sections.nsh" |
28 |
|
29 |
Page license |
30 |
Page directory |
31 |
Page components |
32 |
Page instfiles |
33 |
UninstPage uninstConfirm |
34 |
UninstPage instfiles |
35 |
Section |
36 |
CreateDirectory "$INSTDIR\etc" |
37 |
CreateDirectory "$INSTDIR\www" |
38 |
CreateDirectory "$INSTDIR\www\icons" |
39 |
CreateDirectory "$INSTDIR\modules" |
40 |
CreateDirectory "$INSTDIR\bin" |
41 |
SetOutPath "$INSTDIR" |
42 |
!cd .. |
43 |
File /oname=LICENSE.txt "LICENSE" |
44 |
SetOutPath "$INSTDIR\modules" |
45 |
!cd Module |
46 |
File "*.dll" |
47 |
!cd .. |
48 |
SetOutPath "$INSTDIR\etc" |
49 |
SetOverWrite off |
50 |
File /oname=tewi.conf "generated.conf" |
51 |
SetOutPath "$INSTDIR\www" |
52 |
File /oname=index.html "itworks.html" |
53 |
!cd Binary |
54 |
File /oname=pbtewi.gif "pbtewi.gif" |
55 |
!cd .. |
56 |
!cd Icons |
57 |
SetOutPath "$INSTDIR\www\icons" |
58 |
File "*.png" |
59 |
!cd .. |
60 |
!cd Server |
61 |
SetOverWrite on |
62 |
!cd .. |
63 |
SetOutPath "$INSTDIR" |
64 |
File "mime.types" |
65 |
!cd Server |
66 |
|
67 |
CreateDirectory "$SMPROGRAMS\Tewi HTTPd" |
68 |
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\License.lnk" "$INSTDIR\LICENSE.txt" "" |
69 |
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd.lnk" "$INSTDIR\bin\tewi.exe" "" |
70 |
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd (verbose).lnk" "$INSTDIR\bin\tewi.exe" "-v" |
71 |
CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Uninstall Tewi HTTPd.lnk" "$INSTDIR\uninstall.exe" "" |
72 |
|
73 |
${If} ${RunningX64} |
74 |
SetRegView 64 |
75 |
${Else} |
76 |
SetRegView 32 |
77 |
${EndIf} |
78 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "DisplayName" "Tewi HTTPd" |
79 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "InstallDir" "$INSTDIR" |
80 |
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "UninstallString" '"$INSTDIR\uninstall.exe"' |
81 |
|
82 |
WriteUninstaller "$INSTDIR\uninstall.exe" |
83 |
SectionEnd |
84 |
|
85 |
Section "$(EXEC_ONLY)" SEL_EXEC |
86 |
SetOutPath "$INSTDIR\bin" |
87 |
!cd .. |
88 |
File "tewi.exe" |
89 |
!cd Server |
90 |
WriteINIStr $INSTDIR\install.ini uninstall service false |
91 |
SectionEnd |
92 |
|
93 |
!ifndef ONLY_EXEC |
94 |
Section /o "$(SERV_TOO)" SEL_SERVICE |
95 |
WriteINIStr $INSTDIR\install.ini uninstall service true |
96 |
FileOpen $9 $INSTDIR\install.bat w |
97 |
FileWrite $9 '"$SYSDIR\sc.exe" stop "TewiHTTPd"$\r$\n' |
98 |
FileClose $9 |
99 |
nsExec::Exec '"$INSTDIR\install.bat"' |
100 |
Pop $0 |
101 |
DetailPrint "$(WAIT_STOP)" |
102 |
Sleep 1000 |
103 |
CreateDirectory "$INSTDIR\logs" |
104 |
SetOutPath "$INSTDIR\bin" |
105 |
!cd .. |
106 |
File "tewi.exe" |
107 |
File /oname=tewisrv.exe "tewi-service.exe" |
108 |
!cd Server |
109 |
FileOpen $9 $INSTDIR\install.bat w |
110 |
FileWrite $9 '"$SYSDIR\sc.exe" delete "TewiHTTPd"$\r$\n' |
111 |
FileWrite $9 '"$SYSDIR\sc.exe" create "TewiHTTPd" DisplayName= "Tewi HTTPd" binpath= "$INSTDIR\bin\tewisrv.exe" start= "auto"$\r$\n' |
112 |
FileWrite $9 '"$SYSDIR\sc.exe" start "TewiHTTPd"$\r$\n' |
113 |
FileClose $9 |
114 |
nsExec::Exec '"$INSTDIR\install.bat"' |
115 |
Pop $0 |
116 |
Delete $INSTDIR\install.bat |
117 |
SectionEnd |
118 |
!endif |
119 |
|
120 |
Function .onInit |
121 |
StrCpy $1 ${SEL_EXEC} |
122 |
FunctionEnd |
123 |
|
124 |
Function .onSelChange |
125 |
!insertmacro StartRadioButtons $1 |
126 |
!insertmacro RadioButton ${SEL_EXEC} |
127 |
!ifndef ONLY_EXEC |
128 |
!insertmacro RadioButton ${SEL_SERVICE} |
129 |
!endif |
130 |
!insertmacro EndRadioButtons |
131 |
FunctionEnd |
132 |
|
133 |
Section "Uninstall" |
134 |
ReadINIStr $8 $INSTDIR\install.ini uninstall service |
135 |
${If} $8 == "true" |
136 |
FileOpen $9 $INSTDIR\uninstall.bat w |
137 |
FileWrite $9 '"$SYSDIR\sc.exe" stop "TewiHTTPd"$\r$\n' |
138 |
FileClose $9 |
139 |
nsExec::Exec '"$INSTDIR\uninstall.bat"' |
140 |
Pop $0 |
141 |
FileOpen $9 $INSTDIR\uninstall.bat w |
142 |
DetailPrint "$(WAIT_STOP)" |
143 |
Sleep 1000 |
144 |
FileWrite $9 '"$SYSDIR\sc.exe" delete "TewiHTTPd"$\r$\n' |
145 |
FileClose $9 |
146 |
nsExec::Exec '"$INSTDIR\uninstall.bat"' |
147 |
Pop $0 |
148 |
Delete $INSTDIR\uninstall.bat |
149 |
${EndIf} |
150 |
|
151 |
RMDir /r "$INSTDIR" |
152 |
RMDir /r "$SMPROGRAMS\Tewi HTTPd" |
153 |
|
154 |
${If} ${RunningX64} |
155 |
SetRegView 64 |
156 |
${Else} |
157 |
SetRegView 32 |
158 |
${EndIf} |
159 |
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" |
160 |
SectionEnd |