Revise systemd determination to verify systemctl presence

The base ubuntu image utilizes upstart, however it also
has a /usr/lib/systemd/system folder, which is not present
in the ubuntu-minimal images.

As a result of this, glean fails to properly work on hosts
created from the base ubuntu image. In order to address this
we should check for the presence of the systemd folder and
the systemctl utility.

Additionally, added a flag and minor logic changes to ensure
installation occurs only once.

Closes-bug: #1615673
Change-Id: I056819b4ae1e5ae1fea82fa8d34ad8cb05fe0383
This commit is contained in:
Julia Kreger 2016-02-12 16:43:02 -05:00 committed by Waldemar Znoinski
parent 8b74dec3c4
commit 3c5d0221ff
1 changed files with 10 additions and 1 deletions

View File

@ -96,7 +96,16 @@ def main():
log.info('installing openrc services')
install('glean.openrc', '/etc/init.d/glean')
subprocess.call(['rc-update', 'add', 'glean', 'boot'])
if os.path.exists('/usr/lib/systemd'):
# Needs to check for the presence of systemd and systemctl
# as apparently some packages may stage systemd init files
# when systemd is not present.
# We also cannot check the path for the init pid as the pid
# may be wrong as install is generally executed in a chroot
# with diskimage-builder.
if (os.path.exists('/usr/lib/systemd/system') and
(os.path.exists('/usr/bin/systemctl') or
os.path.exists('/bin/systemctl'))):
p = _find_gleansh_path()
log.info("Installing systemd services")