I have the following (anonymised) systemd script called tomcat-autostart.service, stored in "/usr/lib/systemd/system/tomcat-autostart.service"
[Unit]
Description=Tomcat Autostart Script
Requires=var-www-projects.mount
After=var-www-projects.mount
[Service]
Type=forking
ExecStart=/usr/bin/tomcat-autostart start
ExecStop=/usr/bin/tomcat-autostart stop
[Install]
WantedBy=multi-user.target
After running
sudo systemctl daemon-reload
sudo systemctl enable tomcat-autostart.service
I get the error message:
Failed to execute operation: Bad message
And I also get the following output in /var/log/messages
Feb 17 11:29:53 cheese systemd: [/usr/lib/systemd/system/tomcat-autostart.service:1] Assignment outside of section. Ignoring.
Feb 17 11:29:53 cheese systemd: tomcat-autostart.service lacks both ExecStart= and ExecStop= setting. Refusing.
Feb 17 11:29:53 cheese systemd: [/usr/lib/systemd/system/tomcat-autostart.service:1] Missing '='.
Feb 17 11:29:53 cheese systemd: [/usr/lib/systemd/system/tomcat-autostart.service:1] Missing '='.
I had it working for a while, then I added some comments above the '[Unit]' line, and it stopped working. I then removed the comments, and probably unintentionally modified something else in the script, and I haven't been able to get it working again after that.
It seems to delight it in it's own contradiction. The first error message says that there is an assignment on the first line ('[Unit]'), and the third says that the assignment is missing an '=' sign. So basically, '[Unit]' is an assignment, except that it isn't because it is missing an '=' sign.
Searching for this problem has determined that the second error message is a direct cause of the others. Because it is ignoring the section headers, it never reads the ExecStart and ExecStop declarations. If I can solve the first and third error messages, I should be able to
What is the actual problem with my script? Running 'sudo /usr/bin/tomcat-autostart start' succeeds as expected, and the most common cause on the internet for this error message is having the script not use absolute paths (which I do in this case)