refactor(obico.sh): refactor obico status
initializes `is_linked` as true. switches it to false as soon as the first non linked instance is detected. status is then printed as non linked in the main menu. Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -365,23 +365,33 @@ function update_moonraker_obico() {
|
|||||||
#===================================================#
|
#===================================================#
|
||||||
|
|
||||||
function get_moonraker_obico_status() {
|
function get_moonraker_obico_status() {
|
||||||
local moonraker_obico_services sf_count status
|
local status
|
||||||
moonraker_obico_services=$(moonraker_obico_systemd)
|
local service_count
|
||||||
sf_count=$(echo "${moonraker_obico_services}" | wc -w )
|
local is_linked
|
||||||
|
local moonraker_obico_services
|
||||||
|
|
||||||
if (( sf_count == 0 )); then
|
moonraker_obico_services=$(moonraker_obico_systemd)
|
||||||
status="Not installed!"
|
service_count=$(echo "${moonraker_obico_services}" | wc -w )
|
||||||
elif [[ ! -e "${MOONRAKER_OBICO_DIR}" ]]; then
|
|
||||||
status="Incomplete!"
|
is_linked="true"
|
||||||
else
|
if [[ -n ${moonraker_obico_services} ]]; then
|
||||||
status="Installed!"
|
|
||||||
for service in ${moonraker_obico_services}; do
|
for service in ${moonraker_obico_services}; do
|
||||||
if ! is_moonraker_obico_linked "$(get_instance_name "${service}" moonraker-obico)"; then
|
if ! is_moonraker_obico_linked "$(get_instance_name "${service}" moonraker-obico)"; then
|
||||||
status="Not linked!"
|
is_linked="false"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if (( service_count == 0 )); then
|
||||||
|
status="Not installed!"
|
||||||
|
elif [[ ! -d "${MOONRAKER_OBICO_DIR}" ]]; then
|
||||||
|
status="Incomplete!"
|
||||||
|
elif [[ ${is_linked} == "false" ]]; then
|
||||||
|
status="Not linked!"
|
||||||
|
else
|
||||||
|
status="Installed!"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "${status}"
|
echo "${status}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ function print_status() {
|
|||||||
|
|
||||||
if [[ ${status} == "Not installed!" ]]; then
|
if [[ ${status} == "Not installed!" ]]; then
|
||||||
status="${red}${status}${white}"
|
status="${red}${status}${white}"
|
||||||
elif [[ ${status} == "Incomplete!" ]] || [[ ${status} == "Not linked!" ]]; then
|
elif [[ ${status} == "Incomplete!" ]]; then
|
||||||
|
status="${yellow}${status}${white}"
|
||||||
|
elif [[ ${status} == "Not linked!" ]]; then
|
||||||
|
### "Not linked!" is only required for Moonraker-obico
|
||||||
status="${yellow}${status}${white}"
|
status="${yellow}${status}${white}"
|
||||||
else
|
else
|
||||||
status="${green}${status}${white}"
|
status="${green}${status}${white}"
|
||||||
|
|||||||
Reference in New Issue
Block a user