From 267851bd898208380bb9af6a4014c07b7efbcfbb Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Sun, 6 Aug 2017 12:50:31 +0100
Subject: [PATCH] Only alter fstab if needed

---
 src/freedombone-utils-filesystem | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/freedombone-utils-filesystem b/src/freedombone-utils-filesystem
index f88d65485..f2bd79a3d 100755
--- a/src/freedombone-utils-filesystem
+++ b/src/freedombone-utils-filesystem
@@ -124,7 +124,11 @@ function defrag_filesystem {
 }
 
 function optimise_filesystem {
-    sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' /etc/fstab
+    if grep -q "btrfs" /etc/fstab; then
+        if ! grep -q "btrfs defaults,subvol=@,compress=lzo,ssd" /etc/fstab; then
+            sed -i 's|btrfs subvol=@|btrfs defaults,subvol=@,compress=lzo,ssd|g' /etc/fstab
+        fi
+    fi
 }
 
 # NOTE: deliberately no exit 0
-- 
GitLab