Subversion Repositories Tewi

Rev

Rev 61 | Rev 63 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
54 nishi 1
# $Id: install.nsi 62 2024-09-18 20:02:26Z nishi $
2
 
3
Name "Tewi HTTPd"
4
OutFile "install.exe"
5
InstallDir "C:\Tewi"
6
Icon "tewi.ico"
7
LicenseData ../LICENSE
62 nishi 8
 
9
!include "LogicLib.nsh"
10
!include "Sections.nsh"
11
 
54 nishi 12
Page license
62 nishi 13
Page components
54 nishi 14
Page instfiles
15
UninstPage uninstConfirm
16
UninstPage instfiles
17
Section
18
	CreateDirectory "$INSTDIR\etc"
19
	CreateDirectory "$INSTDIR\www"
60 nishi 20
	CreateDirectory "$INSTDIR\www\icons"
61 nishi 21
	CreateDirectory "$INSTDIR\modules"
54 nishi 22
	CreateDirectory "$INSTDIR\bin"
61 nishi 23
	SetOutPath "$INSTDIR"
24
	File /oname=LICENSE.txt "../LICENSE"
25
	SetOutPath "$INSTDIR\modules"
26
	File "../Module/*.dll"
54 nishi 27
	SetOutPath "$INSTDIR\etc"
61 nishi 28
	SetOverWrite off
29
	File /oname=tewi.conf "../example-win.conf"
54 nishi 30
	SetOutPath "$INSTDIR\www"
31
	File /oname=index.html "../itworks.html"
60 nishi 32
	SetOutPath "$INSTDIR\www\icons"
33
	File "../Icons/*.png"
61 nishi 34
	SetOverWrite on
54 nishi 35
 
36
	CreateDirectory "$SMPROGRAMS\Tewi HTTPd"
61 nishi 37
	CreateShortcut "$SMPROGRAMS\Tewi HTTPd\License.lnk" "$INSTDIR\LICENSE.txt" ""
54 nishi 38
	CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd.lnk" "$INSTDIR\bin\tewi.exe" ""
39
	CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd (verbose).lnk" "$INSTDIR\bin\tewi.exe" "-v"
40
	CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Uninstall Tewi HTTPd.lnk" "$INSTDIR\uninstall.exe" ""
41
 
42
	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "DisplayName" "Tewi HTTPd"
43
	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "UninstallString" '"$INSTDIR\uninstall.exe"'
44
 
45
	WriteUninstaller "$INSTDIR\uninstall.exe"
46
SectionEnd
47
 
62 nishi 48
Section "Install the executable only" SEL_EXEC
49
	SetOutPath "$INSTDIR\bin"
50
	File "../tewi.exe"
51
	WriteINIStr $INSTDIR\install.ini uninstall service false
52
SectionEnd
53
 
54
Section /o "Install the service too (NT-only)" SEL_SERVICE
55
	WriteINIStr $INSTDIR\install.ini uninstall service true
56
	FileOpen $9 $INSTDIR\install.bat w
57
	FileWrite $9 '"$SYSDIR\sc.exe" stop "TewiHTTPd"$\r$\n'
58
	FileClose $9
59
	nsExec::Exec '"$INSTDIR\install.bat"'
60
	Pop $0
61
	DetailPrint "Waiting for 1s so service can stop..."
62
	Sleep 1000
63
	CreateDirectory "$INSTDIR\logs"
64
	SetOutPath "$INSTDIR\bin"
65
	File "../tewi.exe"
66
	File /oname=tewisrv.exe "../tewi-service.exe"
67
	FileOpen $9 $INSTDIR\install.bat w
68
	FileWrite $9 '"$SYSDIR\sc.exe" delete "TewiHTTPd"$\r$\n'
69
	FileWrite $9 '"$SYSDIR\sc.exe" create "TewiHTTPd" DisplayName= "Tewi HTTPd" binpath= "$INSTDIR\bin\tewisrv.exe" start= "auto"$\r$\n'
70
	FileWrite $9 '"$SYSDIR\sc.exe" start "TewiHTTPd"$\r$\n'
71
	FileClose $9
72
	nsExec::Exec '"$INSTDIR\install.bat"'
73
	Pop $0
74
	Delete $INSTDIR\install.bat
75
SectionEnd
76
 
77
Function .onInit
78
	StrCpy $1 ${SEL_EXEC}
79
FunctionEnd
80
 
81
Function .onSelChange
82
	!insertmacro StartRadioButtons $1
83
	!insertmacro RadioButton ${SEL_EXEC}
84
	!insertmacro RadioButton ${SEL_SERVICE}
85
	!insertmacro EndRadioButtons
86
FunctionEnd
87
 
54 nishi 88
Section "Uninstall"
62 nishi 89
	ReadINIStr $8 $INSTDIR\install.ini uninstall service
90
	${If} $8 == "true"
91
		FileOpen $9 $INSTDIR\uninstall.bat w
92
		FileWrite $9 '"$SYSDIR\sc.exe" stop "TewiHTTPd"$\r$\n'
93
		FileClose $9
94
		nsExec::Exec '"$INSTDIR\uninstall.bat"'
95
		Pop $0
96
		FileOpen $9 $INSTDIR\uninstall.bat w
97
		DetailPrint "Waiting for 1s so service can stop..."
98
		Sleep 1000
99
		FileWrite $9 '"$SYSDIR\sc.exe" delete "TewiHTTPd"$\r$\n'
100
		FileClose $9
101
		nsExec::Exec '"$INSTDIR\uninstall.bat"'
102
		Pop $0
103
		Delete $INSTDIR\uninstall.bat
104
	${EndIf}
105
 
54 nishi 106
	RMDir /r "$INSTDIR"
107
	RMDir /r "$SMPROGRAMS\Tewi HTTPd"
108
 
109
	DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd"
110
SectionEnd