0

I build an RPM using fpm for EL6 hosts. It installs a /etc/init.d script. However if that package is installed on an EL7 host, I want it to install a file in /usr/lib/systemd/system instead.

Is there an easy way to tell FPM to make an RPM that will install different files on different operating systems?

If not, is it safe to install both and assume that EL6 hosts will ignore the systemd file, and EL7 hosts will ignore the /etc/init.d script?

TomOnTime
  • 7,945
  • 6
  • 32
  • 52
  • Probably best to avoid dropping the unit file in place on EL6 nodes, since the `/usr/lib/systemd/system/` directory tree won't exist there and would need to be created. – Shane Madden Mar 27 '15 at 18:07

1 Answers1

2

just deliver your startup scripts (so the 'init' and the 'systemd' scripts) along with your other files - and not directly to the 'init.d' respectively 'systemd' folder. then detect in the post-install phase (e.g. via the "/etc/redhat-release") whether you are on EL6 or on EL7 and then copy the relevant startup script accordingly ...

  • Where should the scripts be delivered to before they are copied to their proper destination? – TomOnTime Jan 30 '16 at 18:55
  • hmmh, in such a case (where you just select the right one, copy it to the destination and throw away the other script as you don't need it) i would drop them in e.g. /tmp ... this could of course vary with the use case. and: you shouldn't forget about a pre-uninstall script which removes it when uninstalling the rpm ! – Juergen Klasen Feb 01 '16 at 06:03
  • I was hoping RPM defined a better place than putting them in /tmp. If I knew someone was going to write to /tmp as root, I'd put a symlink there to /etc/passwd so that when they wrote the file it would smash their password file. I mean... I wouldn't do that... but someone mean person might. – TomOnTime Feb 01 '16 at 06:42
  • basically you can put the files to any place you want (like ~root, if you feel this is safer :) – Juergen Klasen Feb 02 '16 at 07:11
  • ... but: such service start scripts typically are anyway readable to anybody - right ? if you place those during installation time to /tmp and with the post-install script copy the desired script to '/etc/init.d' respectively to '/usr/lib/systemd/system/', and set the right permissions(!!!), ... how shall this compromise security ? these service startup scripts are nothing secret – Juergen Klasen Feb 02 '16 at 07:19