summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client/Tools/FreeBSDInit.py
blob: 8ff26d8f35db06b3dd16d6da48ff9c8506e91e81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""FreeBSD Init Support for Bcfg2."""
__revision__ = '$Rev$'

# TODO
# - hardcoded path to ports rc.d
# - doesn't know about /etc/rc.d/

import os
import Bcfg2.Client.Tools


class FreeBSDInit(Bcfg2.Client.Tools.SvcTool):
    """FreeBSD service support for Bcfg2."""
    name = 'FreeBSDInit'
    __handles__ = [('Service', 'freebsd')]
    __req__ = {'Service': ['name', 'status']}

    def __init__(self, logger, cfg, setup):
        Bcfg2.Client.Tools.Tool.__init__(self, logger, cfg, setup)
        if os.uname()[0] != 'FreeBSD':
            raise Bcfg2.Client.Tools.ToolInstantiationError

    def VerifyService(self, entry, _):
        return True

    def get_svc_command(self, service, action):
        return "/usr/local/etc/rc.d/%s %s" % (service.get('name'), action)