@@ -14,40 +14,40 @@ |
||
| 14 | 14 | |
| 15 | 15 | if (!array_key_exists('v',$options) || !array_key_exists('c',$options) || !array_key_exists('b',$options)) |
| 16 | 16 | { |
| 17 | - printf("Need version -v, database -b (mysql,pgsql) command -c (create/update)\n"); |
|
| 18 | - exit(1); |
|
| 17 | + printf("Need version -v, database -b (mysql,pgsql) command -c (create/update)\n"); |
|
| 18 | + exit(1); |
|
| 19 | 19 | } |
| 20 | 20 | $command=$options['c']; |
| 21 | 21 | $path=$options['a']; |
| 22 | 22 | try { |
| 23 | - switch($command) |
|
| 24 | - { |
|
| 25 | - case 'create': |
|
| 26 | - $schema=($options['b']=='mysql')?'schema_v'.$options['v'].'.sql':'schema_v'.$options['v'].'.pgsql'; |
|
| 27 | - $schema=$path.'/SQL/'.$schema; |
|
| 28 | - $trap->trapsDB->create_schema($schema, 'traps_'); |
|
| 29 | - break; |
|
| 30 | - case 'update': |
|
| 31 | - $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_',true); |
|
| 32 | - printf("Update message : %s\n",$message); |
|
| 33 | - if ($message == 'ERROR') |
|
| 34 | - { |
|
| 35 | - exit(1); |
|
| 36 | - } |
|
| 37 | - printf("Messages DONE, updating : \n"); |
|
| 38 | - $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_'); |
|
| 39 | - if ($message == 'ERROR') |
|
| 40 | - { |
|
| 41 | - exit(1); |
|
| 42 | - } |
|
| 43 | - break; |
|
| 44 | - default: |
|
| 45 | - prtinf("Unknown command\n"); |
|
| 46 | - exit(1); |
|
| 47 | - } |
|
| 23 | + switch($command) |
|
| 24 | + { |
|
| 25 | + case 'create': |
|
| 26 | + $schema=($options['b']=='mysql')?'schema_v'.$options['v'].'.sql':'schema_v'.$options['v'].'.pgsql'; |
|
| 27 | + $schema=$path.'/SQL/'.$schema; |
|
| 28 | + $trap->trapsDB->create_schema($schema, 'traps_'); |
|
| 29 | + break; |
|
| 30 | + case 'update': |
|
| 31 | + $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_',true); |
|
| 32 | + printf("Update message : %s\n",$message); |
|
| 33 | + if ($message == 'ERROR') |
|
| 34 | + { |
|
| 35 | + exit(1); |
|
| 36 | + } |
|
| 37 | + printf("Messages DONE, updating : \n"); |
|
| 38 | + $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_'); |
|
| 39 | + if ($message == 'ERROR') |
|
| 40 | + { |
|
| 41 | + exit(1); |
|
| 42 | + } |
|
| 43 | + break; |
|
| 44 | + default: |
|
| 45 | + prtinf("Unknown command\n"); |
|
| 46 | + exit(1); |
|
| 47 | + } |
|
| 48 | 48 | } catch (Exception $e) { |
| 49 | - printf("Caught Exception %s\n",$e->getMessage()); |
|
| 50 | - exit (1); |
|
| 49 | + printf("Caught Exception %s\n",$e->getMessage()); |
|
| 50 | + exit (1); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | exit(0); |
@@ -3,16 +3,16 @@ discard block |
||
| 3 | 3 | // TODO |
| 4 | 4 | require_once 'bin/trap_class.php'; |
| 5 | 5 | |
| 6 | -$options = getopt("c:v:d:b:a:"); |
|
| 6 | +$options=getopt("c:v:d:b:a:"); |
|
| 7 | 7 | |
| 8 | -$icingaweb2Etc=(array_key_exists('d',$options))?$options['d']:"/etc/icingaweb2"; |
|
| 8 | +$icingaweb2Etc=(array_key_exists('d', $options)) ? $options['d'] : "/etc/icingaweb2"; |
|
| 9 | 9 | |
| 10 | -$debugLevel=4;// 0=No output 1=critical 2=warning 3=trace 4=ALL |
|
| 10 | +$debugLevel=4; // 0=No output 1=critical 2=warning 3=trace 4=ALL |
|
| 11 | 11 | |
| 12 | -$trap = new trap($icingaweb2Etc,$debugLevel,'display'); |
|
| 13 | -$trap->setLogging($debugLevel,'display'); |
|
| 12 | +$trap=new trap($icingaweb2Etc, $debugLevel, 'display'); |
|
| 13 | +$trap->setLogging($debugLevel, 'display'); |
|
| 14 | 14 | |
| 15 | -if (!array_key_exists('v',$options) || !array_key_exists('c',$options) || !array_key_exists('b',$options)) |
|
| 15 | +if (!array_key_exists('v', $options) || !array_key_exists('c', $options) || !array_key_exists('b', $options)) |
|
| 16 | 16 | { |
| 17 | 17 | printf("Need version -v, database -b (mysql,pgsql) command -c (create/update)\n"); |
| 18 | 18 | exit(1); |
@@ -20,22 +20,22 @@ discard block |
||
| 20 | 20 | $command=$options['c']; |
| 21 | 21 | $path=$options['a']; |
| 22 | 22 | try { |
| 23 | - switch($command) |
|
| 23 | + switch ($command) |
|
| 24 | 24 | { |
| 25 | 25 | case 'create': |
| 26 | - $schema=($options['b']=='mysql')?'schema_v'.$options['v'].'.sql':'schema_v'.$options['v'].'.pgsql'; |
|
| 26 | + $schema=($options['b'] == 'mysql') ? 'schema_v'.$options['v'].'.sql' : 'schema_v'.$options['v'].'.pgsql'; |
|
| 27 | 27 | $schema=$path.'/SQL/'.$schema; |
| 28 | 28 | $trap->trapsDB->create_schema($schema, 'traps_'); |
| 29 | 29 | break; |
| 30 | 30 | case 'update': |
| 31 | - $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_',true); |
|
| 32 | - printf("Update message : %s\n",$message); |
|
| 31 | + $message=$trap->trapsDB->update_schema($path."/SQL/", $options['v'], 'traps_', true); |
|
| 32 | + printf("Update message : %s\n", $message); |
|
| 33 | 33 | if ($message == 'ERROR') |
| 34 | 34 | { |
| 35 | 35 | exit(1); |
| 36 | 36 | } |
| 37 | 37 | printf("Messages DONE, updating : \n"); |
| 38 | - $message=$trap->trapsDB->update_schema($path."/SQL/",$options['v'], 'traps_'); |
|
| 38 | + $message=$trap->trapsDB->update_schema($path."/SQL/", $options['v'], 'traps_'); |
|
| 39 | 39 | if ($message == 'ERROR') |
| 40 | 40 | { |
| 41 | 41 | exit(1); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | exit(1); |
| 47 | 47 | } |
| 48 | 48 | } catch (Exception $e) { |
| 49 | - printf("Caught Exception %s\n",$e->getMessage()); |
|
| 49 | + printf("Caught Exception %s\n", $e->getMessage()); |
|
| 50 | 50 | exit (1); |
| 51 | 51 | } |
| 52 | 52 | |