apacheds.service script not running from systemctl correctly

Bug #1646146 reported by Brian Swan
42
This bug affects 7 people
Affects Status Importance Assigned to Milestone
apache-directory-server (Ubuntu)
Undecided
Unassigned

Bug Description

Hello,

I'm not sure if this is more of a general bug with Systemd/systemctl, but the apacheds.service file doesn't seem to read the EnvironmentFile variable, or at least doesn't act upon the variable therein.

While trying to start the apacheds service from systemctl I get the following errors:

----
bswan@ds:/lib/systemd/system$ sudo systemctl start apacheds
Failed to start apacheds.service: Unit apacheds.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status apacheds.service' for details.
bswan@ds:/lib/systemd/system$ sudo systemctl status apacheds
● apacheds.service - Apache Directory Server
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Nov 30 08:17:18 ds systemd[1]: apacheds.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 30 08:17:45 ds systemd[1]: [/lib/systemd/system/apacheds.service:11] Executable path is not absolute, ignoring: ${JAVA_HOME}/bin/
Nov 30 08:17:45 ds systemd[1]: apacheds.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 30 08:29:27 ds systemd[1]: apacheds.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 30 08:30:50 ds systemd[1]: [/lib/systemd/system/apacheds.service:11] Executable path is not absolute, ignoring: ${JAVA_HOME}/bin/
Nov 30 08:30:50 ds systemd[1]: apacheds.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 30 08:35:54 ds systemd[1]: apacheds.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 30 08:49:04 ds systemd[1]: apacheds.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Nov 30 08:59:28 ds systemd[1]: [/lib/systemd/system/apacheds.service:12] Executable path is not absolute, ignoring: ${JAVA_HOME}/bin/
Nov 30 08:59:28 ds systemd[1]: apacheds.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
----

After much experimentation the work-around to get it working is to just copy the environment variables from /etc/default/apacheds and paste them into their appropriate places in the apacheds.service file and put the entire thing on one very long line.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in apache-directory-server (Ubuntu):
status: New → Confirmed
Revision history for this message
Zhang Zhongyi (ohnozzy) wrote :

Since the official fix is not out yet, I would like to give more detail on the workaround.
After investigation.
There two problems:

1. In the /lib/systemd/system/apacheds.service
ExecStart=${JAVA_HOME}/bin/java
The ExecStart does not accept environment variable as part of the path to the executable. So replace ${JAVA_HOME} with /usr/bin/java or /usr/lib/jvm/default-java

2. In the /etc/default/apacheds
ADS_INSTANCES="$ADS_HOME/instances"
Since variable expansion is not performed inside the strings for environment variables, replace $ADS_HOME with /usr/share/apacheds

Revision history for this message
Demitrius Belai (demitriusbelai) wrote :

My fix is little different. I just rewrited ExecStart with '/bin/sh -c':

ExecStart=/bin/sh -c "${JAVA_HOME}/bin/java ${JAVA_OPTS} \
            -Dapacheds.controls=${ADS_CONTROLS} \
            -Dapacheds.extendedOperations=${ADS_EXTENDED_OPERATIONS} \
            -Dlog4j.configuration=file:${ADS_INSTANCES}/${ADS_INSTANCE}/conf/log4j.properties \
            -Dapacheds.log.dir=${ADS_INSTANCES}/${ADS_INSTANCE}/log \
            -cp '${ADS_HOME}/lib/*' \
            org.apache.directory.server.UberjarMain \
            ${ADS_INSTANCES}/${ADS_INSTANCE}/"

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch for apacheds.service" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Andreas Wahlfeldt (zaphod-b) wrote :

2.0.0~M15-4 on Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-45-generic x86_64) still suffers from this bug.
None of the suggested Solutions here worked for me.

The apache-directory-server package should be fixed or removed from Ubuntu.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers