0
+ − 1
/**
+ − 2
* Verify credentials for a PostgreSQL database. Assumes we are connecting to BitNami's DB.
+ − 3
* @param string Username
+ − 4
* @param string Password
+ − 5
* @return int 0 if successful, >0 on error. Will push an error string to the stack if >0.
+ − 6
*/
+ − 7
+ − 8
!macro postgresql_get_bin_dir
+ − 9
StrCpy $R2 "$stack_instdir\postgresql\bin"
+ − 10
!macroend
+ − 11
+ − 12
Function postgresql_connect
+ − 13
Pop $R1 ; Password
+ − 14
Pop $R0 ; Username
+ − 15
+ − 16
SetOutPath $PLUGINSDIR
+ − 17
File "inst-resources\postgresqlutil.php"
+ − 18
+ − 19
nsExec::ExecToLog '"$stack_instdir\php\php.exe" "$PLUGINSDIR\postgresqlutil.php" "$R0" "$R1"'
+ − 20
Delete "$PLUGINSDIR\postgresqlutil.php"
+ − 21
; just be done; nsExec's result is on the top of the stack.
+ − 22
FunctionEnd
+ − 23
+ − 24
/**
+ − 25
* Create a postgresql database and grant privileges on it to the given user.
+ − 26
* @param string User to connect with
+ − 27
* @param string Password to connect with
+ − 28
* @param string Database name
+ − 29
* @param string New user
+ − 30
* @param string New user's password
+ − 31
*/
+ − 32
+ − 33
Function postgresql_create_db
+ − 34
Pop $R5 ; Password
+ − 35
Pop $R4 ; User
+ − 36
Pop $R3 ; Database
+ − 37
Pop $R1 ; Password
+ − 38
Pop $R0 ; Username
+ − 39
+ − 40
/*
+ − 41
; This isn't a working feature in PostgreSQL.
+ − 42
IfFileExists "$stack_instdir\postgresql\data\$R3" 0 DatabaseDoesNotExist
+ − 43
MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "The database $\"$R3$\" already exists. Do you want to delete and recreate it?$\n$\nIf you choose No, Setup will not alter PostgreSQL's permissions, and you may need to set up permissions manually." IDYES +2
+ − 44
Return
+ − 45
+ − 46
DatabaseDoesNotExist:
+ − 47
*/
+ − 48
+ − 49
SetOutPath $PLUGINSDIR
+ − 50
File "inst-resources\postgresqlutil.php"
+ − 51
+ − 52
nsExec::ExecToLog '"$stack_instdir\php\php.exe" "$PLUGINSDIR\postgresqlutil.php" "$R0" "$R1" \
+ − 53
"DROP DATABASE IF EXISTS $R3; \
+ − 54
DROP ROLE IF EXISTS $R4; \
+ − 55
CREATE ROLE $R4 WITH PASSWORD $\'$R5$\' LOGIN; \
+ − 56
CREATE DATABASE $R3 WITH OWNER $R4;"'
+ − 57
Delete "$PLUGINSDIR\postgresqlutil.php"
+ − 58
FunctionEnd
+ − 59