mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Setup.exe for Windows
NSIS script to build setup file to install Syncthing and install as a service.
This commit is contained in:
parent
6057138466
commit
f0a88061db
13
etc/windows/ReadMe.txt
Normal file
13
etc/windows/ReadMe.txt
Normal file
@ -0,0 +1,13 @@
|
||||
A first pass at an install script for SyncThing as a Windows Service
|
||||
|
||||
Script uses NSIS http://nsis.sourceforge.net/Download
|
||||
Requires the NSIS Simple Service Plugin http://nsis.sourceforge.net/NSIS_Simple_Service_Plugin
|
||||
And uses the Windows Service Wrapper https://github.com/kohsuke/winsw
|
||||
|
||||
To build the setup file:
|
||||
|
||||
1. Install NSIS, download the Simple Service Plugin DLL into the NSIS plugin folder
|
||||
2. Create a folder (referenced by the $SOURCEPATH variable in the .nsi file) with all the syncthing output in it (exe file, licences, etc)
|
||||
3. Download winsw.exe from https://github.com/kohsuke/winsw/releases, rename it to syncthingservice.exe and save that in $SOURCEPATH
|
||||
4. Put syncthingservice.xml in there too
|
||||
5. Compile SyncthingSetup.nsi using NSIS
|
116
etc/windows/SyncThingSetup.nsi
Normal file
116
etc/windows/SyncThingSetup.nsi
Normal file
@ -0,0 +1,116 @@
|
||||
;--------------------------------
|
||||
;Include Modern UI
|
||||
|
||||
!include "MUI2.nsh"
|
||||
|
||||
;--------------------------------
|
||||
;General
|
||||
|
||||
;Name and file
|
||||
!define SOURCEPATH "C:\SourceCode\SyncThing\Binaries"
|
||||
|
||||
Name "SyncThing Windows Service Install"
|
||||
OutFile "SyncThingSetup.exe"
|
||||
|
||||
;Default installation folder
|
||||
InstallDir "$PROGRAMFILES\SyncThing"
|
||||
|
||||
;Get installation folder from registry if available
|
||||
InstallDirRegKey HKCU "Software\SyncThing" ""
|
||||
|
||||
;Request application privileges for Windows Vista
|
||||
RequestExecutionLevel admin
|
||||
|
||||
;--------------------------------
|
||||
;Interface Settings
|
||||
|
||||
!define MUI_ABORTWARNING
|
||||
|
||||
;--------------------------------
|
||||
;Pages
|
||||
|
||||
!insertmacro MUI_PAGE_COMPONENTS
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
|
||||
;--------------------------------
|
||||
;Languages
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
;--------------------------------
|
||||
;Installer Sections
|
||||
|
||||
Section "SyncThing" SecSyncThing
|
||||
SectionIn RO
|
||||
SetOutPath "$INSTDIR"
|
||||
|
||||
IfFileExists syncthingservice.exe 0 +2
|
||||
SimpleSC::StopService "SyncThing" 1 30
|
||||
|
||||
File /r "${SOURCEPATH}\syncthing.exe"
|
||||
File /r "${SOURCEPATH}\syncthing.exe.md5"
|
||||
File /r "${SOURCEPATH}\AUTHORS.txt"
|
||||
File /r "${SOURCEPATH}\LICENSE.txt"
|
||||
File /r "${SOURCEPATH}\README.txt"
|
||||
File /r "${SOURCEPATH}\FAQ.pdf"
|
||||
File /r "${SOURCEPATH}\Getting-Started.pdf"
|
||||
|
||||
;Store installation folder
|
||||
WriteRegStr HKCU "Software\SyncThing" "" $INSTDIR
|
||||
|
||||
;Create uninstaller
|
||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section "Command Line Interface" SecSyncThingCLI
|
||||
|
||||
SetOutPath "$INSTDIR"
|
||||
|
||||
File /r "${SOURCEPATH}\syncthing-cli.exe"
|
||||
|
||||
SectionEnd
|
||||
|
||||
Section "Windows Service" SecSyncThingService
|
||||
|
||||
SetOutPath "$INSTDIR"
|
||||
|
||||
File /r "${SOURCEPATH}\syncthingservice.exe"
|
||||
File /r "${SOURCEPATH}\syncthingservice.xml"
|
||||
|
||||
ExecWait 'syncthingservice.exe install'
|
||||
ExecWait 'syncthingservice.exe start'
|
||||
|
||||
SectionEnd
|
||||
|
||||
;--------------------------------
|
||||
;Descriptions
|
||||
|
||||
;Language strings
|
||||
LangString DESC_SecSyncThing ${LANG_ENGLISH} "SyncThing"
|
||||
LangString DESC_SecSyncThingCLI ${LANG_ENGLISH} "Command Line Interface"
|
||||
LangString DESC_SecSyncThingService ${LANG_ENGLISH} "Windows Service"
|
||||
|
||||
;Assign language strings to sections
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecSyncThing} $(DESC_SecSyncThing)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecSyncThingCLI} $(DESC_SecSyncThingCLI)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecSyncThingService} $(DESC_SecSyncThingService)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
||||
;--------------------------------
|
||||
;Uninstaller Section
|
||||
|
||||
Section "Uninstall"
|
||||
|
||||
Delete "$INSTDIR\Uninstall.exe"
|
||||
|
||||
RMDir "$INSTDIR"
|
||||
|
||||
DeleteRegKey /ifempty HKCU "Software\SyncThing"
|
||||
|
||||
SectionEnd
|
8
etc/windows/syncthingservice.xml
Normal file
8
etc/windows/syncthingservice.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<service>
|
||||
<id>Syncthing</id>
|
||||
<name>Syncthing</name>
|
||||
<description>This service runs Syncthing</description>
|
||||
<executable>syncthing.exe</executable>
|
||||
<arguments>-home .\ServiceHome -no-console -no-browser</arguments>
|
||||
<logmode>rotate</logmode>
|
||||
</service>
|
Loading…
Reference in New Issue
Block a user