#!/bin/sh

#
# Copyright (C) 2025 Nethesis S.r.l.
# SPDX-License-Identifier: GPL-2.0-only
#

# Check the status of the storage configured, and return one of the following:
# - ok: storage is configured and mounted
# - error: storage is configured but not mounted
# - not_configured: storage is not configured

# check if storage is configured
if uci -q get fstab.ns_data >/dev/null; then
  label=$(uci -q get fstab.ns_data.label)
  if [ -n "$label" ] && block info | grep -q "LABEL=\"$label\".*MOUNT=\"$(uci -q get fstab.ns_data.target)\"" ; then
    status=ok
  else
    status=error
  fi
else
  status=not_configured
fi

echo $status
