This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
A few more tweaks to the /etc/fstab file #11
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This comment was marked as outdated.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
sethvargo
pushed a commit
that referenced
this pull request
Jul 12, 2013
A few more tweaks to the /etc/fstab file
Released in v0.3.5 |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.