about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-09-29 13:43:02 -0400
committerCharadon <dev@iotib.net>2022-09-29 13:43:02 -0400
commit76fc13726ee58808bcd28091bf45e3a6cde14c79 (patch)
tree6e397ffcbeaed9226bd80c364b99d1e6c790f113
parentbfcb99322498845bedbb3c204ad997193ccb4920 (diff)
downloaddscip-76fc13726ee58808bcd28091bf45e3a6cde14c79.tar.gz
setup.sh: If templates directory was defined, copy those files instead of relying on system packaged versions
-rwxr-xr-xsetup.sh30
1 files changed, 21 insertions, 9 deletions
diff --git a/setup.sh b/setup.sh
index e3d91fe..816b880 100755
--- a/setup.sh
+++ b/setup.sh
@@ -59,31 +59,43 @@ check_config() {
 	return 0
 }
 
+install_templates() {
+	if [ ! "$TEMPLATE_DIR" = "" ];
+	then
+		install -m755 "$TEMPLATE_DIR"/* .
+		return 0
+	else
+		return 1
+	fi
+}
+
 install_dscip() {
 	echo "Installing dscip..."
 	set -x
 	mkdir -p "$PROJECT_LOCATION"
 	if [ -d "/usr/share/charadon/dscip" ]; # See if dscip is packaged/installed on system.
 	then
-		ln -s /usr/share/charadon/dscip/* "$PROJECT_LOCATION" || cp /usr/share/charadon/dscip/* "$PROJECT_LOCATION"
-		install -m755 /usr/share/charadon/dscip/config.sh "$PROJECT_LOCATION"
+		DSCIP_PATH="/usr/share/charadon/dscip"
+		ln -s "$DSCIP_PATH"/dscip "$PROJECT_LOCATION" || \
+			cp "$DSCIP_PATH"/dscip "$PROJECT_LOCATION"
+		install -m755 "$DSCIP_PATH"/config.sh "$PROJECT_LOCATION"
+		install_templates || cp "$DSCIP_PATH"/*.sh .
 	elif [ -d /usr/local/share/charadon/dscip ];
 	then
-		ln -s /usr/local/share/charadon/dscip/* "$PROJECT_LOCATION" || cp /usr/local/share/charadon/dscip/* "$PROJECT_LOCATION"
-		install -m755 /usr/share/charadon/dscip/config.sh "$PROJECT_LOCATION"
+		DSCIP_PATH="/usr/local/share/charadon/dscip"
+		ln -s "$DSCIP_PATH"/dscip "$PROJECT_LOCATION" || \
+			cp "$DSCIP_PATH"/dscip "$PROJECT_LOCATION"
+		install -m755 "$DSCIP_PATH"/config.sh "$PROJECT_LOCATION"
+		install_templates || cp "$DSCIP_PATH"/*.sh .
 	else # If not, clone it from upstream.
 		git clone "https://opencode.net/charadon/dscip" "$PROJECT_LOCATION"
+		install_templates || echo "Skipping templates as no Template Directory was set..."
 	fi
 	cd "$PROJECT_LOCATION"
 	# Modifying config.sh with variables obtained from setup.sh
 	sed -i "s}DSCIP_GITREPO=.*}DSCIP_GITREPO=\"$PROJECT_URL\"}g" config.sh
 	sed -i "s/DSCIP_NAME=.*/DSCIP_NAME=\"$PROJECT_NAME\"/g" config.sh
 	sed -i "s/DSCIP_BRANCH=.*/DSCIP_BRANCH=\"$PROJECT_BRANCH\"/g" config.sh
-	# Copy templates.
-	if [ ! "$TEMPLATE_DIR" = "" ];
-	then
-		cp "$TEMPLATE_DIR"/* .
-	fi
 	# Done. Go back to CWD, and tell user how to activate DSCIP.
 	set +x
 	printf "\n"