| @@ 63-108 (lines=46) @@ | ||
| 60 | EOF; |
|
| 61 | ||
| 62 | ||
| 63 | function check_input_parameters() |
|
| 64 | { |
|
| 65 | global $region; |
|
| 66 | global $secret; |
|
| 67 | global $key; |
|
| 68 | global $debug; |
|
| 69 | global $clientInfo; |
|
| 70 | global $argv; |
|
| 71 | ||
| 72 | // Handle input parameters |
|
| 73 | if (!($options = getopt("c:k::s::r::hd"))) |
|
| 74 | usage(); |
|
| 75 | if (isset($options['h'])) |
|
| 76 | usage(); |
|
| 77 | ||
| 78 | if (isset($options['d'])) |
|
| 79 | $debug = true; |
|
| 80 | ||
| 81 | if (isset($options['c'])) |
|
| 82 | { |
|
| 83 | $clientConfFile = $options['c']; |
|
| 84 | if (!file_exists($clientConfFile)) |
|
| 85 | throw new Exception("The client config file is not valid!"); |
|
| 86 | if (!($clientInfo = file_get_contents($clientConfFile))) |
|
| 87 | throw new Exception("Unable to read the file"); |
|
| 88 | } |
|
| 89 | else |
|
| 90 | throw new Exception("Please provide the client config file!"); |
|
| 91 | ||
| 92 | if (isset($options['k'])) |
|
| 93 | $key = $options['k']; |
|
| 94 | else |
|
| 95 | $key = getenv("AWS_ACCESS_KEY_ID"); |
|
| 96 | ||
| 97 | if (isset($options['s'])) |
|
| 98 | $secret = $options['s']; |
|
| 99 | else |
|
| 100 | $secret = getenv("AWS_SECRET_KEY"); |
|
| 101 | ||
| 102 | if (isset($options['r'])) |
|
| 103 | $region = $options['r']; |
|
| 104 | else |
|
| 105 | $region = getenv("AWS_DEFAULT_REGION"); |
|
| 106 | if (!$region) |
|
| 107 | throw new Exception("Please provide your AWS region as parameter or using AWS_DEFAULT_REGION env var !"); |
|
| 108 | } |
|
| 109 | ||
| 110 | function usage() |
|
| 111 | { |
|
| @@ 66-120 (lines=55) @@ | ||
| 63 | exit(0); |
|
| 64 | } |
|
| 65 | ||
| 66 | function check_input_parameters() |
|
| 67 | { |
|
| 68 | global $region; |
|
| 69 | global $secret; |
|
| 70 | global $key; |
|
| 71 | global $debug; |
|
| 72 | global $clientInfo; |
|
| 73 | global $argv; |
|
| 74 | ||
| 75 | // Handle input parameters |
|
| 76 | if (!($options = getopt("c:k::s::r::hd"))) { |
|
| 77 | usage(); |
|
| 78 | } |
|
| 79 | if (isset($options['h'])) { |
|
| 80 | usage(); |
|
| 81 | } |
|
| 82 | ||
| 83 | if (isset($options['d'])) { |
|
| 84 | $debug = true; |
|
| 85 | } |
|
| 86 | ||
| 87 | if (isset($options['c'])) |
|
| 88 | { |
|
| 89 | $clientConfFile = $options['c']; |
|
| 90 | if (!file_exists($clientConfFile)) { |
|
| 91 | throw new Exception("The client config file is not valid!"); |
|
| 92 | } |
|
| 93 | if (!($clientInfo = file_get_contents($clientConfFile))) { |
|
| 94 | throw new Exception("Unable to read the file"); |
|
| 95 | } |
|
| 96 | } else { |
|
| 97 | throw new Exception("Please provide the client config file!\n"); |
|
| 98 | } |
|
| 99 | ||
| 100 | if (isset($options['k'])) { |
|
| 101 | $key = $options['k']; |
|
| 102 | } else { |
|
| 103 | $key = getenv("AWS_ACCESS_KEY_ID"); |
|
| 104 | } |
|
| 105 | ||
| 106 | if (isset($options['s'])) { |
|
| 107 | $secret = $options['s']; |
|
| 108 | } else { |
|
| 109 | $secret = getenv("AWS_SECRET_KEY"); |
|
| 110 | } |
|
| 111 | ||
| 112 | if (isset($options['r'])) { |
|
| 113 | $region = $options['r']; |
|
| 114 | } else { |
|
| 115 | $region = getenv("AWS_DEFAULT_REGION"); |
|
| 116 | } |
|
| 117 | if (!$region) { |
|
| 118 | throw new Exception("Please provide your AWS region as parameter or using AWS_DEFAULT_REGION env var !"); |
|
| 119 | } |
|
| 120 | } |
|
| 121 | ||
| 122 | // Instanciate ComSDK to communicate with the stack |
|
| 123 | try { |
|