LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Making changes to mariadb.service the right way (https://www.linuxquestions.org/questions/linux-newbie-8/making-changes-to-mariadb-service-the-right-way-4175680335/)

rhysers 08-13-2020 02:43 AM

Making changes to mariadb.service the right way
 
Hi,
So long story short, due to issues with running a debian container in LXC, i have to make some changes to the config file to make it run. Now, that's not so bad, but every time it updates, my changes get overwritten (yesterday) and lo and behold, when I was putting them back in today, I noticed the following at the top of the file:
Code:

# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades.  If you want to customize, the
# best way is to create a file "/etc/systemd/system/mariadb.service",
# containing
#      .include /usr/lib/systemd/system/mariadb.service
#      ...make your changes here...
# or create a file "/etc/systemd/system/mariadb.service.d/foo.conf",
# which doesn't need to include ".include" call and which will be parsed
# after the file mariadb.service itself is parsed.
#
# For more info about custom unit files, see systemd.unit(5) or
# https://mariadb.com/kb/en/mariadb/systemd/

So my question is how do i format the changes i need into a /usr/lib/systemd/system/mariadb.service file?
I checked the website but found no specifics and I opened the man page, but quickly became overwhelemed.
The changes I need are these:
Code:

[Service]
ProtectHome=false
ProtectSystem=false
PrivateTmp=false
PrivateNetwork=false
PrivateDevices=false

What does the file I need to make need to look like, and do I just add the line .include /usr/lib/systemd/system/mariadb.service to the orig. config file? What keeps the exact same update that wiped out my other changes from wiping out the .include statement?

Thanks,
Rhys

berndbausch 08-13-2020 04:25 AM

I am probably confused what your question is. At first, it seems that you want to know how to make a systemd unit file immune against updates. The answer is, copy that unit file to /etc/systemd, make the changes there and run systemctl daemon-reload (or just reboot). But then you ask:

Quote:

Originally Posted by rhysers (Post 6155402)
So my question is how do i format the changes i need into a /usr/lib/systemd/system/mariadb.service file?

and
Quote:

The changes I need are these:
Code:

[Service]
ProtectHome=false
ProtectSystem=false
PrivateTmp=false
PrivateNetwork=false
PrivateDevices=false


Hmm. I would just add these lines to the [service] section of the mariadb unit file.
Quote:

do I just add the line .include /usr/lib/systemd/system/mariadb.service to the orig. config file? What keeps the exact same update that wiped out my other changes from wiping out the .include statement?
To be honest, I know nothing about an include statement. However, /usr/lib/systemd/system/mariadb.service is the original systemd unit file, and if you want to include it somewhere, it would be in your copy of the unit file under /etc/systemd.

What I would do: Copy the original mariadb.service to /etc/systemd/system, add the above lines under the [Service] section, and you are done. The next update will overwrite /usr/lib/systemd, but not /etc/systemd.


All times are GMT -5. The time now is 01:37 PM.