BASH   30

init.bat

Guest on 22nd August 2022 07:53:27 AM

  1. @ECHO OFF
  2. SET PATH=%systemRoot%;%systemRoot%\system32;%PATH%
  3. SET lastDir=%cd%
  4. SET baseDir=%~dp0
  5. SET cronDir=%baseDir%cron\
  6. set sysCron=%cronDir%sys.cron
  7.  
  8. :: get phpcli and pmsRoot
  9. SET phpcli=%1
  10. SET pmsRoot=%2
  11. :input_php
  12. IF "%phpcli%"=="" SET /P phpcli="Please input your php path:(example: c:\windows\php.exe)"
  13. if "%phpcli%"=="" (
  14.     echo php path is error
  15.     goto input_php
  16. )
  17. if not exist %phpcli% (
  18.   echo php path is error
  19.   goto input_php
  20. )
  21. :input_url
  22. IF "%pmsRoot%"=="" SET /P pmsRoot="Please input zentao url:(example: http://localhost or http://127.0.0.1:88)"
  23. IF "%pmsRoot%"=="" (
  24.   echo zentao url is error
  25.   goto input_url
  26. )
  27.  
  28. :: get pmsRoot
  29. if "%pmsRoot:~-1%" == "/" SET pmsRoot=%pmsRoot:~0,-1%
  30. :: get requestType
  31. SET requestType= 'PATH_INFO'
  32. for /f "tokens=3" %%f in ('find /c "'PATH_INFO'" "%baseDir%..\config\my.php"') do set count=%%f
  33. if not defined count set count=1
  34. if %count% == 0 SET requestType='GET'
  35.  
  36. :: create ztcli
  37. SET ztcli= %phpcli% %baseDir%ztcli %%*
  38. echo %ztcli% > %baseDir%ztcli.bat
  39. echo ztcli.bat ok
  40.  
  41. :: create backup.bat
  42. SET backup= %phpcli% %baseDir%php\backup.php
  43. echo %backup% > %baseDir%backup.bat
  44. echo backup.bat ok
  45.  
  46. :: create dailyreminder.bat
  47. if %requestType% == 'PATH_INFO' (
  48.   SET computeburn= %phpcli% %baseDir%ztcli "%pmsRoot%/report-remind"
  49. )else (
  50.   SET computeburn= %phpcli% %baseDir%ztcli "%pmsRoot%/index.php?m=report&f=remind"
  51. )
  52. echo %computeburn% > %baseDir%dailyreminder.bat
  53. echo dailyreminder.bat ok
  54.  
  55. :: create computeburn.bat
  56. if %requestType% == 'PATH_INFO' (
  57.   SET computeburn= %phpcli% %baseDir%ztcli "%pmsRoot%/project-computeburn"
  58. )else (
  59.   SET computeburn= %phpcli% %baseDir%ztcli "%pmsRoot%/index.php?m=project&f=computeburn"
  60. )
  61. echo %computeburn% > %baseDir%computeburn.bat
  62. echo computeburn.bat ok
  63.  
  64. :: create checkdb.bat
  65. if %requestType% == 'PATH_INFO' (
  66.   SET checkdb= %phpcli% %baseDir%ztcli "%pmsRoot%/admin-checkdb"
  67. )else (
  68.   SET checkdb= %phpcli% %baseDir%ztcli "%pmsRoot%/index.php?m=admin&f=checkdb"
  69. )
  70. echo %checkdb% > %baseDir%checkdb.bat
  71. echo checkdb.bat ok
  72.  
  73. :: create syncsvn.bat
  74. if %requestType% == 'PATH_INFO' (
  75.   SET syncsvn= %phpcli% %baseDir%ztcli "%pmsRoot%/svn-run"
  76. )else (
  77.   SET syncsvn= %phpcli% %baseDir%ztcli "%pmsRoot%/index.php?m=svn&f=run"
  78. )
  79. echo %syncsvn% > %baseDir%syncsvn.bat
  80. echo syncsvn.bat ok
  81.  
  82. :: create syncgit.bat
  83. if %requestType% == 'PATH_INFO' (
  84.   SET syncgit= %phpcli% %baseDir%ztcli "%pmsRoot%/git-run"
  85. )else (
  86.   SET syncgit= %phpcli% %baseDir%ztcli "%pmsRoot%/index.php?m=git&f=run"
  87. )
  88. echo %syncgit% > %baseDir%syncgit.bat
  89. echo syncgit.bat ok
  90.  
  91. :: create crond.bat
  92. SET cron= %phpcli% %baseDir%php\crond.php
  93. echo %cron% > %baseDir%crond.bat
  94. echo crond.bat ok
  95.  
  96. :: create system cron.
  97. if not exist %cronDir% md %cronDir%
  98. echo # system cron. > %sysCron%
  99. echo #min   hour day month week  command. >> %sysCron%
  100. echo 0      1    *   *     *     %baseDir%dailyreminder.bat # daily reminder.           >> %sysCron%
  101. echo 1      1    *   *     *     %baseDir%backup.bat        # backup database and file. >> %sysCron%
  102. echo 1      23   *   *     *     %baseDir%computeburn.bat   # compute burndown chart.   >> %sysCron%
  103. echo 1-59/2 *    *   *     *     %baseDir%syncsvn.bat       # sync subversion.          >> %sysCron%
  104. echo 1-59/2 *    *   *     *     %baseDir%syncgit.bat       # sync git.                 >> %sysCron%
  105.  
  106. :: return 0 when success.
  107. exit /b 0

Raw Paste


Login or Register to edit or fork this paste. It's free.