From f0a88061db338e2776a34a003f829d18958739a0 Mon Sep 17 00:00:00 2001 From: bencurthoys Date: Fri, 6 Mar 2015 11:51:49 +0000 Subject: [PATCH] Setup.exe for Windows NSIS script to build setup file to install Syncthing and install as a service. --- etc/windows/ReadMe.txt | 13 ++++ etc/windows/SyncThingSetup.nsi | 116 +++++++++++++++++++++++++++++++ etc/windows/syncthingservice.xml | 8 +++ 3 files changed, 137 insertions(+) create mode 100644 etc/windows/ReadMe.txt create mode 100644 etc/windows/SyncThingSetup.nsi create mode 100644 etc/windows/syncthingservice.xml diff --git a/etc/windows/ReadMe.txt b/etc/windows/ReadMe.txt new file mode 100644 index 000000000..bd3db14b4 --- /dev/null +++ b/etc/windows/ReadMe.txt @@ -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 diff --git a/etc/windows/SyncThingSetup.nsi b/etc/windows/SyncThingSetup.nsi new file mode 100644 index 000000000..d5b9b58ca --- /dev/null +++ b/etc/windows/SyncThingSetup.nsi @@ -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 \ No newline at end of file diff --git a/etc/windows/syncthingservice.xml b/etc/windows/syncthingservice.xml new file mode 100644 index 000000000..b7d434293 --- /dev/null +++ b/etc/windows/syncthingservice.xml @@ -0,0 +1,8 @@ + + Syncthing + Syncthing + This service runs Syncthing + syncthing.exe + -home .\ServiceHome -no-console -no-browser + rotate + \ No newline at end of file