From fbb725a9491aabca8abf085f981c2239dcb25734 Mon Sep 17 00:00:00 2001
From: Salt <rehashedsalt@cock.li>
Date: Mon, 15 Jun 2020 09:51:20 -0500
Subject: [PATCH] Implement process listing

---
 firestarter | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/firestarter b/firestarter
index 0e47c9c..6428aa0 100755
--- a/firestarter
+++ b/firestarter
@@ -125,6 +125,19 @@ fsexec() {
 		warn "Could not execute target: \"$filename\""
 	fi
 }
+fslist() {
+	# List all valid services and what they point to
+	for file in "$_optconfigdir"/*; do
+		if ! [ -e "$file" ]; then
+			error "No configuration files found" 70
+		fi
+		# Skip our logs directory
+		[ "$_optlogdir" == "$file" ] && continue
+		if gettarget "$file"; then
+			echo "$(basename -- "$file")"
+		fi
+	done
+}
 fsstatus() {
 	# List statistics about firestarter
 	warn "NYI"
@@ -303,6 +316,7 @@ If no command is specified, firestarter will behave as though init had been
 provided
 
   init			Start all services and wait
+  list			List all valid services
   start			Start the provided service, fork, and exit
   status		Show status information
 
@@ -327,6 +341,9 @@ firestart() {
 			step_wait
 			step_logout
 			;;
+		list)
+			fslist
+			;;
 		start)
 			for file in "${_args[@]:1}"; do
 				fsexec "$_optconfigdir"/"$file"