about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-09-30 11:26:39 -0400
committerCharadon <dev@iotib.net>2022-09-30 11:26:39 -0400
commit49b1842d1e363cd0e3beb3896bd4ab5326c1bfbc (patch)
tree4e194c2b82a7afc3bdd39309405b3d8d90b2131e
parentb0a3cffee6db18145690f1deee8c5367dfc29b83 (diff)
downloaddscip-49b1842d1e363cd0e3beb3896bd4ab5326c1bfbc.tar.gz
setup.sh: Added detector for realpath, and began using realpath to generate the crontab entry
-rwxr-xr-xsetup.sh17
1 files changed, 14 insertions, 3 deletions
diff --git a/setup.sh b/setup.sh
index df23ff7..1a20dbb 100755
--- a/setup.sh
+++ b/setup.sh
@@ -13,6 +13,17 @@ TEMPLATE_DIR=""
 # For use when making new releases on gitlab.
 DSCIP_VERSION=""
 
+REALPATH=""
+# Detect if system has realpath, if not, try to see if GNU Coreutils is
+# installed and use that.
+if which realpath > /dev/null;
+then
+	REALPATH="realpath"
+elif which grealpath > /dev/null;
+then
+	REALPATH="grealpath"
+fi
+
 show_license() {
 	echo 'Copyright 2022 Charadon
 
@@ -75,13 +86,14 @@ install_dscip() {
 	echo "Installing dscip..."
 	set -x
 	mkdir -p "$PROJECT_LOCATION"
+	cd "$PROJECT_LOCATION" || return 1
 	if [ -d "/usr/share/charadon/dscip" ]; # See if dscip is packaged/installed on system.
 	then
 		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 .
+		install_templates || cp -a "$DSCIP_PATH"/*.sh .
 	elif [ -d /usr/local/share/charadon/dscip ];
 	then
 		DSCIP_PATH="/usr/local/share/charadon/dscip"
@@ -98,7 +110,6 @@ install_dscip() {
         fi
 		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
@@ -107,7 +118,7 @@ install_dscip() {
 	set +x
 	printf "\n"
 	printf "\e[32mAll done. Be sure to add:\e[0m\n" 
-	echo "* * * * * $(dirname "$(readlink -f "$PROJECT_LOCATION")")/dscip"
+	echo "* * * * * $($REALPATH ./dscip)"
 	printf "\e[32mTo your crontab! Usually by using \`crontab -e\`\e[0m\n\n"
 	printf "\e[32mAlternatively, you can run dscip as a daemon by modifying DSCIP_DAEMON in config.sh\n"
 	printf "and creating a daemon for your system's init system.\e[0m\n\n"