From a270dca23989b5cf7b59cf1d0e285bc736717a44 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 23 Jan 2015 20:16:20 +0900 Subject: [PATCH] Prevent redundant commenting by drive-audit The drive-audit detects error log about a device and comments out it in /etc/fstab. When the error log is generated several times, it comments out the line for each time. This patch makes drive-audit to check if the device is already commented out, and prevents redundant commenting out. Change-Id: Ia542d35b58552dde0f324bb9c42531f98c9058fa --- bin/swift-drive-audit | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/swift-drive-audit b/bin/swift-drive-audit index 69a64031c2..589b255f22 100755 --- a/bin/swift-drive-audit +++ b/bin/swift-drive-audit @@ -126,7 +126,9 @@ def comment_fstab(mount_point): with open('/etc/fstab.new', 'w') as new_fstab: for line in fstab: parts = line.split() - if len(parts) > 2 and line.split()[1] == mount_point: + if len(parts) > 2 \ + and parts[1] == mount_point \ + and not line.startswith('#'): new_fstab.write('#' + line) else: new_fstab.write(line)