fix: display disabled octoprint services as installed, and show the number of instances

This commit is contained in:
th33xitus
2021-01-28 23:40:37 +01:00
parent 0eb2d066be
commit 1570fd588e

View File

@@ -174,16 +174,12 @@ octoprint_status(){
$OCTOPRINT_DIR $OCTOPRINT_DIR
) )
#remove the "SERVICE" entry from the octoprint array if an octoprint service is installed #remove the "SERVICE" entry from the octoprint array if an octoprint service is installed
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "octoprint.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "octoprint-[[:digit:]].service")" ]; then if systemctl list-unit-files | grep -E "octoprint.*" &>/dev/null; then
unset octoprint_data[0] unset octoprint_data[0]
fi fi
### count amount of octoprint services ### count amount of octoprint services
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "octoprint.service")" ]; then instances=$(systemctl list-unit-files | grep -E "octoprint.*" | wc -l)
instances=1
else
instances=$(systemctl list-units --full -all -t service --no-legend | grep -E "octoprint-[[:digit:]].service" | wc -l)
fi
#count+1 for each found data-item from array #count+1 for each found data-item from array
for op in "${octoprint_data[@]}" for op in "${octoprint_data[@]}"