Skip to content

Instantly share code, notes, and snippets.

@unicolet
Created January 12, 2012 22:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save unicolet/1603679 to your computer and use it in GitHub Desktop.
Save unicolet/1603679 to your computer and use it in GitHub Desktop.
Nullsoft script to create an installer for a rsync Windows Service package based on cygwin
;NSIS Modern User Interface
;Rsync Windows Service Script
;Written by Umberto Nicoletti http://unicolet.blogspot.com/
!define SCRIPT_VERSION "1.0"
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
;--------------------------------
;General
;Name and file
Name "Rsync Service"
OutFile "rsync_svc.exe"
;Default installation folder
InstallDir "C:\cygwin"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\gnu_rsync" "rsync_svc"
;Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!define MUI_WELCOMEPAGE_TITLE "Rsync Service"
!define MUI_WELCOMEPAGE_TITLE_3LINES ""
!define MUI_WELCOMEPAGE_TEXT "Welcome to the setup for rsync."
!define MUI_FINISHPAGE_TITLE "Rsync Service"
!define MUI_FINISHPAGE_TEXT "You have successfully completed the installation."
!insertmacro MUI_PAGE_WELCOME
page custom CustomCreate
; !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_TEXT "The application has been removed from the system."
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Install packages section." SecInstallPkgs
SetOutPath "$INSTDIR"
;ADD YOUR OWN FILES HERE...
File /r "cygwin\*.*"
;Store installation folder
WriteRegStr HKCU "Software\gnu_rsync" "rsync_svc" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall_rsync_svc.exe"
;
; Create the bat to automate service installation/uninstallation
; Remember that the /etc/rsyncd.conf must exist and must be correct
; to be able to start the service.
; For an example see: http://unicolet.blogspot.com/2012/01/rsync-or-any-other-cygwin-daemon-as.html
;
ReadEnvStr $4 COMSPEC
nsExec::ExecToLog '$4 /c "$INSTDIR\service_install.bat" $INSTDIR'
SectionEnd
;--------------------------------
;Descriptions
;Language strings
LangString DESC_SecInstallPkgs ${LANG_ENGLISH} "Install packages section."
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecInstallPkgs} $(DESC_SecInstallPkgs)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
;
; Create the bat to automate service installation/uninstallation
; For an example see: http://unicolet.blogspot.com/2012/01/rsync-or-any-other-cygwin-daemon-as.html
;
ReadEnvStr $4 COMSPEC
nsExec::ExecToLog '$4 /c "$INSTDIR\service_uninstall.bat" $INSTDIR'
;ADD YOUR OWN FILES HERE...
Delete "$INSTDIR\Uninstall_rsync_svc.exe"
RMDir "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\gnu_rsync"
SectionEnd
Function CustomCreate
Push $1 ;park value to the stack
InstallOptions::initDialog /NOUNLOAD '$PLUGINSDIR\alert.ini'
Pop $1 ;get dialog HWND
ReadINIStr $2 "$PLUGINSDIR\custom.ini" "Field 1" "HWND"
SetCtlColors $2 0x0000FF 0xFFFFFF
CreateFont $3 "Tahoma" 7 800
SendMessage $2 ${WM_SETFONT} $3 0
InstallOptions::show
Pop $1 ;get button action
Pop $1 ;get custom.ini full path
Pop $1 ;get back value from stack
FunctionEnd
Function .onInit
initpluginsdir
#file /oname=$PLUGINSDIR\alert.ini alert.ini
FunctionEnd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment