Skip to content

WIP: Option to disable service for systemd. #97

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

Open
wants to merge 1 commit into
base: kinetic-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/robot_upstart/install_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def get_argument_parser():
p.add_argument("pkgpath", type=str, nargs='+', metavar="pkg/path",
help="Package and path to install job launch files from. " +
DESC_PKGPATH)
p.add_argument("--disable", action='store_true', help="If set, disable by not placing systemd's unit files. Ignored for upstart.")
p.add_argument("--job", type=str,
help="Specify job name. If unspecified, will be constructed from package name (first " +
"element before underscore is taken, e.g. 'myrobot' if the package name is 'myrobot_bringup').")
Expand Down
12 changes: 8 additions & 4 deletions src/robot_upstart/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,20 @@ class Generic(object):
providers are implemented, may provide a place to store configuration
common to them. """

def __init__(self, root, job):
def __init__(self, root, job, disable=False):
""" Construct a new Provider.

:param root: The filesystem location to prefix all file-install
commands with.
:type root: str
:param job: The job definition to transform to a set of system files.
:type job: :py:class:robot_upstart.Job
:param disable: If True, service will be disabled.
:type disable: bool
"""
self.root = root
self.job = job
self.disable = disable

# Recipe structure which is serialized to yaml and passed to the mutate_files script.
self.installation_files = {}
Expand Down Expand Up @@ -177,9 +180,10 @@ def generate_install(self):

self.installation_files[os.path.join(self.root, "lib/systemd/system", self.job.name + ".service")] = {
"content": self._fill_template("templates/systemd_job.conf.em"), "mode": 0o644}
self.installation_files[os.path.join(self.root, "etc/systemd/system/multi-user.target.wants",
self.job.name + ".service")] = {
"symlink": os.path.join(self.root, "lib/systemd/system/", self.job.name + ".service")}
if self.disable:
self.installation_files[os.path.join(self.root, "etc/systemd/system/multi-user.target.wants",
self.job.name + ".service")] = {
"symlink": os.path.join(self.root, "lib/systemd/system/", self.job.name + ".service")}
self.installation_files[os.path.join(self.root, "usr/sbin", self.job.name + "-start")] = {
"content": self._fill_template("templates/job-start.em"), "mode": 0o755}
self.installation_files[os.path.join(self.root, "usr/sbin", self.job.name + "-stop")] = {
Expand Down