mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 10:34:28 +05:00
fix: display instance count in main menu status
This commit is contained in:
@@ -17,19 +17,29 @@ klipper_status(){
|
|||||||
$KLIPPER_DIR
|
$KLIPPER_DIR
|
||||||
$KLIPPY_ENV_DIR
|
$KLIPPY_ENV_DIR
|
||||||
)
|
)
|
||||||
#remove the "SERVICE" entry from the klipper_data array if a klipper service is installed
|
### remove the "SERVICE" entry from the klipper_data array if a klipper service is installed
|
||||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service")" ]; then
|
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service")" ]; then
|
||||||
unset klipper_data[0]
|
unset klipper_data[0]
|
||||||
fi
|
fi
|
||||||
#count+1 for each found data-item from array
|
|
||||||
|
### count+1 for each found data-item from array
|
||||||
for kd in "${klipper_data[@]}"
|
for kd in "${klipper_data[@]}"
|
||||||
do
|
do
|
||||||
if [ -e $kd ]; then
|
if [ -e $kd ]; then
|
||||||
kcount=$(expr $kcount + 1)
|
kcount=$(expr $kcount + 1)
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
### count amount of klipper services
|
||||||
|
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
|
||||||
|
instances=1
|
||||||
|
else
|
||||||
|
instances=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
|
||||||
|
fi
|
||||||
|
|
||||||
|
### display status
|
||||||
if [ "$kcount" == "${#klipper_data[*]}" ]; then
|
if [ "$kcount" == "${#klipper_data[*]}" ]; then
|
||||||
KLIPPER_STATUS="${green}Installed!${default} "
|
KLIPPER_STATUS="$(printf "${green}Installed: %-5s${default}" $instances)"
|
||||||
elif [ "$kcount" == 0 ]; then
|
elif [ "$kcount" == 0 ]; then
|
||||||
KLIPPER_STATUS="${red}Not installed!${default} "
|
KLIPPER_STATUS="${red}Not installed!${default} "
|
||||||
else
|
else
|
||||||
@@ -71,15 +81,25 @@ moonraker_status(){
|
|||||||
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service")" ]; then
|
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ] || [ "$(systemctl list-units --full -all -t service --no-legend | grep -E "moonraker-[[:digit:]].service")" ]; then
|
||||||
unset moonraker_data[0]
|
unset moonraker_data[0]
|
||||||
fi
|
fi
|
||||||
#count+1 for each found data-item from array
|
|
||||||
|
### count+1 for each found data-item from array
|
||||||
for mrd in "${moonraker_data[@]}"
|
for mrd in "${moonraker_data[@]}"
|
||||||
do
|
do
|
||||||
if [ -e $mrd ]; then
|
if [ -e $mrd ]; then
|
||||||
mrcount=$(expr $mrcount + 1)
|
mrcount=$(expr $mrcount + 1)
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
### count amount of moonraker services
|
||||||
|
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
|
||||||
|
instances=1
|
||||||
|
else
|
||||||
|
instances=$(systemctl list-units --full -all -t service --no-legend | grep -E "klipper-[[:digit:]].service" | wc -l)
|
||||||
|
fi
|
||||||
|
|
||||||
|
### display status
|
||||||
if [ "$mrcount" == "${#moonraker_data[*]}" ]; then
|
if [ "$mrcount" == "${#moonraker_data[*]}" ]; then
|
||||||
MOONRAKER_STATUS="${green}Installed!${default} "
|
MOONRAKER_STATUS="$(printf "${green}Installed: %-5s${default}" $instances)"
|
||||||
elif [ "$mrcount" == 0 ]; then
|
elif [ "$mrcount" == 0 ]; then
|
||||||
MOONRAKER_STATUS="${red}Not installed!${default} "
|
MOONRAKER_STATUS="${red}Not installed!${default} "
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user