From 09b259c85e25458cb6bb24a2670eb95cbe021af2 Mon Sep 17 00:00:00 2001
From: steve-lad <72376554+steve-lad@users.noreply.github.com>
Date: Wed, 14 Jul 2021 14:58:47 +0200
Subject: [PATCH] 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
---
tftpboot/ringtones/mkringlist.sh | 23 -----------------
tools/createTftpbootXmlStructure.php | 37 ++++++++++++++++++++++++++++
tools/tftpbootFiles.xml | 1 -
3 files changed, 37 insertions(+), 24 deletions(-)
delete mode 100755 tftpboot/ringtones/mkringlist.sh
create mode 100644 tools/createTftpbootXmlStructure.php
diff --git a/tftpboot/ringtones/mkringlist.sh b/tftpboot/ringtones/mkringlist.sh
deleted file mode 100755
index f68c9b7..0000000
--- a/tftpboot/ringtones/mkringlist.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env bash
-outfile=ringlist.xml
-echo -e "" >$outfile
-if [ ! -z "`ls *.pcm 2>/dev/null`" ]; then
- for filename in *.pcm;do
- basename=`basename ${filename} .pcm`
- echo -e "\t" >>$outfile
- echo -e "\t\t${basename}" >>$outfile
- echo -e "\t\tringtones/${filename}" >>$outfile
- echo -e "\t" >>$outfile
- done
-fi
-if [ ! -z "`ls *.raw 2>/dev/null`" ]; then
- for filename in *.raw;do
- basename=`basename ${filename} .raw`
- echo -e "\t" >>$outfile
- echo -e "\t\t${basename}" >>$outfile
- echo -e "\t\tringtones/${filename}" >>$outfile
- echo -e "\t" >>$outfile
- done
-fi
-echo -e "" >>$outfile
-
diff --git a/tools/createTftpbootXmlStructure.php b/tools/createTftpbootXmlStructure.php
new file mode 100644
index 0000000..574d136
--- /dev/null
+++ b/tools/createTftpbootXmlStructure.php
@@ -0,0 +1,37 @@
+" . ltrim("{$currDirPos}/{$subDir[0]}",'./') . "/";
+ $xml .= createCats("{$currDirPos}/{$subDir[0]}");
+ $xml .= "";
+ } else {
+ $xml .= "{$subDir[0]}";
+ }
+ }
+ }
+ return $xml;
+}
+
+function saveXml($xml, $filename) {
+ $xml = ''.'' . $xml . '';
+ $dom = new \DOMDocument("1.0");
+ $dom->preserveWhiteSpace = false;
+ $dom->formatOutput = true;
+ $dom->loadXML($xml);
+ $dom->save($filename);
+}
+
+saveXml(createCats('../tftpboot'),'tftpbootFiles.xml');
+?>
diff --git a/tools/tftpbootFiles.xml b/tools/tftpbootFiles.xml
index d8666f9..f4b3a30 100644
--- a/tools/tftpbootFiles.xml
+++ b/tools/tftpbootFiles.xml
@@ -2828,7 +2828,6 @@
merlin5.pcm
merlin6.pcm
merlin7.pcm
- mkringlist.sh
ringer1.pcm
ringer2.pcm
ringer3.pcm