You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1017 B

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #!/usr/bin/php
  2. <?php
  3. function run_command( $CMD ){
  4. $FD = @popen( $CMD, "r" );
  5. if( $FD ){
  6. while (($buffer = fgets( $FD ) ) !== false ){
  7. echo $buffer;
  8. };
  9. if( !feof( $FD ) ){
  10. echo "Error: unexpected fgets() failure\n";
  11. }
  12. pclose($FD);
  13. };
  14. };
  15. if( isset( $argv[1] ) ){
  16. if( $argv[1] != '/srv' && $argv[1] != '/srv/' ){
  17. $L="tar -cvjf /srv/tmp/upgrade.tar.bz2 --absolute-names -C {$argv[1]} .";
  18. run_command( $L );
  19. $MD5 = md5_file( '/srv/tmp/upgrade.tar.bz2' );
  20. chdir( './pp_cc' );
  21. $L = trim(`/usr/bin/php create_backup_cert.php {$MD5}`);
  22. echo "Cert: {$L}\n";
  23. copy( $L ,'/srv/tmp/manifest.crt' );
  24. unlink( $L );
  25. $L="tar -cvjf /srv/package.tar.bz2 --absolute-names -C /srv/tmp .";
  26. run_command( $L );
  27. unlink( '/srv/tmp/'.$L );
  28. unlink( '/srv/tmp/upgrade.tar.bz2' );
  29. } else {
  30. echo "It's a bad idea to create package of your own [/srv] folder\n";
  31. };
  32. } else {
  33. echo "Usage {$argv[0]} [path_to_a_tree]\n";
  34. };
  35. ?>