finish.ps1 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #Includes
  2. . .\resources\config.ps1
  3. . .\resources\write-log.ps1
  4. . .\resources\domain_name.ps1
  5. . .\resources\get-database_password.ps1
  6. . .\resources\get-system_password.ps1
  7. . .\resources\start-pgsql.ps1
  8. #Temp Permissions
  9. $Acl = Get-Acl "C:/inetpub/FusionPBX"
  10. $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("EVERYONE", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
  11. $Acl.SetAccessRule($Ar)
  12. Set-Acl "C:/inetpub/FusionPBX" $Acl
  13. $psql = "C:\Program Files\PostgreSQL\10\bin\psql.exe -U fusionpbx"
  14. #add the config.php
  15. Copy-Item "./resources/fusionpbx/config.php" "C:/inetpub/FusionPBX/resources"
  16. $filename = "C:/inetpub/FusionPBX/resources/config.php"
  17. (Get-Content $filename) -replace "{database_username}","fusionpbx" `
  18. -replace "{database_password}",$database_password | Out-File $filename
  19. #add the database schema
  20. Start-Process "C:\Program Files\PHP\v7.1\php.exe" "C:/inetpub/FusionPBX/core/upgrade/upgrade_schema.php"
  21. #get the domain_uuid
  22. [string]$domain_uuid = [System.Guid]::NewGuid()
  23. #add the domain name
  24. "C:\Program Files\PostgreSQL\10\bin\psql.exe -U fusionpbx insert into v_domains (domain_uuid, domain_name, domain_enabled) values('$domain_uuid', '$domain_name', 'true');"
  25. #app defaults
  26. Start-Process "C:\Program Files\PHP\v7.1\php.exe" "C:/inetpub/FusionPBX/core/upgrade/upgrade_domains.php"
  27. #add the user
  28. [string]$user_uuid = [System.Guid]::NewGuid()
  29. [string]$user_salt = [System.Guid]::NewGuid()
  30. $user_name=$system_username
  31. if ($system_password -eq 'random') {
  32. $user_password = New-Password 20
  33. }
  34. else {
  35. $user_password=$system_password
  36. }
  37. $password_hash = ."C:\Program Files\PHP\v7.1\php.exe" "-r echo md5('$user_salt$user_password');"
  38. "$psql insert into v_users (user_uuid, domain_uuid, username, password, salt, user_enabled) values('$user_uuid', '$domain_uuid', '$user_name', '$password_hash', '$user_salt', 'true');"
  39. #get the superadmin group_uuid
  40. "$psql select group_uuid from v_groups where group_name = 'superadmin';"
  41. #add the user to the group
  42. [string]$user_group_uuid = [System.Guid]::NewGuid()
  43. $group_name="superadmin"
  44. "$psql insert into v_user_groups (user_group_uuid, domain_uuid, group_name, group_uuid, user_uuid) values('$user_group_uuid', '$domain_uuid', '$group_name', '$group_uuid', '$user_uuid');"
  45. #app defaults
  46. Start-Process "C:\Program Files\PHP\v7.1\php.exe" "C:/inetpub/FusionPBX/core/upgrade/upgrade_domains.php"
  47. #Permissions back to readonly
  48. $Acl = Get-Acl "C:/inetpub/FusionPBX"
  49. $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("EVERYONE", "Read", "ContainerInherit,ObjectInherit", "None", "Allow")
  50. $Acl.SetAccessRule($Ar)
  51. Set-Acl "C:/inetpub/FusionPBX" $Acl
  52. #welcome message
  53. Write-Log ""
  54. Write-Log " Use a web browser to continue setup."
  55. Write-Log " domain name: https://$domain_name"
  56. Write-Log " username: $system_username"
  57. Write-Log " password: $system_password"
  58. Write-Log ""
  59. Write-Log " The domain name in the browser is used by default as part of the authentication."
  60. Write-Log " If you need to login to a different domain then use username@domain."
  61. Write-Log " username: $system_username@$domain_name";
  62. Write-Log ""
  63. Write-Log " Database:"
  64. Write-Log " username: postgres"
  65. Write-Log " password: $database_password"
  66. Write-Log ""
  67. Write-Log " Additional information."
  68. Write-Log " https://fusionpbx.com/support.php"
  69. Write-Log " https://www.fusionpbx.com"
  70. Write-Log " http://docs.fusionpbx.com"
  71. #Start login page
  72. #Start-Process http://$domain_name
  73. Write-Log " Press any key to close this window."
  74. Write-Log " Please copy the important info first."
  75. cmd /c pause | out-null