-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathreset.nsi
96 lines (81 loc) · 3.51 KB
/
reset.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
;--------------------------------
;Defines
!include "MUI2.nsh"
!include "Registry.nsh"
!include "Sections.nsh"
Name "Uganda EMR Reset"
!define JavaRegKey 'HKLM "Software\JavaSoft\Java Runtime Environment" ""'
!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_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
InstallDir "$PROGRAMFILES\UgandaEMR" ;This line creates a default location for the installation. Note that $PROGRAMFILES is a constant value provided by NSIS
DirText "OpenMrs will install in this directory"
!define instDirectory "$PROGRAMFILES\UgandaEMR"
OutFile "includes\scripts\reset.exe"
;-------------------------Splash Screen For installer--------------------------------
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}
# the plugins dir is automatically deleted when the installer exits
InitPluginsDir
File /oname=$PLUGINSDIR\splash.bmp "includes\splash.bmp"
advsplash::show 5000 600 400 -1 $PLUGINSDIR\splash
Pop $0 ; $0 has '1' if the user closed the splash screen early,
; '0' if everything closed normally, and '-1' if some error occurred.
FunctionEnd
;===========================================Installer Sections============================================
;Generating openmrs 1.11.6 database
Section -defaultDatabase
DetailPrint "Running import"
StrCmp $createdb 1 importdbs
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"'
;nsExec::Exec 'C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql -uroot -e "SET PASSWORD FOR $\'root$\'@$\'localhost$\' =$\'openMRS$\'"'
SetOutPath "$DESKTOP\"
File 'includes\databases\default\concept_dictonary_ref.sql'
SetOutPath "$DESKTOP\"
File 'includes\databases\default\new-install.sql'
DetailPrint '..Add default database exit code = $0'
importdbs:
DetailPrint "SQL file import"
ExecWait '"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql" --user=openmrs --password=openmrs --execute="source $DESKTOP\new-install.sql" openmrs' $2
ExecWait '"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql" --user=openmrs --password=openmrs --execute="source $DESKTOP\concept_dictonary_ref.sql" 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:
Delete '$DESKTOP\concept_dictonary_ref.sql'
Delete '$DESKTOP\new-install.sql'
SetOverwrite on
SetOutPath "C:\Application Data\"
File /r "includes\Configurations\OpenMRS"
SectionEnd
;--------------------------------