index.php 892 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. require_once realpath(dirname(__FILE__)) . '/../common.php';
  3. require_once FRAMEWORK_PATH . 'protected/bin/common_script.php';
  4. if (!singleProcess(getCurrentCommand(), '/data/webapps/gitbook.duowan.com/duowan_wiki/index.pid')) {
  5. exit("Sorry, this script file has already been running ...\n");
  6. }
  7. error_reporting(E_ERROR);
  8. $cmdType = $_GET["cmd_type"]);
  9. function gitPull()
  10. {
  11. shell_exec("cd /data/webapps/gitbook.duowan.com/duowan_wiki && git pull");
  12. }
  13. function gitbookBuild()
  14. {
  15. shell_exec("cd /data/webapps/gitbook.duowan.com/duowan_wiki && gitbook build");
  16. }
  17. function gitbookInstall()
  18. {
  19. shell_exec("cd /data/webapps/gitbook.duowan.com/duowan_wiki && gitbook install");
  20. }
  21. if ("pull_rebuild" === $cmdType) {
  22. gitPull();
  23. gitbookBuild();
  24. }
  25. if ("install" === $cmdType) {
  26. gitPull();
  27. gitbookInstall()
  28. gitbookBuild();
  29. }
  30. header("HTTP/1.1 200 OK");
  31. echo("hook finish");