]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/winbacula.nsi.in
Flush changes
[bacula/bacula] / bacula / src / win32 / winbacula.nsi.in
1 ; winbacula.nsi
2 ;
3 ; Written by Michel Meyers (michel@tcnnet.dyndns.org)
4 ;
5 ; Updated by Kern Sibbald for native Win32 Bacula
6 ;    added a number of elements from Christopher Hull's installer
7 ;
8 ; Command line options:
9 ;
10 ; /cygwin     -  do cygwin install into c:\cygwin\bacula
11 ; /service    - 
12 ; /start
13
14 !define PRODUCT "Bacula"
15 !define VERSION "@VERSION@"
16
17 ;                           
18 ; Include the Modern UI
19 ;
20 !include "MUI.nsh"
21 !include "params.nsh"
22 !include "util.nsh"
23
24 ;
25 ; Basics
26 ;
27   Name "Bacula Client"
28   OutFile "winbacula-${VERSION}.exe"
29   InstallDir "c:\bacula"
30
31 ;
32 ; Pull in pages
33 ;
34  !insertmacro MUI_PAGE_WELCOME
35 ;  !insertmacro MUI_PAGE_LICENSE "License.txt"
36  !insertmacro MUI_PAGE_COMPONENTS
37  !insertmacro MUI_PAGE_DIRECTORY
38  !insertmacro MUI_PAGE_INSTFILES
39  !insertmacro MUI_PAGE_FINISH
40
41  !insertmacro MUI_UNPAGE_WELCOME
42  !insertmacro MUI_UNPAGE_CONFIRM
43  !insertmacro MUI_UNPAGE_INSTFILES
44  !insertmacro MUI_UNPAGE_FINISH
45
46
47  !define      MUI_ABORTWARNING
48
49  !insertmacro MUI_LANGUAGE "English"
50
51
52
53 DirText "Setup will install the Bacula Client ${VERSION} to the directory specified below. To install in a different folder, click Browse and select another folder.$\n$\nNote to CYGWIN users: please choose your CYGWIN root directory."
54
55
56 Section "Bacula File Service" SecService
57   ;
58   ; /cygwin on command line forces install dir to c:\cygwin\bacula (useful for silent install)
59   ;
60   Push "/cygwin"
61   Call ParameterGiven
62   Pop $6
63   StrCmp $6 0 NoCygwin
64   StrCpy $INSTDIR "c:\cygwin\bacula"
65  NoCygwin:
66 ; IfFileExists "c:\cygwin" Cygwin ReallyNoCygwin
67 ;Cygwin:
68 ; StrCpy $INSTDIR "c:\cygwin\bacula"
69 ;ReallyNoCygwin:
70
71   ; Check for existing installation
72   StrCpy $7 0
73   IfFileExists "$INSTDIR\bin\bacula-fd.conf" Upgrade NoUpgrade
74  Upgrade:
75     StrCpy $7 1
76     ; Shutdown any baculas that could be running
77     ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
78     ; give it some time to shutdown
79     Sleep 1000
80  NoUpgrade:
81
82   ; Set output path to the installation directory.
83   SetOutPath "$INSTDIR\bin"
84   CreateDirectory "$INSTDIR"
85   CreateDirectory "$INSTDIR\bin"
86   CreateDirectory "$INSTDIR\working"
87   CreateDirectory "c:\tmp"
88   ; Put files there
89   File baculafd\Release\bacula-fd.exe
90   File ..\..\..\depkgs-win32\pthreads\pthreadVCE.dll
91   File License.txt
92   IfFileExists "$INSTDIR\bin\bacula-fd.conf" newconf 
93   File bacula-fd.conf
94   goto do_service
95  newconf:
96   File /oname=bacula-fd.conf.new bacula-fd.conf
97        
98   ; If /service was given jump to the service install part
99  do_service:
100   Push "/service"
101   Call ParameterGiven
102   Pop $5
103   StrCmp $5 1 Service
104   
105   ; If silent install and not /service don't ask questions and goto NoService...
106   IfSilent NoService
107
108   ; If already installed as service skip it too
109   ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
110   StrCmp $9 "1" NoService  
111
112   ; Install as service?
113   MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to install the Bacula Client as a service (automatically starts with your PC)?" IDNO NoService
114  Service:
115     ExecWait '"$INSTDIR\bin\bacula-fd.exe" /install'
116     StrCpy $9 "1"
117     WriteRegDWORD HKLM "Software\Bacula" "InstalledService" "1"
118  NoService:
119
120   ; Write the uninstall keys for Windows
121   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "DisplayName" "Bacula Client"
122   WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula" "UninstallString" '"$INSTDIR\uninstall.exe"'
123   WriteUninstaller "$INSTDIR\Uninstall.exe"
124
125   ; Create bacula-fd.conf and have the user edit it (skipped if silent)
126   IfSilent NoReminder
127   StrCmp $7 "1" NoReminder  ; skip if it is an upgrade
128   MessageBox MB_OK "Please edit $INSTDIR\bin\bacula-fd.conf according to your requirements/installation! Also remember to put a shortcut into your start menu if you didn't install the client as a service."
129   Exec 'write "$INSTDIR\bin\bacula-fd.conf"'  ; spawn wordpad with the file to be edited
130  NoReminder:
131
132   ; Start the client? (default skipped if silent, use /start to force starting)
133   Push "/start"
134   Call ParameterGiven
135   Pop $8
136   StrCmp $8 "1" Start
137   IfSilent NoStart
138   Call IsNt
139   Pop $R0
140   StrCmp $R0 "false" do_win98
141   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO NoStart
142   Exec 'net start bacula'
143   goto NoStart 
144  do_win98:
145   File Start.bat
146   File Stop.bat
147   MessageBox MB_YESNO|MB_ICONQUESTION  "Would you like to start the Bacula Client now?" IDNO NoStart
148  Start:
149   Exec '"$INSTDIR\bin\bacula-fd.exe" -c "$INSTDIR\bin\bacula-fd.conf"'
150  NoStart:
151
152 SectionEnd
153
154
155 Section "Install Documentation" SecDoc
156   SetOutPath "$INSTDIR\doc"
157   CreateDirectory "$INSTDIR\doc"
158   File ..\..\doc\html-manual\*.html
159   File ..\..\doc\html-manual\*.gif
160   File ..\..\doc\html-manual\*.jpg
161 SectionEnd
162
163 ;
164 ; Extra Page descriptions
165 ;
166
167   LangString DESC_SecService ${LANG_ENGLISH} "Install Bacula client on this system."
168   LangString DESC_SecDoc ${LANG_ENGLISH} "Install Documenation on this system."
169
170   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
171     !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
172     !insertmacro MUI_DESCRIPTION_TEXT ${SecDoc} $(DESC_SecDoc)
173   !insertmacro MUI_FUNCTION_DESCRIPTION_END
174
175
176
177 ; Uninstall section
178
179 UninstallText "This will uninstall the Bacula Client. Hit next to continue."
180
181 Section "Uninstall"
182
183   ; Shutdown any baculum that could be running
184   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /kill'
185
186   ReadRegDWORD $9 HKLM "Software\Bacula" "InstalledService"
187   StrCmp $9 "" NoService
188   ; Remove bacula service
189   ExecWait '"$INSTDIR\bin\bacula-fd.exe" /remove'
190   NoService:
191   
192   ; remove registry keys
193   DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Bacula"
194   DeleteRegKey HKLM "Software\Bacula"
195
196   ; remove files and uninstaller (preserving config for now)
197   CopyFiles /SILENT "$INSTDIR\bin\bacula-fd.conf" "$INSTDIR\bacula-fd.conf"
198   Delete /REBOOTOK "$INSTDIR\bin\*.*"
199   Delete /REBOOTOK "$INSTDIR\doc\*.*"
200   CopyFiles /SILENT "$INSTDIR\bacula-fd.conf" "$INSTDIR\bin\bacula-fd.conf"
201   Delete /REBOOTOK "$INSTDIR\bacula-fd.conf"
202   Delete /REBOOTOK "$INSTDIR\Uninstall.exe"
203
204   ; Check for existing installation
205   MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to delete the current configuration file ($INSTDIR\bin\bacula-fd.conf)?" IDNO LeaveConfig
206   Delete /REBOOTOK "$INSTDIR\bin\bacula-fd.conf"
207   ; remove directories used
208   RMDir "$INSTDIR\bin"
209   RMDir "$INSTDIR\doc"
210   RMDir "$INSTDIR\working"
211   RMDir "$INSTDIR"
212   RMDir "C:\tmp"
213   LeaveConfig:
214   
215 SectionEnd
216
217 ; eof