From 9e4e34e8dac3c452255d5d6b465db7c59f7e26c5 Mon Sep 17 00:00:00 2001
From: Markus Birth <mbirth@gmail.com>
Date: Sun, 6 Sep 2015 04:10:26 +0200
Subject: [PATCH] Added cgi-bin scripts to refresh_sd and (not yet finished)
 delete files.

---
 .wifisd/cgi-bin/refresh_sd  |  5 +++++
 .wifisd/cgi-bin/wifi_delete | 21 +++++++++++++++++++++
 .wifisd/init.d/99cgi-bin.sh |  5 +++++
 3 files changed, 31 insertions(+)
 create mode 100644 .wifisd/cgi-bin/refresh_sd
 create mode 100644 .wifisd/cgi-bin/wifi_delete
 create mode 100644 .wifisd/init.d/99cgi-bin.sh

diff --git a/.wifisd/cgi-bin/refresh_sd b/.wifisd/cgi-bin/refresh_sd
new file mode 100644
index 0000000..d4777d2
--- /dev/null
+++ b/.wifisd/cgi-bin/refresh_sd
@@ -0,0 +1,5 @@
+#!/bin/sh
+echo "Status: 200 OK"
+echo "Content-Type: text/plain"
+echo ""
+refresh_sd
diff --git a/.wifisd/cgi-bin/wifi_delete b/.wifisd/cgi-bin/wifi_delete
new file mode 100644
index 0000000..46d88f2
--- /dev/null
+++ b/.wifisd/cgi-bin/wifi_delete
@@ -0,0 +1,21 @@
+#!/bin/sh
+FILE="/mnt/sd/${QUERY_STRING}"
+
+if [ -f "$FILE" ]; then
+    #rm -f ${FILE}
+    #sync
+    #refresh_sd
+    echo "Status: 200 OK"
+    echo "Content-Type: text/plain"
+    echo ""
+    echo "File to delete: $FILE"
+    echo "File exists!"
+
+else
+    echo "Status: 404 Not Found"
+    echo "Content-Type: text/plain"
+    echo ""
+    echo "File $FILE not found!"
+fi
+
+env
diff --git a/.wifisd/init.d/99cgi-bin.sh b/.wifisd/init.d/99cgi-bin.sh
new file mode 100644
index 0000000..3ae731c
--- /dev/null
+++ b/.wifisd/init.d/99cgi-bin.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+chmod a+x /mnt/sd/.wifisd/cgi-bin/refresh_sd
+chmod a+x /mnt/sd/.wifisd/cgi-bin/wifi_delete
+ln -s /mnt/sd/.wifisd/cgi-bin/refresh_sd /www/cgi-bin/refresh_sd
+ln -s /mnt/sd/.wifisd/cgi-bin/wifi_delete /www/cgi-bin/wifi_delete