summaryrefslogtreecommitdiff
path: root/bootstrap/run_salt.sh
blob: 3977e9cc5611d1b0a220c743d00f655b38817ab2 (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
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash -e

working_dir="${1}"
build_basedir="${2}"
local_build="${3}"

salt_running_p() {
    ps -ef | grep -F "salt-call" | grep -v "grep"
    return ${?}
}

python3_supported=$(python <<EOF
try:
    from salt.scripts import salt_call
    print("success")
except ImportError:
    print("fail")
EOF
)

if [ "${python3_supported}" == "success" ]; then
    python=$(which python)
else
    python=$(which python2)
fi

while salt_running_p; do
    sleep 5
done

${python} $(which salt-call) \
    --local \
    --pillar-root=${working_dir}/pillar \
    --file-root=${working_dir}/salt \
    state.highstate \
    pillar="$($(dirname ${0})/pillar_config.rb --build-basedir=${build_basedir} --local-build=${local_build})"

exit 0