-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·42 lines (35 loc) · 1.43 KB
/
install.sh
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
#!/usr/bin/env bash
# rector.conf - The Salt reactor configuration file.
# mrSaltSlack_ret.sls - Salt sls file that sends data to Slack when a function returns.
# mrSaltSlack_start.sls - Salt sls file that sends data to Slack when a minion starts.
# Read the Slack webhook identifier
echo "Insert your Slack webhook identifier:"
read identifier
mkdir -p /etc/salt
mkdir -p /etc/salt/master.d
touch /etc/salt/master.d/reactor.conf
mkdir -p /srv/reactor
cp src/mrSaltSlack_ret.sls /srv/reactor/
cp src/mrSaltSlack_start.sls /srv/reactor/
cp src/mrSaltSlack_auth.sls /srv/reactor/
# If the reactor has been declared, only insert the reactor connection.
if grep -q 'reactor:' /etc/salt/master.d/reactor.conf; then
echo "
- 'salt/minion/*/start':
- /srv/reactor/mrSaltSlack_start.sls
- 'salt/job/*/ret/*':
- /srv/reactor/mrSaltSlack_ret.sls
" >> /etc/salt/master.d/reactor.conf
else
echo "
reactor:
- 'salt/minion/*/start':
- /srv/reactor/mrSaltSlack_start.sls
- 'salt/job/*/ret/*':
- /srv/reactor/mrSaltSlack_ret.sls
" >> /etc/salt/master.d/reactor.conf
fi
# Insert slack webhook identifier in mrSaltSlack sls files. (Replace placeholder "[[slack-identifier]]" with the supplied webhook identifier)
sed -i "s|identifierplaceholder|$identifier|g" /srv/reactor/mrSaltSlack_ret.sls
sed -i "s|identifierplaceholder|$identifier|g" /srv/reactor/mrSaltSlack_start.sls
sed -i "s|identifierplaceholder|$identifier|g" /srv/reactor/mrSaltSlack_auth.sls