Centos – Need help converting init.d service scripts to systemd (CentOS)

centosredhatrhel7servicesystemd

I have spent several days on an issue that's incredibly frustrating and I'm straight out of options.

I am currently using a CentOS 6.8 server at work for our website. CentOS 6 (Enterprise Linux 6 or EL6) uses the older init.d model for startup scripts.
There is a program my boss requires me to use, the SonicWALL CDP Agent. He has a SonicWALL backup server, and their "agent" software runs in the background to back up specific files and folders to the server. It's actually built upon Acronis TrueImage, but that's another story.

The biggest issue is that their CDP agent uses Adobe AIR. They must have designed it this way to be cross-platform (as they have an installer for Windows/OSX/Linux), but of course Adobe completely stopped supporting AIR on 64-bit Linux some time ago. Their site gives some steps for getting it installed, but that dates back to Red Hat 5.5, not even 6.

I did manage to get AIR to install on EL7 by following the steps for EL6, and just noting where the package names had changed in the repos. Interesting to note that the normal GUI installer (AdobeAIRInstaller.bin) doesn't work and gives some error about "maybe your admin prohibits installs" even when running as root), but the .rpm files work.

I have the most current ones:
adobeair-core-2.6.0-19170.noarch.rpm
adobeair-2.6.0-19170.i686.rpm

Combined with the GTK2 i686 libraries, this actually works.

However, the CDP Agent is more complicated than this. There are two system services that need to run in order for the agent software to actually work (and if you think about it, this would be required for the automatic backups to work anyway.)

Their installer, however, is years old and places the startup scripts in init.d. This is "supposed" to work in EL7, but it doesn't. I've spent hours fiddling with this and it simply does not work.

So basically, there are two binaries that need to run. The commands to start them are:

/sbin/cdp/cdpagentproxy  
/sbin/cdp/cdpdaemon start  

If I open a terminal and run these manually, they work – and I can open the CDP Agent and it works. However, they aren't starting up at boot due to the init.d/systemd incompatibility.

So I made a couple simple "services" and placed them in the right spots. The cdpdaemon.service file, for example:

[Unit]
Description=CDP Daemon Service
After=syslog.target network.target

[Service]
Type=forking
ExecStart=/sbin/cdp/cdpdaemon start

[Install]
WantedBy=multi-user.target

I placed this in /usr/lib/systemd/system/cdpdaemon.service and made a symlink to it in /etc/systemd/system/multi-user.target.wants/cdpdaemon.service.

But here's what happens when I try to check the status:

[root@localhost Desktop]# systemctl status cdpdaemon.service
● cdpdaemon.service - CDP Daemon Service
   Loaded: loaded (/usr/lib/systemd/system/cdpdaemon.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2016-08-21 22:08:13 EDT; 10s ago
      Process: 1596 ExecStart=/sbin/cdp/cdpdaemon start (code=exited, status=0/SUCCESS)
 Main PID: 1633 (code=exited, status=127)

Aug 21 22:08:13 localhost.localdomain systemd[1]: Starting CDP Daemon Service...
Aug 21 22:08:13 localhost.localdomain cdpdaemon[1596]: Starting  process.
Aug 21 22:08:13 localhost.localdomain systemd[1]: Started CDP Daemon Service.
Aug 21 22:08:13 localhost.localdomain systemd[1]: cdpdaemon.service: main process exited, code=exited, status=127/n/a
Aug 21 22:08:13 localhost.localdomain systemd[1]: Unit cdpdaemon.service entered failed state.
Aug 21 22:08:13 localhost.localdomain systemd[1]: cdpdaemon.service failed.

The other one does that same thing. It looks like it tries to run, but then stops and reports an error. If I open a terminal and simply type /sbin/cdp/cdpdaemon start, it works perfectly fine.

Am I doing something wrong here? I don't understand the different types of "target" options nor the "after" and type. (I basically took a working service, copied the text and changed the command)

I suppose another option would be to make a cronjob that runs at a certain time (let's say 11pm, if the backups run at midnight) that runs the two commands, but that seems like the wrong way to go about this.

The program DOES run, I just can't get it to run on its own without me starting the two helper processes.

Edit: I thought I'd provide the install .sh file in case it helps. You can see where it checks what distro you're running and creates the init.d scripts.

http://pastebin.com/FmrZcmcR

Best Answer

"Type=fokring" is for services that fork a child and put that into background and themselves exit normally. Looking at your output it feels like your programs do not do that. what happens if you change "Type=forking" to "Type=simple"?