Merge pull request #1407 from bencurthoys/master

Windows Service Setup.exe
This commit is contained in:
Jakob Borg 2015-03-07 14:38:43 +01:00
commit 55d9514e83
3 changed files with 137 additions and 0 deletions

13
etc/windows/ReadMe.txt Normal file
View 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

View 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

View 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>