-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage
executable file
·49 lines (43 loc) · 925 Bytes
/
manage
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
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Install salt from source.
if ! command -v salt-call > /dev/null; then
salt_dir=~/oss/salt
if ! [ -d $salt_dir ]; then
git clone [email protected]:saltstack/salt.git $salt_dir
fi
pip3 install -e $salt_dir
fi
# Own /etc/salt.
if ! [ -d /etc/salt ]; then
echo "Creating /etc/salt..."
sudo mkdir -p /etc/salt
fi
owner="$(gstat -c '%U' /etc/salt)"
if [[ "$owner" != "$USER" ]]; then
echo "Chowning /etc/salt..."
sudo chown -vR "$USER" /etc/salt
fi
# Configure salt
mkdir -p /etc/salt
cat << EOF > /etc/salt/minion
root_dir: /etc/salt/
log_level: info
minion_id_caching: False
file_client: local
local: true
file_roots:
base:
- $DIR/salt
pillar_roots:
base:
- $DIR/salt/pillar
EOF
command="$1"
if [ -n "$command" ]; then
shift
else
command=state.highstate
fi
salt-call --retcode-passthrough "$command" "$@"