Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

A few more tweaks to the /etc/fstab file #11

Merged
merged 5 commits into from Jul 12, 2013
Merged

A few more tweaks to the /etc/fstab file #11

merged 5 commits into from Jul 12, 2013

Conversation

sonnysideup
Copy link
Contributor

I think these changes represent the safest, least intrusive means of updating the /etc/fstab with an entry for the newly created swap file.

I ran these changes a number of times against a couple of different fstab files and each time it produce good results.

we don't have to strip strings in order to check for line presence
stops removing empty lines from fstab
removes extra newline chars
using #grep when then have to ask the result if it's not #empty?
using #any? makes sense, but we should still use a regex instead of
performing a string equality test
f.write(contents.join("\n") + "\n")
end
contents << "#{addition}\n"
::File.open(fstab, 'w') { |f| f.write(contents.join) }

This comment was marked as outdated.

@sonnysideup
Copy link
Contributor Author

will this minor change work?

@@ -152,16 +152,13 @@ def persist
contents = ::File.readlines(fstab)
addition = "#{@new_resource.path} swap swap defaults 0 0"

if contents.any? { |line| line.strip == addition }
if contents.any? { |line| line =~ /^#{addition}/ }

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

sethvargo pushed a commit that referenced this pull request Jul 12, 2013
A few more tweaks to the /etc/fstab file
@sethvargo sethvargo merged commit f1797c8 into Sous-Chefs-Boneyard:master Jul 12, 2013
@sethvargo
Copy link
Contributor

Released in v0.3.5

@lock
Copy link

lock bot commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants