Make directory listing of tftpboot in xml
Create function to create a directory listing in xml for use by external apps to make download requests more specific Remove mkringlist.sh from tftpboot Output from createTftpBootXml Structure included
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
outfile=ringlist.xml
|
|
||||||
echo -e "<CiscoIPPhoneRingList>" >$outfile
|
|
||||||
if [ ! -z "`ls *.pcm 2>/dev/null`" ]; then
|
|
||||||
for filename in *.pcm;do
|
|
||||||
basename=`basename ${filename} .pcm`
|
|
||||||
echo -e "\t<Ring>" >>$outfile
|
|
||||||
echo -e "\t\t<DisplayName>${basename}</DisplayName>" >>$outfile
|
|
||||||
echo -e "\t\t<FileName>ringtones/${filename}</FileName>" >>$outfile
|
|
||||||
echo -e "\t</Ring>" >>$outfile
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if [ ! -z "`ls *.raw 2>/dev/null`" ]; then
|
|
||||||
for filename in *.raw;do
|
|
||||||
basename=`basename ${filename} .raw`
|
|
||||||
echo -e "\t<Ring>" >>$outfile
|
|
||||||
echo -e "\t\t<DisplayName>${basename}</DisplayName>" >>$outfile
|
|
||||||
echo -e "\t\t<FileName>ringtones/${filename}</FileName>" >>$outfile
|
|
||||||
echo -e "\t</Ring>" >>$outfile
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
echo -e "</CiscoIPPhoneRingList>" >>$outfile
|
|
||||||
|
|
37
tools/createTftpbootXmlStructure.php
Normal file
37
tools/createTftpbootXmlStructure.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
//Usage: php createTftpbootXmlStructure.php;
|
||||||
|
|
||||||
|
function createCats($currDirPos){
|
||||||
|
|
||||||
|
$xml = '';
|
||||||
|
|
||||||
|
if(is_dir($currDirPos)){
|
||||||
|
// Remove unix ./..
|
||||||
|
foreach (array_diff(scandir($currDirPos),array('.','..')) as $subDir) {
|
||||||
|
//remove link information
|
||||||
|
$subDir = (explode(' ', $subDir));
|
||||||
|
|
||||||
|
if(is_dir("{$currDirPos}/{$subDir[0]}")) {
|
||||||
|
$xml .= "<Directory name = '{$subDir[0]}'><DirectoryPath>" . ltrim("{$currDirPos}/{$subDir[0]}",'./') . "/</DirectoryPath>";
|
||||||
|
$xml .= createCats("{$currDirPos}/{$subDir[0]}");
|
||||||
|
$xml .= "</Directory>";
|
||||||
|
} else {
|
||||||
|
$xml .= "<FileName>{$subDir[0]}</FileName>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveXml($xml, $filename) {
|
||||||
|
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.'<tftpboot>' . $xml . '</tftpboot>';
|
||||||
|
$dom = new \DOMDocument("1.0");
|
||||||
|
$dom->preserveWhiteSpace = false;
|
||||||
|
$dom->formatOutput = true;
|
||||||
|
$dom->loadXML($xml);
|
||||||
|
$dom->save($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveXml(createCats('../tftpboot'),'tftpbootFiles.xml');
|
||||||
|
?>
|
@@ -2828,7 +2828,6 @@
|
|||||||
<FileName>merlin5.pcm</FileName>
|
<FileName>merlin5.pcm</FileName>
|
||||||
<FileName>merlin6.pcm</FileName>
|
<FileName>merlin6.pcm</FileName>
|
||||||
<FileName>merlin7.pcm</FileName>
|
<FileName>merlin7.pcm</FileName>
|
||||||
<FileName>mkringlist.sh</FileName>
|
|
||||||
<FileName>ringer1.pcm</FileName>
|
<FileName>ringer1.pcm</FileName>
|
||||||
<FileName>ringer2.pcm</FileName>
|
<FileName>ringer2.pcm</FileName>
|
||||||
<FileName>ringer3.pcm</FileName>
|
<FileName>ringer3.pcm</FileName>
|
||||||
|
Reference in New Issue
Block a user