Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi System Preparation | Add sysctl config values to our own .conf file #1247

Merged
merged 3 commits into from
Nov 21, 2017
Merged

Conversation

MichaIng
Copy link
Owner

  • Generally we should try to add our values into our own files, if a '*.d/' folder exists. This enables package updates to overwrite the unchanged main .conf without overwriting our values.
  • I chose "97-" prefix here as "99-" is used by systemd and "98-" by RPi raspberrypi-sys-mods.
  • We could also check for/sed existing vm.swappiness entries, but I guess '/*.d' entries will overwrite anyway?

… file

- Generally we should try to add our values into our own files, if a '*.d/' folder exists. This enables package updates to overwrite the unchanged main .conf without overwriting our values.
- I chose "97-" prefix here as "99-" is used by systemd and "98-" by RPi raspberrypi-sys-mods.
- We could also check for/sed existing vm.swappiness entries, but I guess '/*.d' entries will overwrite anyway?
...especially since we introduce "/sysctl.d/97-dietpi.conf" for our own adjustments.
@@ -333,7 +333,7 @@ systemctl mask apt-daily.service
systemctl mask apt-daily-upgrade.timer

#/etc/sysctl.conf | Check for a previous entry before adding this
echo -e "vm.swappiness=1" >> /etc/sysctl.conf
echo -e "vm.swappiness=1" >> /etc/sysctl.d/97-dietpi.conf
Copy link
Collaborator

@Fourdee Fourdee Nov 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use > here, it will overwrite the file with the entry. >> will append to end of existing file, if it exists (multiple entries if command used again with >>, not with >)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh important point, thus > is necessary here, or touch filename first, if we add something earlier/optional.

@Fourdee
Copy link
Collaborator

Fourdee commented Nov 20, 2017

@MichaIng

Generally we should try to add our values into our own files, if a '*.d/' folder exists.

Agree 👍

We could also check for/sed existing vm.swappiness entries, but I guess '/*.d' entries will overwrite anyway?

https://github.com/Fourdee/DietPi/pull/1247/files#r152038845

@Fourdee Fourdee added this to the v159 milestone Nov 20, 2017
@MichaIng
Copy link
Owner Author

Yes, as we create and and just set this value so far, no check necessary. We could just check the other config files if some other package/default sets it also. I am not sure about priorities, if it is set multiple times in different configs, could run some checks about this later.

@MichaIng
Copy link
Owner Author

@Fourdee
Just evidentially found my test of echo -e "vm.swappiness=1" >> /etc/sysctl.d/97-dietpi.conf and even that >> is used, the file is also created if not existent, at least here on Jessie and Stretch. Thus we can just always use >> and don't need to think about if it's already there or not. Of course we should prevent double entries, but not as long as we just create and write the file in system preparation script 😉.

But I will leave the > for now, as it does not matter here.

@Fourdee Fourdee merged commit 4ac07e0 into MichaIng:testing Nov 21, 2017
@MichaIng MichaIng deleted the patch-3 branch November 21, 2017 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants