Backend programs
authorJoey Schulze <joey@infodrom.org>
Sun, 19 Nov 2017 23:21:43 +0000 (00:21 +0100)
committerJoey Schulze <joey@infodrom.org>
Sat, 24 Nov 2018 13:27:19 +0000 (14:27 +0100)
bin/musiikki-datetime [new file with mode: 0755]
bin/musiikki-halt [new file with mode: 0755]
bin/musiikki-rescan [new file with mode: 0755]
bin/musiikki-shares [new file with mode: 0755]
bin/musiikki-wifi [new file with mode: 0755]

diff --git a/bin/musiikki-datetime b/bin/musiikki-datetime
new file mode 100755 (executable)
index 0000000..bc1c46a
--- /dev/null
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+read date
+read time
+
+logger -t musiikki "DateTime: $date $time"
+date -s "$date $time"
+
diff --git a/bin/musiikki-halt b/bin/musiikki-halt
new file mode 100755 (executable)
index 0000000..5870d2f
--- /dev/null
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+/sbin/halt -p
diff --git a/bin/musiikki-rescan b/bin/musiikki-rescan
new file mode 100755 (executable)
index 0000000..4d4c068
--- /dev/null
@@ -0,0 +1,29 @@
+#! /bin/bash
+
+#
+# Run via cron every 5 minutes
+#
+
+cfg=/etc/musiikki.conf
+
+if [ ! -f ${cfg} ]
+then
+    echo "Cannot find config file ${cfg}" > /dev/stderr
+    exit 2
+fi
+
+. $cfg
+
+#
+# Unfortunately minidlnad is not able to rescan the archive during
+# regular operation.  Depending on the size of the archive rescanning
+# can last for one hour or more, and only few files will be announced
+# during this operation.
+#
+
+if [ -f "${rescan_file}" ]
+then
+    rm "${rescan_file}"
+    rm -f ${cache}
+    /usr/sbin/service minidlna restart
+fi
diff --git a/bin/musiikki-shares b/bin/musiikki-shares
new file mode 100755 (executable)
index 0000000..bc1a5c8
--- /dev/null
@@ -0,0 +1,23 @@
+#! /bin/sh
+
+read ro_passwd
+read rw_passwd
+
+logger -t musiikki "Samba: newpasswd"
+
+if [ -n "${ro_passwd}" ]
+then
+    (
+       echo "${ro_passwd}"
+       echo "${ro_passwd}"
+    ) | /usr/bin/smbpasswd -s "musicread" > /dev/null 2>&1
+fi
+
+if [ -n "${rw_passwd}" ]
+then
+    (
+       echo "${rw_passwd}"
+       echo "${rw_passwd}"
+    ) | /usr/bin/smbpasswd -s "musicwrite" > /dev/null 2>&1
+
+fi
diff --git a/bin/musiikki-wifi b/bin/musiikki-wifi
new file mode 100755 (executable)
index 0000000..8bd4bfc
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+read essid
+read password
+
+logger -t musiikki "WiFi: ESSID $essid"
+
+sed -i "s/ssid=.*/ssid=${essid}/;s/wpa_passphrase=.*/wpa_passphrase=${password}/" /etc/hostapd/hostapd.conf
+
+cd /tmp/
+nohup /etc/init.d/hostapd restart > /dev/null 2>&1 &