service configuration files that needs to be saved just incase the server got lost someday by the cloud provider.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

85 行
2.6KB

  1. #!/usr/bin/php
  2. <?php
  3. //
  4. //read environment variables
  5. //the shell variable $RENEWED_LINEAGE will point to the config live subdirectory
  6. //(for example, "/etc/letsencrypt/live/example.com") containing the new certs and
  7. //keys; the shell variable $RENEWED_DOMAINS will contain a space-delimited list
  8. //of renewed cert domains (for example, "example.com www.example.com").
  9. $domains = explode(" ", getenv('RENEWED_DOMAINS'));
  10. //update each domain
  11. foreach ($domains as $d) {
  12. echo "update $d \n";
  13. if ($d=="supercredit.com.au"){
  14. // install_to_cpanel();
  15. }
  16. }
  17. //restart nginx webserver.
  18. exec('/usr/sbin/service nginx reload');
  19. function install_to_cpanel()
  20. {
  21. //https://documentation.cpanel.net/display/DD/Tutorial+-+Call+UAPI%27s+SSL%3A%3Ainstall_ssl+Function+in+Custom+Code
  22. // Log everything during development.
  23. // If you run this on the CLI, set 'display_errors = On' in php.ini.
  24. error_reporting(E_ALL);
  25. // Declare your username and password for authentication.
  26. $username = 'supercreditcom';
  27. $password = 'P#SdlnWQ$+mW';
  28. // Define the API call.
  29. $cpanel_host = 'biz96.biukop.com.au';
  30. $request_uri = "https://$cpanel_host:2083/execute/SSL/install_ssl";
  31. // Define the SSL certificate and key files.
  32. $cert_file = realpath("/etc/letsencrypt/live/supercredit.com.au/cert.pem");
  33. $key_file = realpath("/etc/letsencrypt/live/supercredit.com.au/privkey.pem");
  34. $chain_file = realpath("/etc/letsencrypt/live/supercredit.com.au/chain.pem");
  35. // Set up the payload to send to the server.
  36. $payload = array(
  37. 'domain' => "supercredit.com.au",
  38. 'cert' => file_get_contents($cert_file),
  39. 'key' => file_get_contents($key_file),
  40. 'cabundle'=> file_get_contents($chain_file),
  41. );
  42. // Set up the cURL request object.
  43. $ch = curl_init( $request_uri );
  44. curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
  45. curl_setopt( $ch, CURLOPT_USERPWD, $username . ':' . $password );
  46. curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  47. curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  48. // Set up a POST request with the payload.
  49. curl_setopt( $ch, CURLOPT_POST, true );
  50. curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
  51. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  52. // Make the call, and then terminate the cURL caller object.
  53. $curl_response = curl_exec( $ch );
  54. curl_close( $ch );
  55. // Decode and validate output.
  56. $response = json_decode( $curl_response );
  57. if( empty( $response ) ) {
  58. echo "The cURL call did not return valid JSON:\n";
  59. die( $response );
  60. } elseif ( !$response->status ) {
  61. echo "The cURL call returned valid JSON, but reported errors:\n";
  62. die( $response->errors[0] . "\n" );
  63. }
  64. // Print and exit.
  65. die( print_r( $response ) );
  66. }
  67. ?>