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