Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd support for Debian Jessie, Stretch, and Buster #1419

Merged
merged 1 commit into from
Feb 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from azurelinuxagent.common.osutil import get_osutil
import setuptools
from setuptools import find_packages
from setuptools.command.install import install as _install
from setuptools.command.install import install as _install
import subprocess
import sys

root_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -59,11 +60,13 @@ def set_systemd_files(data_files, dest="/lib/systemd/system",
data_files.append((dest, src))


def set_freebsd_rc_files(data_files, dest="/etc/rc.d/", src=["init/freebsd/waagent"]):
def set_freebsd_rc_files(data_files, dest="/etc/rc.d/",
src=["init/freebsd/waagent"]):
data_files.append((dest, src))


def set_openbsd_rc_files(data_files, dest="/etc/rc.d/", src=["init/openbsd/waagent"]):
def set_openbsd_rc_files(data_files, dest="/etc/rc.d/",
src=["init/openbsd/waagent"]):
data_files.append((dest, src))


Expand Down Expand Up @@ -92,7 +95,6 @@ def get_data_files(name, version, fullname):
if version.startswith("7.1"):
# TODO this is a mitigation to systemctl bug on 7.1
set_sysv_files(data_files)

elif name == 'arch':
set_bin_files(data_files, dest="/usr/bin")
set_conf_files(data_files, src=["config/arch/waagent.conf"])
Expand Down Expand Up @@ -138,7 +140,7 @@ def get_data_files(name, version, fullname):
set_udev_files(data_files)
if fullname == 'SUSE Linux Enterprise Server' and \
version.startswith('11') or \
fullname == 'openSUSE' and version.startswith(
fullname == 'openSUSE' and version.startswith(
'13.1'):
set_sysv_files(data_files, dest='/etc/init.d',
src=["init/suse/waagent"])
Expand All @@ -158,6 +160,8 @@ def get_data_files(name, version, fullname):
set_conf_files(data_files, src=["config/debian/waagent.conf"])
set_logrotate_files(data_files)
set_udev_files(data_files, dest="/lib/udev/rules.d")
if debian_has_systemd():
set_systemd_files(data_files)
elif name == 'iosxe':
set_bin_files(data_files)
set_conf_files(data_files, src=["config/iosxe/waagent.conf"])
Expand All @@ -182,6 +186,14 @@ def get_data_files(name, version, fullname):
return data_files


def debian_has_systemd():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of debian_has_systemd() is cleaner than the earlier approach. Thanks for doing the change. 👍

try:
return subprocess.check_output(
['cat', '/proc/1/comm']).strip() == 'systemd'
except subprocess.CalledProcessError:
return False


class install(_install):
user_options = _install.user_options + [
('lnx-distro=', None, 'target Linux distribution'),
Expand Down Expand Up @@ -217,6 +229,7 @@ def run(self):
osutil.stop_agent_service()
osutil.start_agent_service()


# Note to packagers and users from source.
# In version 3.5 of Python distribution information handling in the platform
# module was deprecated. Depending on the Linux distribution the
Expand Down