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

relocate our systemd service files #2437

Closed
phillxnet opened this issue Dec 6, 2022 · 3 comments
Closed

relocate our systemd service files #2437

phillxnet opened this issue Dec 6, 2022 · 3 comments
Assignees

Comments

@phillxnet
Copy link
Member

Currently, and for the lifetime of the project's use of systemd (the entire lifetime of systemd) we have used the following directory for our rockstor* service files (not including overrides which are considered differently in this regard, see #2436 ):

rleap15-4:~ # ls -la /etc/systemd/system/rockstor*
-rw-r--r-- 1 root root 300 Nov 28 18:51 /etc/systemd/system/rockstor-bootstrap.service
-rw-r--r-- 1 root root 738 Nov 28 18:51 /etc/systemd/system/rockstor-ipv6check.service
-rw-r--r-- 1 root root 319 Nov 28 18:51 /etc/systemd/system/rockstor-pre.service
-rw-r--r-- 1 root root 314 Nov 28 18:51 /etc/systemd/system/rockstor.service

According to: https://en.opensuse.org/openSUSE:Systemd_packaging_guidelines#Unit_files

Systemd unit files, including but not limited to service, socket, timer and path files should always be installed in %_unitdir, i.e. /usr/lib/systemd/system, and never in /etc/systemd/system, so they can be overridden by users without conflicting with packaging.

We should instead be using:

/usr/lib/systemd/system

This modification is dependant upon the merging of pending pr #2434

and should ease our ability to use official rpm macros to establish and manage our systemd configuration. Further enhancing our package robustness re systemd modifications and our compliance with upstream standards.

@phillxnet
Copy link
Member Author

Of note with this issue is that if our rpm package installs it's service files to the preferred:

/usr/lib/systemd/system

Local builds, i.e. development builds, can, in-turn, overide the 'system' package systemd files by opting to install in:

/etc/systemd/system/

directory: https://en.opensuse.org/openSUSE:Systemd_packaging_guidelines#Unit_files

Systemd unit files ought not to be edited by system administrators. As a result, the files are not to be marked as %config in the %files section of the specfile. Instead, modifications are to be placed by the admin in the /etc/systemd/system directory, either as a full replacement file such as /etc/systemd/system/foo.service, or by an extending fragment such as /etc/systemd/system/foo.service.d/my.conf.

@phillxnet
Copy link
Member Author

phillxnet commented Dec 7, 2022

Our project wide use of /etc/systemd/systemd is as follows:

grep -R "/etc/systemd/system"
conf/rockstor-hdparm.service:# /etc/systemd/system/rockstor-hdparm.service, and recreate any existing
src/rockstor/system/osi.py:    Updates or creates the /etc/systemd/system/rockstor-hdparm.service file for
src/rockstor/system/osi.py:    /etc/systemd/system/rockstor-hdparm.service file exists in the first place.
src/rockstor/system/osi.py:    systemd_target = "/etc/systemd/system/{}".format(service)
src/rockstor/system/osi.py:    Looks through /etc/systemd/system/rockstor-hdparm service for any comment
src/rockstor/system/osi.py:    infile = "/etc/systemd/system/rockstor-hdparm.service"
src/rockstor/scripts/flash_optimize.py:SYSTEMD_DIR = "/etc/systemd/system/"
src/rockstor/scripts/initrock.py:SYSTEMD_DIR = "/etc/systemd/system"
src/rockstor/smart_manager/views/samba_service.py:        ss_dest = "/etc/systemd/system/{}".format(systemd_name)
src/rockstor/smart_manager/views/docker_service.py:                shutil.copy(socket_file, "/etc/systemd/system/docker.socket")
src/rockstor/smart_manager/views/docker_service.py:        outf = "/etc/systemd/system/docker.service"

In the cases of:

  • smart_manager/views/samba_service.py - (smb.service (we edit from /usr/lib/systemd and override by same name in /etc/systemd/system/)
  • smart_manager/views/docker_service.py - (docker.socket & docker.service)
  • scripts/initrock.py - (30-rockstor-nginx-override.conf)

We are using the correct directories as we are separating our config over that of the associated packages, which are themselves using the "/usr/lib/systemd/system" directive.

For our own rockstor* services,

  • scripts/initrock.py (rockstor-pre.service rockstor.service rockstor-bootstrap.servcie)
  • scripts/flash_optimize.py - (rockstor-fstrim.service rockstor-fstrim.timer)
  • system/osi.py - (rockstor-hdparm.service)

which do not override existing OS services, we should honour the upstream guidance of putting these into "/usr/lib/systemd/system" in order that we, ourselves, can be overridden (customized) via the /etc/systemd/system directory, or it's override specific variations, such as we do to nginx: but named after our own rockstor* services.

@phillxnet phillxnet self-assigned this Dec 9, 2022
phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Dec 9, 2022
Use initrock.py to move existing non override
rockstor services to the preferred location of
/usr/lib/systemd/system. There-by allowing for
admin override of our own services.
Our existing mechanism to update these same
service files is then run directly there-after.
Includes:
- modifying scripts/flash_optimize.py to comply.
- modifying system/osi to comply.
- added additional clean-up mechanism to remove known
legacy service files. Currently only used for the short
lived rockstor-ipv6check.service, which was used to remove
a previous non upstream default of disabling ipv6.
- general code tidies including:
-- clean abstraction of systemd paths.
-- update string formatting mechanism in flash_optimize.py.
-- removal of incompatible/ineffectual tmpfs setup for /tmp
--
phillxnet added a commit to phillxnet/rockstor-core that referenced this issue Dec 10, 2022
Without this we create ghost services that are thought
to be harmless. N.B. we still have this issue with
rockstor-hdparm.service, if drive power/spin-down services
were enabled. How-ever in that case there is a Web-UI
re-establishment route.
Thanks to @FroggyFlox for highlighting this failure.
phillxnet added a commit that referenced this issue Dec 10, 2022
…vice_files

relocate our systemd service files #2437
@phillxnet
Copy link
Member Author

Closing as:
Fixed by #2439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant