linuxgen 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. include ('api.1984tech.php');
  3. $tech = new OrwellWorld();
  4. //need at least 1 command line argument
  5. if ($argc >= 2) {
  6. $allowedOptions = array(
  7. '--ipset' => 'preview ipset update script to stdout',
  8. '--iptables' => 'preview iptables update script to stdout',
  9. '--resolve' => 'render IPs list of loaded domains',
  10. '--ipsetupdate' => 'run ipset update script',
  11. '--iptablesupdate' => 'run iptables update script',
  12. '--help' => 'show small help'
  13. );
  14. $option = $argv[1];
  15. if (isset($allowedOptions[$option])) {
  16. switch ($option) {
  17. case '--ipset':
  18. print($tech->getIpsetScript());
  19. break;
  20. case '--ipsetupdate':
  21. print($tech->getIpsetScript(true));
  22. break;
  23. case '--iptables':
  24. print($tech->getIptablesScript());
  25. break;
  26. case '--iptablesupdate':
  27. print($tech->getIptablesScript(true));
  28. break;
  29. case '--resolve':
  30. print($tech->renderDomainsIps());
  31. break;
  32. case '--help':
  33. print('Usage: php cli/linuxgen --option' . PHP_EOL);
  34. print('Available options:' . PHP_EOL);
  35. if (!empty($allowedOptions)) {
  36. foreach ($allowedOptions as $optionName => $optionDesc) {
  37. print($optionName . ' - ' . $optionDesc . PHP_EOL);
  38. }
  39. }
  40. break;
  41. }
  42. } else {
  43. print('Unknown command line option: ' . $option . PHP_EOL);
  44. }
  45. } else {
  46. //option requirement notification
  47. print('At least one option required.' . PHP_EOL);
  48. print('Usage: php cli/linuxgen --option' . PHP_EOL);
  49. print('For example: php cli/linuxgen --help' . PHP_EOL);
  50. }