Skip to content

Commit 3d9c519

Browse files
committed
fix: use dpkg-query to read SnapRAID version on Debian/Ubuntu
snapraid -V is broken on current Debian packages. Use dpkg-query as the primary source on dpkg-based systems, stripping the Debian revision suffix (e.g. 12.4-1 -> 12.4). Falls back to the binary for non-dpkg installs (source builds, other distros).
1 parent 16907ee commit 3d9c519

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

snapraid-aio-script.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ main(){
9898
# Check if the script is running as root
9999
check_root
100100

101-
# Read SnapRAID version
102-
SNAPRAIDVERSION="$("$SNAPRAID_BIN" -V | sed -e 's/snapraid v\(.*\)by.*/\1/')"
101+
# Read SnapRAID version (dpkg-query preferred on Debian/Ubuntu; fallback to binary)
102+
if command_exists dpkg-query && dpkg-query -W snapraid &>/dev/null 2>&1; then
103+
SNAPRAIDVERSION="$(dpkg-query -W -f='${Version}' snapraid | cut -d- -f1)"
104+
else
105+
SNAPRAIDVERSION="$("$SNAPRAID_BIN" -V 2>/dev/null | sed -e 's/snapraid v\(.*\)by.*/\1/')"
106+
fi
103107

104108
# Begin user output
105109

0 commit comments

Comments
 (0)