aboutsummaryrefslogtreecommitdiff
path: root/sysutils/py-salt/files/salt_proxy.in
blob: 5f93b35361adb2d1b7672d898d82e27d3e99ecb1 (plain) (blame)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh

# Salt Proxy startup script
#
# PROVIDE: salt_proxy
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following to /etc/rc.conf[.local] to enable this service
#
# salt_proxy_enable (bool):        Set to NO by default.
#               Set it to YES to enable salt_proxy.
# salt_proxy_paths (string):       Set to "/sbin:/bin:/usr/sbin:/usr/bin:%%PREFIX%%/bin:%%PREFIX%%/sbin" by default.
#               Default $PATH for Salt
# salt_proxy_eggcache (string):    Set to "/tmp" by default.
#               Allows defining egg cache directory to fix runtime on diskless systems.
# salt_proxy_list (string):        Set to "" by default.
#               Space separated list of proxies.
#

. /etc/rc.subr

name=salt_proxy
rcvar=salt_proxy_enable

load_rc_config ${name}

: ${salt_proxy_enable:=NO}
: ${salt_proxy_paths=/sbin:/bin:/usr/sbin:/usr/bin:%%PREFIX%%/bin:%%PREFIX%%/sbin}
: ${salt_proxy_eggcache=/tmp}

start_cmd=salt_proxy_start

command="%%PREFIX%%/bin/salt-proxy"
command_interpreter="%%PYTHON_CMD%%"
required_files="%%PREFIX%%/etc/salt"
command_args="-c ${required_files} -d"

export PATH="${salt_proxy_paths}"
export PYTHON_EGG_CACHE="${salt_proxy_eggcache}"

salt_proxy_start()
{
    if [ ! -n "${salt_proxy_list}" ]; then
        echo "${salt_proxy_list} is undefined"
        return 1
    fi

    local _proxy

    for _proxy in ${salt_proxy_list}; do
        echo "Starting salt-proxy: ${_proxy}"
        ${command_interpreter} ${command} --proxyid ${_proxy} ${command_args}
    done
}

run_rc_command "$1"