Only alter fstab if needed

This commit is contained in:
Bob Mottram 2017-08-06 12:50:31 +01:00
parent 42754613df
commit 267851bd89
1 changed files with 5 additions and 1 deletions

View File

@ -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