-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blow up checkcommands (Import custom commands in 1.5)
- Loading branch information
NEMS Linux
committed
Aug 23, 2019
1 parent
8138a6b
commit 7fa2375
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,17 @@ | |||
#!/usr/bin/env php | |||
<?php | |||
// blow up checkcommands | |||
// This simply breaks a checkcommandsfile into separate files for each check_command. That way the importer can fail on one but will still continue to import the rest. | |||
if (!isset($argv) || !isset($argv[1]) || !isset($argv[2])) { | |||
exit('Usage: ' . $argv[0] . ' /path/checkcommands.cfg /tmp/path' . PHP_EOL); | |||
} | |||
if (!file_exists($argv[2])) mkdir($argv[2]); | |||
$data = file_get_contents($argv[1]); | |||
$dataArr = explode('}', $data); | |||
$v=0; | |||
if (is_array($dataArr)) { | |||
foreach ($dataArr as $block) { | |||
file_put_contents($argv[2].'/'.$v++.'.cfg',$block.PHP_EOL.'}'); | |||
} | |||
} | |||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters