From 904a63acdbfdb4cede17d505ce7b09daa60757b6 Mon Sep 17 00:00:00 2001
From: Griefed <griefed@griefed.de>
Date: Sun, 18 Oct 2020 00:05:20 +0200
Subject: [PATCH] Cleanup and fixes

---
 root/etc/cont-init.d/40-install | 11 +++++----
 root/etc/cont-init.d/50-config  | 42 +++++++++++++++++++++++++++++++--
 root/etc/cont-init.d/60-git     | 39 ------------------------------
 3 files changed, 47 insertions(+), 45 deletions(-)
 delete mode 100644 root/etc/cont-init.d/60-git

diff --git a/root/etc/cont-init.d/40-install b/root/etc/cont-init.d/40-install
index 4f2e89f..6e7334a 100644
--- a/root/etc/cont-init.d/40-install
+++ b/root/etc/cont-init.d/40-install
@@ -6,13 +6,16 @@ if [ ! -f "/config/www/ICEcoder/index.php" ]; then
 		"https://github.com/icecoder/ICEcoder/archive/${ICECODER_VERSION}.zip"
 	cd /tmp || exit
 	unzip -qq install.zip
-	mkdir /plugins
-	mv ICEcoder-*/data/* /data/
-	mv ICEcoder-*/plugins/* /plugins/
+	mv ICEcoder-*/data/.gitkeep /data/
+	mv ICEcoder-*/plugins/index.php /plugins/
 	mv ICEcoder-* /app/ICEcoder
 	cd / || exit
 	rm -rf /tmp/* /config/www/data
 	rm -rf /app/ICEcoder/data
 	rm -rf /app/ICEcoder/plugins
-	chown -R abc:abc /app/ICEcoder
+	chown -R abc:abc \
+		/app/ICEcoder \
+		/data \
+		/config \
+		/plugins
 fi
diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config
index e261cd7..dced70d 100644
--- a/root/etc/cont-init.d/50-config
+++ b/root/etc/cont-init.d/50-config
@@ -6,6 +6,44 @@ ln -sf /plugins /app/ICEcoder/plugins
 
 # permissions
 chown -R abc:abc \
-/config
-/data
+/config \
+/data \
 /plugins
+
+# check for lock file to only run git operations once
+if [ ! -e /lock.file ]; then
+  # Give abc a sudo shell for development
+  chsh abc -s /bin/bash
+  sed -e 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' \
+    -i /etc/sudoers
+  sed -e 's/^wheel:\(.*\)/wheel:\1,abc/g' -i /etc/group
+  # create directory for project
+  mkdir -p /data/code
+  # make sure URL is set and folder is empty to clone code
+  if [ ${GITURL+x} ] && [ ! "$(/bin/ls -A /data/code 2>/dev/null)" ] ; then \
+    # clone the url the user passed to this directory
+    git clone "${GITURL}" /data/code
+  fi
+else
+  # lock exists not importing project this is a restart
+  echo "Lock exists just starting pylon"
+fi
+
+# create lock file after first run
+touch /lock.file
+
+# copy php ini for user editing
+[[ ! -e "/config/php/php.ini" ]] && \
+cp /etc/php7/php.ini /config/php/php.ini
+cp /config/php/php.ini /etc/php7/php.ini
+
+# permissions
+mkdir -p /config/sessions
+echo "[cont-init.d] Setting permissions this may take some time"
+chown -R abc:abc \
+ /data \
+ /config \
+ /plugins
+# make our folders
+mkdir -p \
+/config/{log/ICEcoder,php,sess}
diff --git a/root/etc/cont-init.d/60-git b/root/etc/cont-init.d/60-git
deleted file mode 100644
index d24f292..0000000
--- a/root/etc/cont-init.d/60-git
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/with-contenv bash
-
-# check for lock file to only run git operations once
-if [ ! -e /lock.file ]; then
-  # Give abc a sudo shell for development
-  chsh abc -s /bin/bash
-  sed -e 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' \
-    -i /etc/sudoers
-  sed -e 's/^wheel:\(.*\)/wheel:\1,abc/g' -i /etc/group
-  # create directory for project
-  mkdir -p /data/code
-  # make sure URL is set and folder is empty to clone code
-  if [ ${GITURL+x} ] && [ ! "$(/bin/ls -A /data/code 2>/dev/null)" ] ; then \
-    # clone the url the user passed to this directory
-    git clone "${GITURL}" /data/code
-  fi
-else
-  # lock exists not importing project this is a restart
-  echo "Lock exists just starting pylon"
-fi
-
-# create lock file after first run
-touch /lock.file
-
-# copy php ini for user editing
-[[ ! -e "/config/php/php.ini" ]] && \
-cp /etc/php7/php.ini /config/php/php.ini
-cp /config/php/php.ini /etc/php7/php.ini
-
-# permissions
-mkdir -p /config/sessions
-echo "[cont-init.d] Setting permissions this may take some time"
-chown -R abc:abc \
- /data \
- /config
- /plugins
-# make our folders
-mkdir -p \
-/config/{log/ICEcoder,php,sess}
-- 
GitLab