From 1e3a409d22f04c06600bc1a314a48621df7cf424 Mon Sep 17 00:00:00 2001
From: Griefed <44273438+Griefed@users.noreply.github.com>
Date: Wed, 14 Oct 2020 20:38:25 +0200
Subject: [PATCH] Rebase to lsiobase/alpine

---
 root/defaults/discord-config.json |  7 +++++++
 root/defaults/misc-config.json    | 16 ++++++++++++++++
 root/defaults/socket-config.json  |  5 +++++
 root/etc/cont-init.d/50-config    | 28 ++++++++++++++++++++++++++++
 root/etc/services.d/d-zone/run    |  6 ++++++
 5 files changed, 62 insertions(+)
 create mode 100644 root/defaults/discord-config.json
 create mode 100644 root/defaults/misc-config.json
 create mode 100644 root/defaults/socket-config.json
 create mode 100644 root/etc/cont-init.d/50-config
 create mode 100644 root/etc/services.d/d-zone/run

diff --git a/root/defaults/discord-config.json b/root/defaults/discord-config.json
new file mode 100644
index 0000000..69e97aa
--- /dev/null
+++ b/root/defaults/discord-config.json
@@ -0,0 +1,7 @@
+{
+  "url": "https://github.com/vegeta897/d-zone",
+  "infoCommand": "!d-zone",
+  "autoPopulate": true,
+  "servers": [
+  ]
+}
diff --git a/root/defaults/misc-config.json b/root/defaults/misc-config.json
new file mode 100644
index 0000000..b430b01
--- /dev/null
+++ b/root/defaults/misc-config.json
@@ -0,0 +1,16 @@
+{
+  "textbox": {
+    "maxWidth": 96,
+    "linesPerPage": 4,
+    "scrollSpeeds": [
+      [0, 3],
+      [75, 2],
+      [150, 1]
+    ],
+    "pageDelay": 5,
+    "finalDelay": 30,
+    "openTime": 10,
+    "closeTime": 8,
+    "bgColor": "rgba(0, 0, 0, 0.7)"
+  }
+}
diff --git a/root/defaults/socket-config.json b/root/defaults/socket-config.json
new file mode 100644
index 0000000..b0a23bf
--- /dev/null
+++ b/root/defaults/socket-config.json
@@ -0,0 +1,5 @@
+{
+  "address": "127.0.0.1",
+  "port": 3000,
+  "secure": false
+}
diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config
new file mode 100644
index 0000000..6242a5c
--- /dev/null
+++ b/root/etc/cont-init.d/50-config
@@ -0,0 +1,28 @@
+#!/usr/bin/with-contenv bash
+
+
+# Check if configs are provided by host, if not, use defaults
+if [ ! -f "/config/discord-config.json" ]; then
+	cp /defaults/discord-config.json /config/discord-config.json
+fi
+
+if [ ! -f "/config/misc-config.json" ]; then
+        cp /defaults/misc-config.json /config/misc-config.json
+fi
+
+if [ ! -f "/config/socket-config.json" ]; then
+        cp /defaults/socket-config.json /config/socket-config.json
+fi
+
+# Overwrite config files in d-zone directory
+ln -sf /config/discord-config.json /app/d-zone/discord-config.json
+ln -sf /config/misc-config.json /app/d-zone/misc-config.json
+ln -sf /config/socket-config.json /app/d-zone/socket-config.json
+
+# permissions stuff
+chown -R abc:abc \
+	/config
+
+# chwon the app directory, but not node_modules
+find /app/d-zone -maxdepth 1 ! -name node_modules ! -name d-zone -exec chown -R abc:abc '{}' \;
+
diff --git a/root/etc/services.d/d-zone/run b/root/etc/services.d/d-zone/run
new file mode 100644
index 0000000..bec90ba
--- /dev/null
+++ b/root/etc/services.d/d-zone/run
@@ -0,0 +1,6 @@
+#!/usr/bin/with-contenv bash
+
+cd /app/d-zone || exit
+
+exec \
+	s6-setuidgid abc /usr/bin/npm start
-- 
GitLab