Skip to content

Commit 1ef47fc

Browse files
committed
windows installer 2.2.9
1 parent 4a3c889 commit 1ef47fc

File tree

2 files changed

+40
-29
lines changed

2 files changed

+40
-29
lines changed

packaging/win/mamonsu.def.nsh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
!define NAME Mamonsu
2-
!define VERSION 2.2.0
2+
!define VERSION 2.2.9
33
!define MAMONSU_REG_PATH "Software\PostgresPro\Mamonsu"
44
!define MAMONSU_REG_UNINSTALLER_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall"
55
!define EDB_REG "SOFTWARE\Postgresql"
66
!define PGPRO_REG_1C "SOFTWARE\Postgres Professional\PostgresPro 1C"
77
!define PGPRO_REG_32 "SOFTWARE\PostgresPro\X86"
88
!define PGPRO_REG_64 "SOFTWARE\PostgresPro\X64"
99
!define USER "mamonsu"
10+
!define CONFIG_FILE "agent.conf"
11+
!define EXE_FILE "mamonsu.exe"
12+
!define OLD_EXE_FILE "agent.exe"
13+
!define LOG_FILE "mamonsu.log"
14+
!define SERVICE_FILE "service_win32.exe"
15+
!define TEMPLATE_FILE "template_win32.xml"
1016

1117
!define SERVICE_NAME "mamonsu"
1218
!define SERVICE_DISPLAY_NAME "Monitoring agent: mamonsu"
1319
!define SERVICE_TYPE "16" ; service that runs in its own process
1420
!define SERVICE_START_TYPE "2" ; automatic start
1521
!define SERVICE_DEPENDENCIES "EventLog"
1622
!define SERVICE_DESCRIPTION "mamonsu service"
17-
!define LOG_FILE "mamonsu.log"
1823

1924
LangString PG_TITLE ${LANG_ENGLISH} "PostgreSQL"
2025
LangString PG_SUBTITLE ${LANG_ENGLISH} "Server options of PostgreSQL instance you want to monitor"

packaging/win/mamonsu.nsi

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ SpaceTexts none
9090
; Finish page
9191
!define MUI_FINISHPAGE_NOAUTOCLOSE
9292
!define MUI_FINISHPAGE_SHOWREADME_TEXT "show config"
93-
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\mamonsu.conf"
93+
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\${CONFIG_FILE}"
9494
!insertmacro MUI_PAGE_FINISH
9595

9696
;Uninstall
@@ -120,15 +120,15 @@ Section "${NAME} ${VERSION}" SectionMamonsu
120120
${endif}
121121

122122
SetOutPath "$INSTDIR"
123-
File "..\..\dist\service_win32.exe"
124-
File "..\..\dist\mamonsu.exe"
125-
File "..\..\packaging\conf\template_win32.xml"
123+
File "..\..\dist\${SERVICE_FILE}"
124+
File "..\..\dist\${EXE_FILE}"
125+
File "..\..\packaging\conf\${TEMPLATE_FILE}"
126126
CreateDirectory "$log_dir"
127127
WriteUninstaller "$INSTDIR\Uninstall.exe"
128128

129129
;create user
130130
Call CreateUser
131-
;create mamonsu.conf
131+
;create agent.conf
132132
Call CreateConfig
133133
;create service
134134
Call CreateService
@@ -468,21 +468,21 @@ Function CreateConfig
468468
${if} $action == 'downgrade'
469469
${OrIf} $action == 'upgrade'
470470

471-
${if} ${FileExists} "$ext_inst_dir\mamonsu.conf"
472-
${ConfigRead} "$ext_inst_dir\mamonsu.conf" "file =" $0 ; put log_file_name in $0
471+
${if} ${FileExists} "$ext_inst_dir\${CONFIG_FILE}"
472+
${ConfigRead} "$ext_inst_dir\${CONFIG_FILE}" "file =" $0 ; put log_file_name in $0
473473
DetailPrint "Copying config file to new install directory ..."
474-
CopyFiles "$ext_inst_dir\mamonsu.conf" "$INSTDIR"
475-
${ConfigWrite} "$INSTDIR\mamonsu.conf" "file = " "$log_dir\${LOG_FILE}" $0
474+
CopyFiles "$ext_inst_dir\${CONFIG_FILE}" "$INSTDIR"
475+
${ConfigWrite} "$INSTDIR\${CONFIG_FILE}" "file = " "$log_dir\${LOG_FILE}" $0
476476
StrCpy $5 "exist"
477477
Goto recreate_config
478478
${else} ;do not exist
479479
Goto recreate_config
480480
${endif}
481481

482482
${elseif} $action == 'reinstall'
483-
${if} ${FileExists} "$ext_inst_dir\mamonsu.conf"
483+
${if} ${FileExists} "$ext_inst_dir\${CONFIG_FILE}"
484484
#if user decided to choose different log directory while reinstalling
485-
${ConfigWrite} "$ext_inst_dir\mamonsu.conf" "file = " "$log_dir\${LOG_FILE}" $0
485+
${ConfigWrite} "$ext_inst_dir\${CONFIG_FILE}" "file = " "$log_dir\${LOG_FILE}" $0
486486
Goto cancel
487487
${else}
488488
Goto recreate_config
@@ -511,7 +511,7 @@ Function CreateConfig
511511
[postgres]$\r$\nuser = $pg_user$\r$\ndatabase = $pg_db$\r$\npassword = $2$\r$\nhost = $pg_host$\r$\nport = $pg_port$\r$\n$\r$\n\
512512
[log]$\r$\nfile = $log_dir\${LOG_FILE}$\r$\nlevel = INFO$\r$\n'
513513
FileClose $0
514-
Rename $1 "$INSTDIR\mamonsu.conf"
514+
Rename $1 "$INSTDIR\${CONFIG_FILE}"
515515
${endif}
516516

517517
AccessControl::DisableFileInheritance "$INSTDIR"
@@ -535,11 +535,11 @@ Function CreateConfig
535535
AccessControl::GrantOnFile "$log_dir" "${USER}" "FullAccess"
536536
AccessControl::GrantOnFile "$log_dir" "${USER}" "AddFile"
537537

538-
AccessControl::SetFileOwner "$INSTDIR\service_win32.exe" "${USER}"
539-
AccessControl::GrantOnFile "$INSTDIR\service_win32.exe" "(S-1-3-0)" "FullAccess"
538+
AccessControl::SetFileOwner "$INSTDIR\${SERVICE_FILE}" "${USER}"
539+
AccessControl::GrantOnFile "$INSTDIR\${SERVICE_FILE}" "(S-1-3-0)" "FullAccess"
540540

541-
AccessControl::SetFileOwner "$INSTDIR\mamonsu.conf" "${USER}"
542-
AccessControl::GrantOnFile "$INSTDIR\mamonsu.conf" "(S-1-3-0)" "FullAccess"
541+
AccessControl::SetFileOwner "$INSTDIR\${CONFIG_FILE}" "${USER}"
542+
AccessControl::GrantOnFile "$INSTDIR\${CONFIG_FILE}" "(S-1-3-0)" "FullAccess"
543543
cancel:
544544
FunctionEnd
545545

@@ -596,7 +596,7 @@ Function CreateService
596596
${OrIf} $action == 'downgrade'
597597
DetailPrint "It`s upgrade/downgrade, service must be updated to reflect new path to binary"
598598
DetailPrint "Updating service ..."
599-
nsExec::ExecToStack /TIMEOUT=10000 '"$INSTDIR\service_win32.exe" update'
599+
nsExec::ExecToStack /TIMEOUT=10000 '"$INSTDIR\${SERVICE_FILE}" update'
600600
Pop $0
601601
Pop $1
602602
${if} $0 == 0
@@ -616,7 +616,7 @@ Function CreateService
616616
${endif}
617617
${endif}
618618
DetailPrint "Creating service ${SERVICE_NAME} ... "
619-
nsExec::ExecToStack /TIMEOUT=10000 '"$INSTDIR\service_win32.exe" --username "$hostname\${USER}" --password "$user_password" --startup delayed install'
619+
nsExec::ExecToStack /TIMEOUT=10000 '"$INSTDIR\${SERVICE_FILE}" --username "$hostname\${USER}" --password "$user_password" --startup delayed install'
620620
Pop $0
621621
Pop $1
622622
${if} $0 == 0
@@ -660,9 +660,13 @@ Function DeleteDirectory
660660
${if} $action == 'downgrade'
661661
${orif} $action == 'upgrade'
662662
DetailPrint "Deleting old install directory ..."
663-
Delete "$ext_inst_dir\mamonsu.conf"
664-
Delete "$ext_inst_dir\mamonsu.exe"
665-
Delete "$ext_inst_dir\service_win32.exe"
663+
Delete "$ext_inst_dir\${SERVICE_FILE}"
664+
Delete "$ext_inst_dir\${CONFIG_FILE}"
665+
Delete "$ext_inst_dir\${EXE_FILE}"
666+
${if} ${FileExists} "$ext_inst_dir\${OLD_EXE_FILE}"
667+
Delete "$ext_inst_dir\${OLD_EXE_FILE}"
668+
${endIf}
669+
Delete "$ext_inst_dir\${TEMPLATE_FILE}"
666670
Delete "$ext_inst_dir\Uninstall.exe"
667671
compare_log_dirs:
668672
${if} $ext_log_dir != $log_dir
@@ -677,7 +681,8 @@ FunctionEnd
677681
; Uninstall functions
678682
Function un.CheckExist
679683
;добавить проверку директории
680-
ReadRegStr $ext_log_dir HKLM "${MAMONSU_REG_PATH}" "LogDir"
684+
ReadRegStr $ext_log_dir HKLM "${MAMONSU_REG_PATH}\${VERSION}" "LogDir"
685+
MessageBox MB_OK "$ext_log_dir"
681686
FunctionEnd
682687

683688
Function un.DeleteService
@@ -690,9 +695,9 @@ Function un.DeleteService
690695
DetailPrint "Result: error"
691696
${EndIf}
692697

693-
#remove
698+
#remove service
694699
DetailPrint "Removing service mamonsu ..."
695-
nsExec::ExecToStack '"$INSTDIR\service_win32.exe" remove'
700+
nsExec::ExecToStack '"$INSTDIR\${SERVICE_FILE}" remove'
696701
Pop $0
697702
Pop $1
698703
${if} $0 == 0
@@ -733,9 +738,10 @@ Function un.DeleteReg
733738
FunctionEnd
734739

735740
Function un.DeleteDirectory
736-
Delete "$INSTDIR\mamonsu.conf"
737-
Delete "$INSTDIR\mamonsu.exe"
738-
Delete "$INSTDIR\service_win32.exe"
741+
Delete "$INSTDIR\${CONFIG_FILE}"
742+
Delete "$INSTDIR\${EXE_FILE}"
743+
Delete "$INSTDIR\${SERVICE_FILE}"
744+
Delete "$INSTDIR\${TEMPLATE_FILE}"
739745
Delete "$INSTDIR\Uninstall.exe"
740746
Delete "$ext_log_dir\${LOG_FILE}"
741747
RMDir "$ext_log_dir"

0 commit comments

Comments
 (0)