Dotfile repository using SaltStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
pinch-dotfiles/bootstrap.sh

106 lines
2.8 KiB

#!/bin/bash
# This script will bootstrap the machine using SaltStack
# Copyright (C) 2017 Elijah Lazkani
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
function _main () {
case "$(uname -s)" in
Darwin)
_mac_os_x
;;
Linux)
_linux
;;
CYGWIN*|MINGW32*|MSYS*)
_windows
;;
*)
_unknown_os
;;
esac
}
function _mac_os_x () {
echo "Operating System identified as Mac OS X"
# Check for Homebrew
command brew help > /dev/null 2>&1
if [ $? -ne 0 ];
then
echo "Homebrew not installed, installing..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Check SaltStack
command salt-call -h > /dev/null 2>&1
if [ $? -ne 0 ];
then
echo "SaltStack not installed, installing..."
#brew install saltstack
fi
_saltstack
}
function _linux () {
echo "Operating System identified as Linux"
# Check Saltstack
command salt-call -h > /dev/null 2>&1
if [ $? -ne 0 ];
then
echo "SaltStack not installed, installing..."
curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.com
sudo sh bootstrap-salt.sh git develop
echo "Cleaning installation script"
rm bootstrap-salt.sh
fi
_saltstack
}
function _windows () {
echo "Operating System identified as... what?"
echo "Get a real OS..."
exit 1
}
function _unknown_os () {
echo "Operating System was not identified"
exit 1
}
function _saltstack () {
echo "Bootstrapping SaltStack"
sudo salt-call --local --config=./ --state-output=changes grains.setvals "{ \"user\": \"$(whoami)\", \"group\": \"$(id -g -n $(whoami))\", \"homedir\": \"$HOME\" }"
if [[ $state ]];
then
echo "Running $state... Sit down and chillax..."
sudo salt-call --local --config=./ --state-output=changes --log-level=quiet state.sls $state
else
echo "Sit down and chillax..."
sudo salt-call --local --config=./ --state-output=changes --log-level=quiet state.apply
fi
}
state="$1"
_main