-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.sh
executable file
·50 lines (45 loc) · 1.41 KB
/
init.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
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
HOMEDIR=$HOME
USERNAME=$(whoami)
USE_SUDO=''
if [ $USERNAME != "root" ];
then
USE_SUDO="sudo "
fi
# Are we on OSX and do we need homebrew?
if [[ `uname` == 'Darwin' ]];
then
command -v brew > /dev/null 2>&1
if [ $? -ne 0 ];
then
echo "Homebrew not found. Installing ..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Do we need to install SaltStack?
command -v salt-call > /dev/null 2>&1
if [ $? -ne 0 ];
then
echo "SaltStack not found. Installing ..."
brew install saltstack
fi
else
# Do we need to install SaltStack?
command -v salt-call > /dev/null 2>&1
if [ $? -ne 0 ];
then
echo "We need SaltStack ..."
# Linux (Hopefully ...): SaltStack Bootstrap one-liner
# -d Don't enable salt-minion autostart
# -P Allow pip based installations
wget -qO- https://bootstrap.saltstack.com | $USE_SUDO sh -s -- -P -d git v2016.11.3
fi
fi
# Set the user, home-directory, and state root
$USE_SUDO salt-call --local --config=./ --state-output=changes grains.setvals "{ \"user\": \"$USERNAME\", \"homedir\": \"$HOMEDIR\" }"
# Apply the high state
if [[ ! $1 ]];
then
$USE_SUDO salt-call --local --config=./ --state_verbose=False --state-output=mixed --log-level=quiet --retcode-passthrough state.highstate
else
$USE_SUDO salt-call --local --config=./ --state_verbose=False --state-output=mixed --log-level=quiet --retcode-passthrough state.sls $1
fi