1 ;tor.nsi - A basic win32 installer for Tor
2 ; Originally written by J Doe.
3 ; Modified by Steve Topletz, Andrew Lewman
4 ; See the Tor LICENSE for licensing information
5 ;-----------------------------------------
8 !include "LogicLib.nsh"
9 !include "FileFunc.nsh"
10 !insertmacro GetParameters
11 !define VERSION
"0.2.2.8-alpha-dev"
12 !define INSTALLER
"tor-${VERSION}-win32.exe"
13 !define WEBSITE
"https://www.torproject.org/"
14 !define LICENSE
"LICENSE"
15 !define BIN
"..\bin" ;BIN is where it expects to find tor.exe, tor-resolve.exe
18 SetCompressor
/SOLID LZMA
;Tighter compression
19 RequestExecutionLevel user
;Updated for Vista compatibility
21 InstallDir $PROGRAMFILES\Tor
24 Caption "Tor ${VERSION} Setup"
25 BrandingText "The Onion Router"
28 VIProductVersion
"${VERSION}"
29 VIAddVersionKey
"ProductName" "The Onion Router: Tor"
30 VIAddVersionKey
"Comments" "${WEBSITE}"
31 VIAddVersionKey
"LegalTrademarks" "Three line BSD"
32 VIAddVersionKey
"LegalCopyright" "©2004-2008, Roger Dingledine, Nick Mathewson"
33 VIAddVersionKey
"FileDescription" "Tor is an implementation of Onion Routing. You can read more at ${WEBSITE}"
34 VIAddVersionKey
"FileVersion" "${VERSION}"
36 !define MUI_WELCOMEPAGE_TITLE
"Welcome to the Tor Setup Wizard"
37 !define MUI_WELCOMEPAGE_TEXT
"This wizard will guide you through the installation of Tor ${VERSION}.\r\n\r\nIf you have previously installed Tor and it is currently running, please exit Tor first before continuing this installation.\r\n\r\n$_CLICK"
38 !define MUI_ABORTWARNING
39 !define MUI_ICON
"${NSISDIR}\Contrib\Graphics\Icons\win-install.ico"
40 !define MUI_UNICON
"${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico"
41 !define MUI_HEADERIMAGE_BITMAP
"${NSISDIR}\Contrib\Graphics\Header\win.bmp"
42 !define MUI_FINISHPAGE_RUN
"$INSTDIR\tor.exe"
43 !define MUI_FINISHPAGE_LINK
"Visit the Tor website for the latest updates."
44 !define MUI_FINISHPAGE_LINK_LOCATION
${WEBSITE}
46 !insertmacro MUI_PAGE_WELCOME
47 ; There's no point in having a clickthrough license: Our license adds
48 ; certain rights, but doesn't remove them.
49 ; !insertmacro MUI_PAGE_LICENSE "${LICENSE}"
50 !insertmacro MUI_PAGE_COMPONENTS
51 !insertmacro MUI_PAGE_DIRECTORY
52 !insertmacro MUI_PAGE_INSTFILES
53 !insertmacro MUI_PAGE_FINISH
54 !insertmacro MUI_UNPAGE_WELCOME
55 !insertmacro MUI_UNPAGE_CONFIRM
56 !insertmacro MUI_UNPAGE_INSTFILES
57 !insertmacro MUI_UNPAGE_FINISH
58 !insertmacro MUI_LANGUAGE
"English"
71 ;Files that have to be installed for tor to run and that the user
72 ;cannot choose not to install
77 WriteINIStr "$INSTDIR\Tor Website.url" "InternetShortcut" "URL" ${WEBSITE}
79 StrCpy $CONFIGFILE "torrc"
80 StrCpy $CONFIGDIR $APPDATA\Tor
81 ; ;If $APPDATA isn't valid here (Early win95 releases with no updated
82 ; ; shfolder.dll) then we put it in the program directory instead.
83 ; StrCmp $APPDATA "" "" +2
84 ; StrCpy $CONFIGDIR $INSTDIR
86 ;If there's already a torrc config file, ask if they want to
87 ;overwrite it with the new one.
88 ${If} ${FileExists} "$CONFIGDIR\torrc"
89 MessageBox MB_ICONQUESTION|
MB_YESNO "You already have a Tor config file.$\r$\nDo you want to overwrite it with the default sample config file?" IDYES Yes
IDNO No
91 Delete $CONFIGDIR\torrc
94 StrCpy $CONFIGFILE "torrc.sample"
97 File /oname=
$CONFIGFILE "..\src\config\torrc.sample"
99 ; the geoip file needs to be included and stuffed into the right directory
100 ; otherwise tor is unhappy
101 SetOutPath $APPDATA\Tor
105 Section "Documents" Docs
106 Call ExtractDocuments
109 SubSection
/e
"Shortcuts" Shortcuts
111 Section "Start Menu" StartMenu
113 ${If} ${FileExists} "$SMPROGRAMS\Tor\*.*"
114 RMDir /r
"$SMPROGRAMS\Tor"
117 ${If} ${FileExists} "$INSTDIR\Documents\*.*"
122 Section "Desktop" Desktop
124 CreateShortCut "$DESKTOP\Tor.lnk" "$INSTDIR\tor.exe" "" "$INSTDIR\tor.ico"
127 Section /o
"Run at startup" Startup
129 CreateShortCut "$SMSTARTUP\Tor.lnk" "$INSTDIR\tor.exe" "" "$INSTDIR\tor.ico" "" SW_SHOWMINIMIZED
135 Call un
.InstallPackage
139 WriteUninstaller "$INSTDIR\Uninstall.exe"
140 ;The registry entries simply add the Tor uninstaller to the Windows
142 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tor" "DisplayName" "Tor (remove only)"
143 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tor" "UninstallString" '"$INSTDIR\Uninstall.exe"'
146 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
147 !insertmacro MUI_DESCRIPTION_TEXT
${Tor} "The core executable and config files needed for Tor to run."
148 !insertmacro MUI_DESCRIPTION_TEXT
${Docs} "Documentation about Tor."
149 !insertmacro MUI_DESCRIPTION_TEXT
${ShortCuts} "Shortcuts to easily start Tor"
150 !insertmacro MUI_DESCRIPTION_TEXT
${StartMenu} "Shortcuts to access Tor and it's documentation from the Start Menu"
151 !insertmacro MUI_DESCRIPTION_TEXT
${Desktop} "A shortcut to start Tor from the desktop"
152 !insertmacro MUI_DESCRIPTION_TEXT
${Startup} "Launches Tor automatically at startup in a minimized window"
153 !insertmacro MUI_FUNCTION_DESCRIPTION_END
155 ;####################Functions#########################
157 Function ExtractBinaries
158 File "${BIN}\tor.exe"
159 File "${BIN}\tor-resolve.exe"
162 Function ExtractGEOIP
167 File "${BIN}\tor.ico"
170 Function ExtractSpecs
171 File "..\doc\HACKING"
172 File "..\doc\spec\address-spec.txt"
173 File "..\doc\spec\control-spec.txt"
174 File "..\doc\spec\control-spec-v0.txt"
175 File "..\doc\spec\dir-spec.txt"
176 File "..\doc\spec\dir-spec-v1.txt"
177 File "..\doc\spec\path-spec.txt"
178 File "..\doc\spec\rend-spec.txt"
179 File "..\doc\spec\socks-extensions.txt"
180 File "..\doc\spec\tor-spec.txt"
181 File "..\doc\spec\version-spec.txt"
185 File "..\doc\tor-resolve.html"
186 File "..\doc\tor-reference.html"
189 Function ExtractDesignDocs
190 File "..\doc\design-paper\tor-design.pdf"
193 Function ExtractReleaseDocs
200 Function ExtractDocuments
201 SetOutPath "$INSTDIR\Documents"
204 Call ExtractDesignDocs
205 Call ExtractReleaseDocs
208 Function un
.InstallFiles
209 Delete "$DESKTOP\Tor.lnk"
210 Delete "$INSTDIR\tor.exe"
211 Delete "$INSTDIR\tor-resolve.exe"
212 Delete "$INSTDIR\Tor Website.url"
213 Delete "$INSTDIR\torrc"
214 Delete "$INSTDIR\torrc.sample"
215 Delete "$INSTDIR\tor.ico"
216 Delete "$SMSTARTUP\Tor.lnk"
217 Delete "$INSTDIR\Uninstall.exe"
218 Delete "$INSTDIR\geoip"
221 Function un
.InstallDirectories
222 ${If} $CONFIGDIR ==
$INSTDIR
225 RMDir /r
"$INSTDIR\Documents"
227 RMDir /r
"$SMPROGRAMS\Tor"
228 RMDir /r
"$APPDATA\Tor"
231 Function un
.WriteRegistry
232 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Tor"
235 Function un
.InstallPackage
237 Call un
.InstallDirectories
238 Call un
.WriteRegistry
241 Function CreateTorLinks
242 CreateDirectory "$SMPROGRAMS\Tor"
243 CreateShortCut "$SMPROGRAMS\Tor\Tor.lnk" "$INSTDIR\tor.exe" "" "$INSTDIR\tor.ico"
244 CreateShortCut "$SMPROGRAMS\Tor\Torrc.lnk" "Notepad.exe" "$CONFIGDIR\torrc"
245 CreateShortCut "$SMPROGRAMS\Tor\Tor Website.lnk" "$INSTDIR\Tor Website.url"
246 CreateShortCut "$SMPROGRAMS\Tor\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
249 Function CreateDocLinks
250 CreateDirectory "$SMPROGRAMS\Tor\Documents"
251 CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Manual.lnk" "$INSTDIR\Documents\tor-reference.html"
252 CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Documentation.lnk" "$INSTDIR\Documents"
253 CreateShortCut "$SMPROGRAMS\Tor\Documents\Tor Specification.lnk" "$INSTDIR\Documents\tor-spec.txt"
256 Function ParseCmdLine
258 ${If} $1 ==
"-x" ;Extract All Files
259 StrCpy $INSTDIR $EXEDIR
261 Call ExtractDocuments
263 ${ElseIf} $1 ==
"-b" ;Extract Binaries Only
264 StrCpy $INSTDIR $EXEDIR
268 MessageBox MB_OK|
MB_TOPMOST `${Installer} [-x|-b]$\r$\n$\r$\n -x Extract all files$\r$\n -b Extract binary files only`