-
Notifications
You must be signed in to change notification settings - Fork 9
/
restore.nsi
78 lines (64 loc) · 2.34 KB
/
restore.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;--------------------------------
;Defines
!include "MUI2.nsh"
!include "Registry.nsh"
!include "Sections.nsh"
Name "UgandaEMR Restore"
!define MUI_ICON "software/favicon.ico"
!define MUI_UNICON "software/favicon.ico"
Var SMDir ;Start menu folder
Var errorsrc
;!define MUI_STARTMENUPAGE_DEFAULTFOLDER "MY Program" ;Default, name is used if not defined
!define MUI_HEADERIMAGE_BITMAP "software\logo.bmp"
!define MUI_HEADERIMAGE_RIGHT
RequestExecutionLevel admin
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
OutFile "includes\scripts\restore.exe"
;-------------------------Splash Screen For installer--------------------------------
Var RestoreFilePath
XPStyle on
Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
;===========================================Installer Sections============================================
;Restore database in UgandaEMR
Section 'Restore Database' -SecRestoreDB
SectionIn RO
nsDialogs::SelectFileDialog mode initial_selection open
Pop $0
StrCpy $RestoreFilePath $0
MessageBox MB_OK "Path to the Database file to be restored [$RestoreFilePath]"
nsExec::Exec 'C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql -uopenmrs -popenmrs -e "drop database openmrs"'
nsExec::Exec 'C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql -uopenmrs -popenmrs -e "CREATE database openmrs"'
importdbs:
DetailPrint "SQL file import"
ExecWait '"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql" --user=openmrs --password=openmrs --execute="source $RestoreFilePath" openmrs' $2
StrCmp $2 1 0 endinst
StrCpy $errorsrc "File import error"
Goto abortinst
abortinst:
DetailPrint " "
DetailPrint "$\n An error occured ! $\n"
DetailPrint " $errorsrc "
DetailPrint " "
endinst:
SectionEnd
;--------------------------------