Skip to content
Snippets Groups Projects
Verified Commit 4b7a9bb3 authored by Michal Hrusecky's avatar Michal Hrusecky :mouse:
Browse files

Prefer gnu-stat if available

Busybox stat is not enough but is we had a working alternatives, the default
stat command should be gnu stat as in older versions of Turris OS. So if there
is a gnu-stat, use that one as it is bound to work, if not, let's assume the
stat is linking to the correct implementation (dependencies are in package) and
we are running either in test environment or on old/new Turris OS version.
parent 0a18e3b7
Branches gnu-stat
1 merge request!9Prefer gnu-stat if available
Pipeline #59503 passed with stage
in 1 minute and 9 seconds
......@@ -26,8 +26,12 @@ class SettingsUci(BaseCmdLine, BaseFile):
old_uuid = ""
uuid = get_option_named(data, "storage", "srv", "uuid", "")
raid = get_option_named(data, "storage", "srv", "raid", "custom")
try:
stat = self._trigger_and_parse(["which", "gnu-stat"], r"(/.*/gnu-stat)")
except BackendCommandFailed:
stat = "stat"
# get mountpoint of /srv
srv_mount_point = self._trigger_and_parse(["stat", "-c", "%m", "/srv"], r"\s*(.*)\s*")
srv_mount_point = self._trigger_and_parse([stat, "-c", "%m", "/srv"], r"\s*(.*)\s*")
try:
old_device = self._read_and_parse(
......
......@@ -7,6 +7,8 @@ config_get UUID srv uuid
config_get RAID srv raid custom
FROM_SCRATCH=""
STAT="$(which gnu-stat)"
[ -n "$STAT" ] || STAT="$(which stat)"
SRV_MNT_PNT="/srv"
# Decide how much we want to debug
[ "$DBG" = 0 ] || set -x
......@@ -125,7 +127,7 @@ if [ -z "$UUID" ]; then
shift
# Commit configuration
SRV="$(stat -c %m /srv/)"
SRV="$("$STAT" -c %m /srv/)"
SRV_DEV=""
SRV_UUID=""
if grep -q '^ubi[^[:blank:]]* '"$SRV"' .*' /proc/mounts || \
......@@ -142,7 +144,7 @@ if [ -z "$UUID" ]; then
fi
# Make sure we have /srv mounted somewhere
if [ "$(stat -c %m /srv/)" = "$(stat -c %m /)" ]; then
if [ "$("$STAT" -c %m /srv/)" = "$("$STAT" -c %m /)" ]; then
SRV_MNT_PNT="/tmp/storage_plugin/tmpdir"
mkdir -p "$SRV_MNT_PNT"
DEV="$(blkid -c /dev/null -U "$UUID")"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment