2013-01-18 00:24:01 +00:00
|
|
|
#!/bin/sh -
|
2012-10-17 14:02:09 +01:00
|
|
|
#===============================================================================
|
|
|
|
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en
|
|
|
|
#===============================================================================
|
|
|
|
#
|
2013-02-07 01:44:38 +00:00
|
|
|
# FILE: bootstrap-salt.sh
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
2012-10-17 16:28:43 +01:00
|
|
|
# DESCRIPTION: Bootstrap salt installation for various systems/distributions
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
2012-10-17 16:28:43 +01:00
|
|
|
# BUGS: https://github.com/saltstack/salty-vagrant/issues
|
2012-10-17 14:02:09 +01:00
|
|
|
# AUTHOR: Pedro Algarvio (s0undt3ch), pedro@algarvio.me
|
2012-11-28 12:26:44 -08:00
|
|
|
# Alec Koumjian (akoumjian), akoumjian@gmail.com
|
2013-02-12 20:58:50 +00:00
|
|
|
# Geoff Garside (geoffgarside), geoff@geoffgarside.co.uk
|
2013-01-24 17:46:40 +00:00
|
|
|
# LICENSE: Apache 2.0
|
2012-10-17 16:28:43 +01:00
|
|
|
# ORGANIZATION: Salt Stack (saltstack.org)
|
2012-10-17 14:02:09 +01:00
|
|
|
# CREATED: 10/15/2012 09:49:37 PM WEST
|
|
|
|
#===============================================================================
|
|
|
|
set -o nounset # Treat unset variables as an error
|
2013-02-26 23:29:17 +00:00
|
|
|
ScriptVersion="1.5.1"
|
2013-02-07 01:44:38 +00:00
|
|
|
ScriptName="bootstrap-salt.sh"
|
2012-10-18 22:18:07 +01:00
|
|
|
|
2013-02-12 18:35:31 +00:00
|
|
|
#===============================================================================
|
|
|
|
# Environment variables taken into account.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# * BS_COLORS: If 0 disables colour support
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
#===============================================================================
|
|
|
|
# LET THE BLACK MAGIC BEGIN!!!!
|
|
|
|
#===============================================================================
|
|
|
|
|
2013-02-12 18:35:31 +00:00
|
|
|
|
2013-02-11 20:44:46 +00:00
|
|
|
# Bootstrap script truth values
|
|
|
|
BS_TRUE=1
|
|
|
|
BS_FALSE=0
|
2013-02-11 20:22:33 +00:00
|
|
|
|
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __detect_color_support
|
|
|
|
# DESCRIPTION: Try to detect color support.
|
|
|
|
#-------------------------------------------------------------------------------
|
2013-02-12 18:35:31 +00:00
|
|
|
COLORS=${BS_COLORS:-$(tput colors 2>/dev/null || echo 0)}
|
2013-02-11 20:22:33 +00:00
|
|
|
__detect_color_support() {
|
|
|
|
if [ $? -eq 0 ] && [ "$COLORS" -gt 2 ]; then
|
|
|
|
RC="\033[1;31m"
|
|
|
|
GC="\033[1;32m"
|
|
|
|
BC="\033[1;34m"
|
2013-02-20 12:09:35 +00:00
|
|
|
YC="\033[1;33m"
|
2013-02-11 20:22:33 +00:00
|
|
|
EC="\033[0m"
|
|
|
|
else
|
|
|
|
RC=""
|
|
|
|
GC=""
|
|
|
|
BC=""
|
2013-02-20 12:09:35 +00:00
|
|
|
YC=""
|
2013-02-11 20:22:33 +00:00
|
|
|
EC=""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
__detect_color_support
|
|
|
|
|
|
|
|
|
2013-02-11 19:17:21 +00:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: echoerr
|
|
|
|
# DESCRIPTION: Echo errors to stderr.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
echoerror() {
|
2013-02-12 23:16:33 +00:00
|
|
|
printf "${RC} * ERROR${EC}: $@\n" 1>&2;
|
2013-02-11 19:17:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: echoinfo
|
|
|
|
# DESCRIPTION: Echo information to stdout.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
echoinfo() {
|
2013-02-12 23:16:33 +00:00
|
|
|
printf "${GC} * INFO${EC}: $@\n";
|
2013-02-11 19:17:21 +00:00
|
|
|
}
|
|
|
|
|
2013-02-20 12:09:35 +00:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: echowarn
|
|
|
|
# DESCRIPTION: Echo warning informations to stdout.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
echowarn() {
|
|
|
|
printf "${YC} * WARN${EC}: $@\n";
|
|
|
|
}
|
|
|
|
|
2013-02-11 19:17:21 +00:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: echodebug
|
|
|
|
# DESCRIPTION: Echo debug information to stdout.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
echodebug() {
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $ECHO_DEBUG -eq $BS_TRUE ]; then
|
2013-02-12 23:16:33 +00:00
|
|
|
printf "${BC} * DEBUG${EC}: $@\n";
|
2013-02-11 20:44:46 +00:00
|
|
|
fi
|
2013-02-11 19:17:21 +00:00
|
|
|
}
|
|
|
|
|
2012-10-17 16:07:33 +01:00
|
|
|
#=== FUNCTION ================================================================
|
|
|
|
# NAME: usage
|
|
|
|
# DESCRIPTION: Display usage information.
|
|
|
|
#===============================================================================
|
|
|
|
usage() {
|
|
|
|
cat << EOT
|
|
|
|
|
2012-11-29 01:44:45 +00:00
|
|
|
Usage : ${ScriptName} [options] <install-type> <install-type-args>
|
2012-10-17 16:07:33 +01:00
|
|
|
|
|
|
|
Installation types:
|
|
|
|
- stable (default)
|
2012-10-19 12:22:59 +01:00
|
|
|
- daily (ubuntu specific)
|
2012-10-17 16:07:33 +01:00
|
|
|
- git
|
|
|
|
|
2012-10-19 12:22:59 +01:00
|
|
|
Examples:
|
2012-11-29 01:44:45 +00:00
|
|
|
$ ${ScriptName}
|
|
|
|
$ ${ScriptName} stable
|
|
|
|
$ ${ScriptName} daily
|
|
|
|
$ ${ScriptName} git
|
|
|
|
$ ${ScriptName} git develop
|
|
|
|
$ ${ScriptName} git 8c3fadf15ec183e5ce8c63739850d543617e4357
|
2012-10-19 12:22:59 +01:00
|
|
|
|
2012-10-17 16:07:33 +01:00
|
|
|
Options:
|
2013-01-25 17:57:12 +00:00
|
|
|
-h Display this message
|
|
|
|
-v Display script version
|
2013-02-11 20:22:33 +00:00
|
|
|
-n No colours.
|
2013-02-11 20:44:46 +00:00
|
|
|
-D Show debug output.
|
2013-02-15 12:55:36 +00:00
|
|
|
-c Temporary configuration directory
|
2013-01-25 17:57:12 +00:00
|
|
|
-M Also install salt-master
|
|
|
|
-S Also install salt-syndic
|
|
|
|
-N Do not install salt-minion
|
2013-02-10 19:46:56 +00:00
|
|
|
-C Only run the configuration function. This option automaticaly
|
|
|
|
bypasses any installation.
|
|
|
|
|
2012-10-17 16:07:33 +01:00
|
|
|
EOT
|
|
|
|
} # ---------- end of function usage ----------
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
# Handle command line arguments
|
|
|
|
#-----------------------------------------------------------------------
|
2012-11-28 18:13:19 +00:00
|
|
|
TEMP_CONFIG_DIR="null"
|
2013-02-11 20:44:46 +00:00
|
|
|
INSTALL_MASTER=$BS_FALSE
|
|
|
|
INSTALL_SYNDIC=$BS_FALSE
|
|
|
|
INSTALL_MINION=$BS_TRUE
|
|
|
|
ECHO_DEBUG=$BS_FALSE
|
2013-02-10 19:46:56 +00:00
|
|
|
CONFIG_ONLY=$BS_FALSE
|
2012-10-17 16:07:33 +01:00
|
|
|
|
2013-02-10 19:46:56 +00:00
|
|
|
while getopts ":hvnDc:MSNC" opt
|
2012-10-17 16:07:33 +01:00
|
|
|
do
|
2013-01-25 17:57:12 +00:00
|
|
|
case "${opt}" in
|
|
|
|
|
2013-02-11 20:54:28 +00:00
|
|
|
h ) usage; exit 0 ;;
|
2013-01-25 17:57:12 +00:00
|
|
|
|
2013-02-11 21:27:54 +00:00
|
|
|
v ) echo "$0 -- Version $ScriptVersion"; exit 0 ;;
|
|
|
|
n ) COLORS=0; __detect_color_support ;;
|
|
|
|
D ) ECHO_DEBUG=$BS_TRUE ;;
|
2013-02-11 22:11:00 +00:00
|
|
|
c ) TEMP_CONFIG_DIR="$OPTARG"
|
|
|
|
# If the configuration directory does not exist, error out
|
|
|
|
if [ ! -d "$TEMP_CONFIG_DIR" ]; then
|
|
|
|
echoerror "The configuration directory ${TEMP_CONFIG_DIR} does not exist."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
2013-02-11 21:27:54 +00:00
|
|
|
M ) INSTALL_MASTER=$BS_TRUE ;;
|
|
|
|
S ) INSTALL_SYNDIC=$BS_TRUE ;;
|
|
|
|
N ) INSTALL_MINION=$BS_FALSE ;;
|
|
|
|
C ) CONFIG_ONLY=$BS_TRUE ;;
|
2013-01-25 17:57:12 +00:00
|
|
|
|
|
|
|
\?) echo
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Option does not exist : $OPTARG"
|
2013-01-25 17:57:12 +00:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
2012-10-17 16:07:33 +01:00
|
|
|
|
|
|
|
esac # --- end of case ---
|
|
|
|
done
|
|
|
|
shift $(($OPTIND-1))
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2013-02-07 20:48:50 +00:00
|
|
|
|
2012-11-29 01:27:43 +00:00
|
|
|
__check_unparsed_options() {
|
|
|
|
shellopts="$1"
|
2012-11-29 03:40:18 +00:00
|
|
|
unparsed_options=$( echo "$shellopts" | grep -E '[-]+[[:alnum:]]' )
|
2012-11-29 01:27:43 +00:00
|
|
|
if [ "x$unparsed_options" != "x" ]; then
|
|
|
|
usage
|
2013-02-11 19:17:21 +00:00
|
|
|
echo
|
|
|
|
echoerror "options are only allowed before install arguments"
|
|
|
|
echo
|
2012-11-29 01:27:43 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
2013-01-25 02:01:00 +00:00
|
|
|
|
2013-02-11 21:58:59 +00:00
|
|
|
|
2013-01-25 02:01:00 +00:00
|
|
|
# Check that we're actually installing one of minion/master/syndic
|
2013-02-11 21:27:54 +00:00
|
|
|
if [ $INSTALL_MINION -eq $BS_FALSE ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && [ $CONFIG_ONLY -eq $BS_FALSE ]; then
|
|
|
|
echoerror "Nothing to install or configure"
|
2013-01-25 02:16:41 +00:00
|
|
|
exit 1
|
2013-01-25 02:01:00 +00:00
|
|
|
fi
|
|
|
|
|
2013-02-11 21:27:54 +00:00
|
|
|
if [ $CONFIG_ONLY -eq $BS_TRUE ] && [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
echoerror "In order to run the script in configuration only mode you also need to provide the configuration directory."
|
2013-01-25 02:16:41 +00:00
|
|
|
exit 1
|
2013-01-25 02:01:00 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-17 14:02:09 +01:00
|
|
|
# Define installation type
|
|
|
|
if [ "$#" -eq 0 ];then
|
|
|
|
ITYPE="stable"
|
|
|
|
else
|
2012-11-29 01:27:43 +00:00
|
|
|
__check_unparsed_options "$*"
|
2012-10-17 14:02:09 +01:00
|
|
|
ITYPE=$1
|
2012-10-19 12:22:59 +01:00
|
|
|
shift
|
2012-10-17 14:02:09 +01:00
|
|
|
fi
|
|
|
|
|
2013-01-25 00:03:27 +00:00
|
|
|
# Check installation type
|
2013-01-21 17:14:41 +00:00
|
|
|
if [ "$ITYPE" != "stable" ] && [ "$ITYPE" != "daily" ] && [ "$ITYPE" != "git" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Installation type \"$ITYPE\" is not known..."
|
2012-10-17 14:02:09 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2012-09-06 23:17:02 +10:00
|
|
|
|
2013-01-25 00:03:27 +00:00
|
|
|
# If doing a git install, check what branch/tag/sha will be checked out
|
2012-10-19 12:22:59 +01:00
|
|
|
if [ $ITYPE = "git" ]; then
|
|
|
|
if [ "$#" -eq 0 ];then
|
|
|
|
GIT_REV="master"
|
|
|
|
else
|
2012-11-29 01:27:43 +00:00
|
|
|
__check_unparsed_options "$*"
|
2012-11-28 18:47:20 +00:00
|
|
|
GIT_REV="$1"
|
2012-10-19 12:22:59 +01:00
|
|
|
shift
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-01-25 00:03:27 +00:00
|
|
|
# Check for any unparsed arguments. Should be an error.
|
2012-10-19 12:22:59 +01:00
|
|
|
if [ "$#" -gt 0 ]; then
|
2012-11-29 01:27:43 +00:00
|
|
|
__check_unparsed_options "$*"
|
2012-10-19 12:22:59 +01:00
|
|
|
usage
|
2013-02-11 21:58:59 +00:00
|
|
|
echo
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Too many arguments."
|
2013-02-07 20:48:50 +00:00
|
|
|
exiterr 1
|
2012-10-19 12:22:59 +01:00
|
|
|
fi
|
|
|
|
|
2012-10-17 14:02:09 +01:00
|
|
|
# Root permissions are required to run this script
|
|
|
|
if [ $(whoami) != "root" ] ; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Salt requires root privileges to install. Please re-run this script as root."
|
2012-09-06 23:17:02 +10:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-01-27 19:12:27 +00:00
|
|
|
CALLER=$(echo `ps -a -o pid,args | grep $$ | grep -v grep | tr -s ' '` | cut -d ' ' -f 2)
|
2013-01-25 20:18:08 +00:00
|
|
|
if [ "${CALLER}x" = "${0}x" ]; then
|
2013-01-25 20:29:53 +00:00
|
|
|
CALLER="PIPED THROUGH"
|
2013-01-25 20:18:08 +00:00
|
|
|
fi
|
2013-02-11 19:17:21 +00:00
|
|
|
echoinfo "${CALLER} ${0} -- Version ${ScriptVersion}"
|
2013-02-24 09:06:24 +00:00
|
|
|
echowarn "Running the unstable version of ${ScriptName}"
|
|
|
|
|
|
|
|
|
2012-10-23 04:16:03 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __exit_cleanup
|
|
|
|
# DESCRIPTION: Cleanup any leftovers after script has ended
|
2013-01-21 14:25:28 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# http://www.unix.com/man-page/POSIX/1posix/trap/
|
|
|
|
#
|
|
|
|
# Signal Number Signal Name
|
|
|
|
# 1 SIGHUP
|
|
|
|
# 2 SIGINT
|
|
|
|
# 3 SIGQUIT
|
|
|
|
# 6 SIGABRT
|
|
|
|
# 9 SIGKILL
|
|
|
|
# 14 SIGALRM
|
|
|
|
# 15 SIGTERM
|
2012-10-23 04:16:03 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__exit_cleanup() {
|
|
|
|
EXIT_CODE=$?
|
|
|
|
|
|
|
|
# Remove the logging pipe when the script exits
|
2013-02-11 19:17:21 +00:00
|
|
|
echodebug "Removing the logging pipe $LOGPIPE"
|
2012-10-23 04:16:03 +01:00
|
|
|
rm -f $LOGPIPE
|
|
|
|
|
|
|
|
# Kill tee when exiting, CentOS, at least requires this
|
|
|
|
TEE_PID=$(ps ax | grep tee | grep $LOGFILE | awk '{print $1}')
|
2012-11-28 01:02:25 +00:00
|
|
|
|
2012-11-28 01:17:47 +00:00
|
|
|
[ "x$TEE_PID" = "x" ] && exit $EXIT_CODE
|
2012-11-28 01:02:25 +00:00
|
|
|
|
2013-02-11 19:17:21 +00:00
|
|
|
echodebug "Killing logging pipe tee's with pid(s): $TEE_PID"
|
2012-10-23 04:16:03 +01:00
|
|
|
|
|
|
|
# We need to trap errors since killing tee will cause a 127 errno
|
|
|
|
# We also do this as late as possible so we don't "mis-catch" other errors
|
|
|
|
__trap_errors() {
|
2013-02-11 19:17:21 +00:00
|
|
|
echoinfo "Errors Trapped: $EXIT_CODE"
|
2012-10-23 04:16:03 +01:00
|
|
|
# Exit with the "original" exit code, not the trapped code
|
|
|
|
exit $EXIT_CODE
|
|
|
|
}
|
2013-01-21 16:21:41 +00:00
|
|
|
trap "__trap_errors" INT QUIT ABRT KILL QUIT TERM
|
2012-10-23 04:16:03 +01:00
|
|
|
|
|
|
|
# Now we're "good" to kill tee
|
2013-01-21 16:20:19 +00:00
|
|
|
kill -s TERM $TEE_PID
|
2012-10-23 04:16:03 +01:00
|
|
|
|
|
|
|
# In case the 127 errno is not triggered, exit with the "original" exit code
|
|
|
|
exit $EXIT_CODE
|
|
|
|
}
|
2013-01-21 14:25:28 +00:00
|
|
|
trap "__exit_cleanup" EXIT INT
|
2012-10-23 04:16:03 +01:00
|
|
|
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2012-11-28 01:02:25 +00:00
|
|
|
# Define our logging file and pipe paths
|
2012-11-29 01:44:45 +00:00
|
|
|
LOGFILE="/tmp/$( echo $ScriptName | sed s/.sh/.log/g )"
|
|
|
|
LOGPIPE="/tmp/$( echo $ScriptName | sed s/.sh/.logpipe/g )"
|
2012-11-28 01:02:25 +00:00
|
|
|
|
|
|
|
# Create our logging pipe
|
2012-11-28 01:17:47 +00:00
|
|
|
# On FreeBSD we have to use mkfifo instead of mknod
|
2012-11-28 01:02:25 +00:00
|
|
|
mknod $LOGPIPE p >/dev/null 2>&1 || mkfifo $LOGPIPE >/dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Failed to create the named pipe required to log"
|
2012-11-28 01:02:25 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# What ever is written to the logpipe gets written to the logfile
|
|
|
|
tee < $LOGPIPE $LOGFILE &
|
|
|
|
|
|
|
|
# Close STDOUT, reopen it directing it to the logpipe
|
|
|
|
exec 1>&-
|
|
|
|
exec 1>$LOGPIPE
|
|
|
|
# Close STDERR, reopen it directing it to the logpipe
|
|
|
|
exec 2>&-
|
|
|
|
exec 2>$LOGPIPE
|
|
|
|
|
|
|
|
|
2012-10-21 16:04:57 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __gather_hardware_info
|
|
|
|
# DESCRIPTION: Discover hardware information
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__gather_hardware_info() {
|
2012-11-28 01:21:44 +00:00
|
|
|
if [ -f /proc/cpuinfo ]; then
|
2012-12-11 15:28:50 +00:00
|
|
|
CPU_VENDOR_ID=$(cat /proc/cpuinfo | grep -E 'vendor_id|Processor' | head -n 1 | awk '{print $3}' | cut -d '-' -f1 )
|
2013-01-27 19:40:42 +00:00
|
|
|
elif [ -f /usr/bin/kstat ]; then
|
2013-01-27 19:28:14 +00:00
|
|
|
# SmartOS.
|
|
|
|
# Solaris!?
|
|
|
|
# This has only been tested for a GenuineIntel CPU
|
2013-01-27 19:40:42 +00:00
|
|
|
CPU_VENDOR_ID=$(/usr/bin/kstat -p cpu_info:0:cpu_info0:vendor_id | awk '{print $2}')
|
2012-11-28 01:21:44 +00:00
|
|
|
else
|
2012-11-28 03:39:10 +00:00
|
|
|
CPU_VENDOR_ID=$( sysctl -n hw.model )
|
2012-11-28 01:21:44 +00:00
|
|
|
fi
|
2012-10-21 16:04:57 +01:00
|
|
|
CPU_VENDOR_ID_L=$( echo $CPU_VENDOR_ID | tr '[:upper:]' '[:lower:]' )
|
|
|
|
CPU_ARCH=$(uname -m 2>/dev/null || uname -p 2>/dev/null || echo "unknown")
|
|
|
|
CPU_ARCH_L=$( echo $CPU_ARCH | tr '[:upper:]' '[:lower:]' )
|
|
|
|
|
|
|
|
}
|
|
|
|
__gather_hardware_info
|
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __gather_os_info
|
2012-10-18 22:30:20 +01:00
|
|
|
# DESCRIPTION: Discover operating system information
|
2012-10-18 22:18:07 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__gather_os_info() {
|
|
|
|
OS_NAME=$(uname -s 2>/dev/null)
|
|
|
|
OS_NAME_L=$( echo $OS_NAME | tr '[:upper:]' '[:lower:]' )
|
|
|
|
OS_VERSION=$(uname -r)
|
|
|
|
OS_VERSION_L=$( echo $OS_VERSION | tr '[:upper:]' '[:lower:]' )
|
2012-10-17 14:02:09 +01:00
|
|
|
}
|
2012-10-18 22:18:07 +01:00
|
|
|
__gather_os_info
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2012-09-06 23:17:02 +10:00
|
|
|
|
2012-10-24 01:32:48 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __parse_version_string
|
|
|
|
# DESCRIPTION: Parse version strings ignoring the revision.
|
|
|
|
# MAJOR.MINOR.REVISION becomes MAJOR.MINOR
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__parse_version_string() {
|
|
|
|
VERSION_STRING="$1"
|
|
|
|
PARSED_VERSION=$(
|
|
|
|
echo $VERSION_STRING |
|
|
|
|
sed -e 's/^/#/' \
|
|
|
|
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\)\(\.[0-9][0-9]*\).*$/\1/' \
|
|
|
|
-e 's/^#[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' \
|
|
|
|
-e 's/^#[^0-9]*\([0-9][0-9]*\).*$/\1/' \
|
|
|
|
-e 's/^#.*$//'
|
|
|
|
)
|
|
|
|
echo $PARSED_VERSION
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-23 02:49:14 +00:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __unquote_string
|
|
|
|
# DESCRIPTION: Strip single or double quotes from the provided string.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__unquote_string() {
|
|
|
|
echo $@ | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"
|
|
|
|
}
|
|
|
|
|
2013-02-23 18:30:51 +00:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __camelcase_split
|
|
|
|
# DESCRIPTION: Convert CamelCased strings to Camel_Cased
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__camelcase_split() {
|
|
|
|
echo $@ | sed -r 's/([^A-Z-])([A-Z])/\1 \2/g'
|
|
|
|
}
|
|
|
|
|
2013-02-24 07:54:28 +00:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __strip_duplicates
|
|
|
|
# DESCRIPTION: Strip duplicate strings
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__strip_duplicates() {
|
2013-02-26 20:16:48 +00:00
|
|
|
echo $@ | tr -s '[:space:]' '\n' | awk '!x[$0]++'
|
2013-02-24 07:54:28 +00:00
|
|
|
}
|
|
|
|
|
Sort the files gathered from `ls /etc/*[_-]release /etc/*[_-]version`. Fixes #55. Refs #54 and #56.
Since we need a custom sorting order, there's a new function to do that job, `__sort_release_files`. Sorting is first done by knowledge. If we know a release file, it goes to the primary list. If it's unknown it goes to the secondary list.
Afterwards the primary list gets sorted by maximum importance, ie, the CentOS files needs to come before the RedHat files.
Afterwards, the primary list gets sorted again, but this time, by the lowest importance, ie, the lsb-release file should come last(it's handled separately).
Finally, the function returns the primary list following the secondary list, and that will be the order for which we try to detect the distributions.
2013-02-22 01:46:55 +00:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __sort_release_files
|
|
|
|
# DESCRIPTION: Custom sort function. Alphabetical or numerical sort is not
|
|
|
|
# enough.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__sort_release_files() {
|
2013-02-22 03:57:44 +00:00
|
|
|
KNOWN_RELEASE_FILES=$(echo "(arch|centos|debian|ubuntu|fedora|redhat|suse|\
|
2013-02-23 02:49:14 +00:00
|
|
|
mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|lsb|system|\
|
|
|
|
os)(-|_)(release|version)" | sed -r 's:[[:space:]]::g')
|
Sort the files gathered from `ls /etc/*[_-]release /etc/*[_-]version`. Fixes #55. Refs #54 and #56.
Since we need a custom sorting order, there's a new function to do that job, `__sort_release_files`. Sorting is first done by knowledge. If we know a release file, it goes to the primary list. If it's unknown it goes to the secondary list.
Afterwards the primary list gets sorted by maximum importance, ie, the CentOS files needs to come before the RedHat files.
Afterwards, the primary list gets sorted again, but this time, by the lowest importance, ie, the lsb-release file should come last(it's handled separately).
Finally, the function returns the primary list following the secondary list, and that will be the order for which we try to detect the distributions.
2013-02-22 01:46:55 +00:00
|
|
|
primary_release_files=""
|
|
|
|
secondary_release_files=""
|
|
|
|
# Sort know VS un-known files first
|
|
|
|
for release_file in $(echo $@ | sed -r 's:[[:space:]]:\n:g' | sort --unique --ignore-case); do
|
|
|
|
match=$(echo $release_file | egrep -i ${KNOWN_RELEASE_FILES})
|
|
|
|
if [ "x${match}" != "x" ]; then
|
|
|
|
primary_release_files="${primary_release_files} ${release_file}"
|
|
|
|
else
|
|
|
|
secondary_release_files="${secondary_release_files} ${release_file}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Now let's sort by know files importance, max important goes last in the max_prio list
|
|
|
|
max_prio="redhat-release centos-release"
|
|
|
|
for entry in $max_prio; do
|
|
|
|
if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then
|
|
|
|
primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\2 \1 \3:g")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# Now, least important goes last in the min_prio list
|
|
|
|
min_prio="lsb-release"
|
|
|
|
for entry in $max_prio; do
|
|
|
|
if [ "x$(echo ${primary_release_files} | grep $entry)" != "x" ]; then
|
|
|
|
primary_release_files=$(echo ${primary_release_files} | sed -e "s:\(.*\)\($entry\)\(.*\):\1 \3 \2:g")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Echo the results collapsing multiple white-space into a single white-space
|
|
|
|
echo "${primary_release_files} ${secondary_release_files}" | sed -r 's:[[:space:]]:\n:g'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __gather_linux_system_info
|
2012-10-18 22:30:20 +01:00
|
|
|
# DESCRIPTION: Discover Linux system information
|
2012-10-18 22:18:07 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__gather_linux_system_info() {
|
2012-10-19 12:07:14 +01:00
|
|
|
DISTRO_NAME=""
|
|
|
|
DISTRO_VERSION=""
|
|
|
|
|
2013-02-20 12:39:35 +00:00
|
|
|
# Let's test if the lsb_release binary is available
|
2013-02-20 12:46:02 +00:00
|
|
|
rv=$(lsb_release >/dev/null 2>&1)
|
|
|
|
if [ $? -eq 0 ]; then
|
2013-02-20 12:39:35 +00:00
|
|
|
DISTRO_NAME=$(lsb_release -si)
|
2013-02-23 18:30:51 +00:00
|
|
|
if [ "x$(echo "$DISTRO_NAME" | grep RedHat)" != "x" ]; then
|
|
|
|
# Let's convert CamelCase to Camel Case
|
|
|
|
DISTRO_NAME=$(__camelcase_split "$DISTRO_NAME")
|
|
|
|
fi
|
2013-02-20 12:39:35 +00:00
|
|
|
rv=$(lsb_release -sr)
|
|
|
|
[ "${rv}x" != "x" ] && DISTRO_VERSION=$(__parse_version_string "$rv")
|
|
|
|
elif [ -f /etc/lsb-release ]; then
|
Sort the files gathered from `ls /etc/*[_-]release /etc/*[_-]version`. Fixes #55. Refs #54 and #56.
Since we need a custom sorting order, there's a new function to do that job, `__sort_release_files`. Sorting is first done by knowledge. If we know a release file, it goes to the primary list. If it's unknown it goes to the secondary list.
Afterwards the primary list gets sorted by maximum importance, ie, the CentOS files needs to come before the RedHat files.
Afterwards, the primary list gets sorted again, but this time, by the lowest importance, ie, the lsb-release file should come last(it's handled separately).
Finally, the function returns the primary list following the secondary list, and that will be the order for which we try to detect the distributions.
2013-02-22 01:46:55 +00:00
|
|
|
# We don't have the lsb_release binary, though, we do have the file it parses
|
2012-10-19 12:07:14 +01:00
|
|
|
DISTRO_NAME=$(grep DISTRIB_ID /etc/lsb-release | sed -e 's/.*=//')
|
2013-02-16 10:17:46 +00:00
|
|
|
rv=$(grep DISTRIB_RELEASE /etc/lsb-release | sed -e 's/.*=//')
|
|
|
|
[ "${rv}x" != "x" ] && DISTRO_VERSION=$(__parse_version_string "$rv")
|
2012-10-19 12:07:14 +01:00
|
|
|
fi
|
|
|
|
|
2013-01-21 17:14:41 +00:00
|
|
|
if [ "x$DISTRO_NAME" != "x" ] && [ "x$DISTRO_VERSION" != "x" ]; then
|
2012-10-19 12:07:14 +01:00
|
|
|
# We already have the distribution name and version
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
Sort the files gathered from `ls /etc/*[_-]release /etc/*[_-]version`. Fixes #55. Refs #54 and #56.
Since we need a custom sorting order, there's a new function to do that job, `__sort_release_files`. Sorting is first done by knowledge. If we know a release file, it goes to the primary list. If it's unknown it goes to the secondary list.
Afterwards the primary list gets sorted by maximum importance, ie, the CentOS files needs to come before the RedHat files.
Afterwards, the primary list gets sorted again, but this time, by the lowest importance, ie, the lsb-release file should come last(it's handled separately).
Finally, the function returns the primary list following the secondary list, and that will be the order for which we try to detect the distributions.
2013-02-22 01:46:55 +00:00
|
|
|
for rsource in $(__sort_release_files $(
|
2012-10-18 22:27:38 +01:00
|
|
|
cd /etc && /bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \
|
|
|
|
sed -e '/^redhat-release$/d' -e '/^lsb-release$/d'; \
|
|
|
|
echo redhat-release lsb-release
|
Sort the files gathered from `ls /etc/*[_-]release /etc/*[_-]version`. Fixes #55. Refs #54 and #56.
Since we need a custom sorting order, there's a new function to do that job, `__sort_release_files`. Sorting is first done by knowledge. If we know a release file, it goes to the primary list. If it's unknown it goes to the secondary list.
Afterwards the primary list gets sorted by maximum importance, ie, the CentOS files needs to come before the RedHat files.
Afterwards, the primary list gets sorted again, but this time, by the lowest importance, ie, the lsb-release file should come last(it's handled separately).
Finally, the function returns the primary list following the secondary list, and that will be the order for which we try to detect the distributions.
2013-02-22 01:46:55 +00:00
|
|
|
)); do
|
2012-10-18 22:27:38 +01:00
|
|
|
|
2012-11-27 19:08:20 +00:00
|
|
|
[ -L "/etc/${rsource}" ] && continue # Don't follow symlinks
|
|
|
|
[ ! -f "/etc/${rsource}" ] && continue # Does not exist
|
2012-10-18 23:54:58 +01:00
|
|
|
|
2012-10-18 22:27:38 +01:00
|
|
|
n=$(echo ${rsource} | sed -e 's/[_-]release$//' -e 's/[_-]version$//')
|
2013-02-20 22:14:22 +00:00
|
|
|
rv=$( (grep VERSION /etc/${rsource}; cat /etc/${rsource}) | grep '[0-9]' | sed -e 'q' )
|
2013-02-16 10:17:46 +00:00
|
|
|
[ "${rv}x" = "x" ] && continue # There's no version information. Continue to next rsource
|
|
|
|
v=$(__parse_version_string "$rv")
|
2012-10-18 22:27:38 +01:00
|
|
|
case $(echo ${n} | tr '[:upper:]' '[:lower:]') in
|
2013-02-23 02:49:14 +00:00
|
|
|
redhat )
|
2013-02-12 22:36:05 +00:00
|
|
|
if [ ".$(egrep 'CentOS' /etc/${rsource})" != . ]; then
|
|
|
|
n="CentOS"
|
|
|
|
elif [ ".$(egrep 'Red Hat Enterprise Linux' /etc/${rsource})" != . ]; then
|
2012-10-18 22:27:38 +01:00
|
|
|
n="<R>ed <H>at <E>nterprise <L>inux"
|
|
|
|
else
|
|
|
|
n="<R>ed <H>at <L>inux"
|
|
|
|
fi
|
|
|
|
;;
|
2013-02-23 02:49:14 +00:00
|
|
|
arch ) n="Arch Linux" ;;
|
2012-10-18 22:27:38 +01:00
|
|
|
centos ) n="CentOS" ;;
|
|
|
|
debian ) n="Debian" ;;
|
|
|
|
ubuntu ) n="Ubuntu" ;;
|
|
|
|
fedora ) n="Fedora" ;;
|
|
|
|
suse ) n="SUSE" ;;
|
|
|
|
mandrake*|mandriva ) n="Mandriva" ;;
|
|
|
|
gentoo ) n="Gentoo" ;;
|
|
|
|
slackware ) n="Slackware" ;;
|
|
|
|
turbolinux ) n="TurboLinux" ;;
|
|
|
|
unitedlinux ) n="UnitedLinux" ;;
|
2013-01-30 13:06:11 +00:00
|
|
|
system )
|
|
|
|
while read -r line; do
|
|
|
|
[ "${n}x" != "systemx" ] && break
|
|
|
|
case "$line" in
|
|
|
|
*Amazon*Linux*AMI*)
|
|
|
|
n="Amazon Linux AMI"
|
|
|
|
break
|
|
|
|
esac
|
|
|
|
done < /etc/${rsource}
|
|
|
|
;;
|
2013-02-19 21:15:14 +00:00
|
|
|
os )
|
2013-02-23 02:49:14 +00:00
|
|
|
n=$(__unquote_string $(grep '^NAME=' /etc/os-release | sed -e 's/^NAME=\(.*\)$/\1/g'))
|
2013-02-23 02:55:52 +00:00
|
|
|
[ "${n}" = "Arch Linux" ] && v="" # Arch Linux does not provide a version.
|
2013-02-19 21:15:14 +00:00
|
|
|
;;
|
2012-10-18 22:27:38 +01:00
|
|
|
* ) n="${n}" ;
|
|
|
|
esac
|
|
|
|
DISTRO_NAME=$n
|
|
|
|
DISTRO_VERSION=$v
|
|
|
|
break
|
2012-10-18 22:18:07 +01:00
|
|
|
done
|
|
|
|
}
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
|
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __gather_sunos_system_info
|
|
|
|
# DESCRIPTION: Discover SunOS system info
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__gather_sunos_system_info() {
|
2013-01-27 22:54:21 +00:00
|
|
|
if [ -f /sbin/uname ]; then
|
|
|
|
DISTRO_VERSION=$(/sbin/uname -X | grep -i kernelid | awk '{ print $3}')
|
|
|
|
fi
|
|
|
|
|
|
|
|
DISTRO_NAME=""
|
|
|
|
if [ -f /etc/release ]; then
|
|
|
|
while read -r line; do
|
|
|
|
[ "${DISTRO_NAME}x" != "x" ] && break
|
|
|
|
case "$line" in
|
|
|
|
*OpenIndiana*oi_[0-9]*)
|
|
|
|
DISTRO_NAME="OpenIndiana"
|
|
|
|
DISTRO_VERSION=$(echo "$line" | sed -nr "s/OpenIndiana(.*)oi_([[:digit:]]+)(.*)/\2/p")
|
2013-01-27 23:05:19 +00:00
|
|
|
break
|
2013-01-27 22:54:21 +00:00
|
|
|
;;
|
|
|
|
*OpenSolaris*snv_[0-9]*)
|
|
|
|
DISTRO_NAME="OpenSolaris"
|
|
|
|
DISTRO_VERSION=$(echo "$line" | sed -nr "s/OpenSolaris(.*)snv_([[:digit:]]+)(.*)/\2/p")
|
2013-01-27 23:05:19 +00:00
|
|
|
break
|
2013-01-27 22:54:21 +00:00
|
|
|
;;
|
|
|
|
*Oracle*Solaris*[0-9]*)
|
|
|
|
DISTRO_NAME="Oracle Solaris"
|
|
|
|
DISTRO_VERSION=$(echo "$line" | sed -nr "s/(Oracle Solaris) ([[:digit:]]+)(.*)/\2/p")
|
2013-01-27 23:05:19 +00:00
|
|
|
break
|
2013-01-27 22:54:21 +00:00
|
|
|
;;
|
|
|
|
*Solaris*)
|
|
|
|
DISTRO_NAME="Solaris"
|
2013-01-27 23:05:19 +00:00
|
|
|
break
|
2013-01-27 22:54:21 +00:00
|
|
|
;;
|
|
|
|
*NexentaCore*)
|
2013-01-27 23:05:19 +00:00
|
|
|
DISTRO_NAME="Nexenta Core"
|
|
|
|
break
|
2013-01-27 22:54:21 +00:00
|
|
|
;;
|
|
|
|
*SmartOS*)
|
2013-01-27 23:05:19 +00:00
|
|
|
DISTRO_NAME="SmartOS"
|
|
|
|
break
|
2013-01-27 22:54:21 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < /etc/release
|
2013-01-27 22:55:45 +00:00
|
|
|
fi
|
2013-01-27 22:54:21 +00:00
|
|
|
|
|
|
|
if [ "${DISTRO_NAME}x" = "x" ]; then
|
|
|
|
DISTRO_NAME="Solaris"
|
|
|
|
DISTRO_VERSION=$(
|
|
|
|
echo "${OS_VERSION}" |
|
|
|
|
sed -e 's;^4\.;1.;' \
|
|
|
|
-e 's;^5\.\([0-6]\)[^0-9]*$;2.\1;' \
|
|
|
|
-e 's;^5\.\([0-9][0-9]*\).*;\1;'
|
|
|
|
)
|
|
|
|
fi
|
2012-10-17 14:02:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __gather_bsd_system_info
|
2012-10-18 22:30:20 +01:00
|
|
|
# DESCRIPTION: Discover OpenBSD, NetBSD and FreeBSD systems information
|
2012-10-18 22:18:07 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__gather_bsd_system_info() {
|
|
|
|
DISTRO_NAME=${OS_NAME}
|
2012-11-28 01:53:15 +00:00
|
|
|
DISTRO_VERSION=$(echo "${OS_VERSION}" | sed -e 's;[()];;' -e 's/-.*$//')
|
2012-10-18 22:18:07 +01:00
|
|
|
}
|
2012-10-17 14:02:09 +01:00
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __gather_system_info
|
2012-10-18 22:30:20 +01:00
|
|
|
# DESCRIPTION: Discover which system and distribution we are running.
|
2012-10-18 22:18:07 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__gather_system_info() {
|
|
|
|
case ${OS_NAME_L} in
|
|
|
|
linux )
|
|
|
|
__gather_linux_system_info
|
|
|
|
;;
|
|
|
|
sunos )
|
|
|
|
__gather_sunos_system_info
|
|
|
|
;;
|
|
|
|
openbsd|freebsd|netbsd )
|
|
|
|
__gather_bsd_system_info
|
|
|
|
;;
|
|
|
|
* )
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "${OS_NAME} not supported.";
|
2012-10-18 22:18:07 +01:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
}
|
2013-01-18 01:19:18 +00:00
|
|
|
__gather_system_info
|
|
|
|
|
|
|
|
|
2013-02-11 20:22:33 +00:00
|
|
|
echo
|
2013-02-11 19:17:21 +00:00
|
|
|
echoinfo "System Information:"
|
|
|
|
echoinfo " CPU: ${CPU_VENDOR_ID}"
|
|
|
|
echoinfo " CPU Arch: ${CPU_ARCH}"
|
|
|
|
echoinfo " OS Name: ${OS_NAME}"
|
|
|
|
echoinfo " OS Version: ${OS_VERSION}"
|
|
|
|
echoinfo " Distribution: ${DISTRO_NAME} ${DISTRO_VERSION}"
|
2013-01-26 18:05:54 +00:00
|
|
|
echo
|
|
|
|
|
2013-02-11 21:58:59 +00:00
|
|
|
# Let users know what's going to be installed/configured
|
|
|
|
if [ $INSTALL_MINION -eq $BS_TRUE ]; then
|
|
|
|
if [ $CONFIG_ONLY -eq $BS_FALSE ]; then
|
|
|
|
echoinfo "Installing minion"
|
|
|
|
else
|
|
|
|
echoinfo "Configuring minion"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $INSTALL_MASTER -eq $BS_TRUE ]; then
|
|
|
|
if [ $CONFIG_ONLY -eq $BS_FALSE ]; then
|
|
|
|
echoinfo "Installing master"
|
|
|
|
else
|
|
|
|
echoinfo "Configuring master"
|
|
|
|
fi
|
|
|
|
fi
|
2013-01-18 01:19:18 +00:00
|
|
|
|
2013-02-11 21:58:59 +00:00
|
|
|
if [ $INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
|
|
|
if [ $CONFIG_ONLY -eq $BS_FALSE ]; then
|
|
|
|
echoinfo "Installing syndic"
|
|
|
|
else
|
|
|
|
echoinfo "Configuring syndic"
|
|
|
|
fi
|
|
|
|
fi
|
2013-01-18 01:19:18 +00:00
|
|
|
|
|
|
|
# Simplify version naming on functions
|
|
|
|
if [ "x${DISTRO_VERSION}" = "x" ]; then
|
2013-01-31 11:21:00 -08:00
|
|
|
DISTRO_MAJOR_VERSION=""
|
2013-02-12 21:12:57 +00:00
|
|
|
DISTRO_MINOR_VERSION=""
|
|
|
|
PREFIXED_DISTRO_MAJOR_VERSION=""
|
|
|
|
PREFIXED_DISTRO_MINOR_VERSION=""
|
2013-01-18 01:19:18 +00:00
|
|
|
else
|
2013-01-31 11:21:00 -08:00
|
|
|
DISTRO_MAJOR_VERSION="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).*/\1/g')"
|
2013-02-16 09:57:46 +00:00
|
|
|
DISTRO_MINOR_VERSION="$(echo $DISTRO_VERSION | sed 's/^\([0-9]*\).\([0-9]*\).*/\2/g')"
|
2013-02-12 21:12:57 +00:00
|
|
|
PREFIXED_DISTRO_MAJOR_VERSION="_${DISTRO_MAJOR_VERSION}"
|
2013-02-16 09:57:46 +00:00
|
|
|
if [ "${PREFIXED_DISTRO_MAJOR_VERSION}" = "_" ]; then
|
|
|
|
PREFIXED_DISTRO_MAJOR_VERSION=""
|
|
|
|
fi
|
2013-02-12 21:12:57 +00:00
|
|
|
PREFIXED_DISTRO_MINOR_VERSION="_${DISTRO_MINOR_VERSION}"
|
2013-02-16 09:57:46 +00:00
|
|
|
if [ "${PREFIXED_DISTRO_MINOR_VERSION}" = "_" ]; then
|
|
|
|
PREFIXED_DISTRO_MINOR_VERSION=""
|
|
|
|
fi
|
2013-01-18 01:19:18 +00:00
|
|
|
fi
|
|
|
|
# Simplify distro name naming on functions
|
2013-02-12 17:52:47 +00:00
|
|
|
DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -re 's/([[:space:]])+/_/g')
|
2013-01-18 01:19:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Only Ubuntu has daily packages, let's let users know about that
|
2013-01-21 17:14:41 +00:00
|
|
|
if [ "${DISTRO_NAME_L}" != "ubuntu" ] && [ $ITYPE = "daily" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Only Ubuntu has daily packages support"
|
2013-01-18 01:19:18 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2012-10-17 14:02:09 +01:00
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __function_defined
|
|
|
|
# DESCRIPTION: Checks if a function is defined within this scripts scope
|
|
|
|
# PARAMETERS: function name
|
|
|
|
# RETURNS: 0 or 1 as in defined or not defined
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__function_defined() {
|
|
|
|
FUNC_NAME=$1
|
2013-01-22 13:52:34 +00:00
|
|
|
if [ "$(command -v $FUNC_NAME)x" != "x" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoinfo "Found function $FUNC_NAME"
|
2013-01-22 13:52:34 +00:00
|
|
|
return 0
|
2012-10-18 22:18:07 +01:00
|
|
|
fi
|
2013-02-11 19:17:21 +00:00
|
|
|
echodebug "$FUNC_NAME not found...."
|
2012-10-18 22:18:07 +01:00
|
|
|
return 1
|
|
|
|
}
|
2013-01-18 01:19:18 +00:00
|
|
|
|
|
|
|
|
2012-10-27 07:31:14 +01:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __git_clone_and_checkout
|
|
|
|
# DESCRIPTION: (DRY) Helper function to clone and checkout salt to a
|
|
|
|
# specific revision.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__git_clone_and_checkout() {
|
|
|
|
SALT_GIT_CHECKOUT_DIR=/tmp/git/salt
|
|
|
|
[ -d /tmp/git ] || mkdir /tmp/git
|
|
|
|
cd /tmp/git
|
|
|
|
[ -d $SALT_GIT_CHECKOUT_DIR ] || git clone git://github.com/saltstack/salt.git salt
|
|
|
|
cd salt
|
|
|
|
git checkout $GIT_REV
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-31 19:10:54 -07:00
|
|
|
#--- FUNCTION ----------------------------------------------------------------
|
|
|
|
# NAME: __apt_get_noinput
|
|
|
|
# DESCRIPTION: (DRY) apt-get install with noinput options
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
__apt_get_noinput() {
|
2013-01-25 20:18:08 +00:00
|
|
|
apt-get install -y -o DPkg::Options::=--force-confold $@; return $?
|
2012-10-31 19:10:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
|
|
|
# Distribution install functions
|
|
|
|
#
|
|
|
|
# In order to install salt for a distribution you need to define:
|
|
|
|
#
|
|
|
|
# To Install Dependencies, which is required, one of:
|
2013-02-12 21:12:57 +00:00
|
|
|
# 1. install_<distro>_<major_version>_<install_type>_deps
|
|
|
|
# 2. install_<distro>_<major_version>_<minor_version>_<install_type>_deps
|
|
|
|
# 3. install_<distro>_<major_version>_deps
|
|
|
|
# 4 install_<distro>_<major_version>_<minor_version>_deps
|
|
|
|
# 5. install_<distro>_<install_type>_deps
|
|
|
|
# 6. install_<distro>_deps
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
2013-01-25 00:03:27 +00:00
|
|
|
# Optionally, define a salt configuration function, which will be called if
|
2012-11-28 04:35:22 +00:00
|
|
|
# the -c|config-dir option is passed. One of:
|
2013-02-12 21:12:57 +00:00
|
|
|
# 1. config_<distro>_<major_version>_<install_type>_salt
|
|
|
|
# 2. config_<distro>_<major_version>_<minor_version>_<install_type>_salt
|
|
|
|
# 3. config_<distro>_<major_version>_salt
|
|
|
|
# 4 config_<distro>_<major_version>_<minor_version>_salt
|
|
|
|
# 5. config_<distro>_<install_type>_salt
|
|
|
|
# 6. config_<distro>_salt
|
|
|
|
# 7. config_salt [THIS ONE IS ALREADY DEFINED AS THE DEFAULT]
|
2012-10-18 17:28:00 +01:00
|
|
|
#
|
2013-01-10 13:13:55 -08:00
|
|
|
# To install salt, which, of course, is required, one of:
|
2013-02-12 21:12:57 +00:00
|
|
|
# 1. install_<distro>_<major_version>_<install_type>
|
|
|
|
# 2. install_<distro>_<major_version>_<minor_version>_<install_type>
|
|
|
|
# 3. install_<distro>_<install_type>
|
2013-01-10 13:13:55 -08:00
|
|
|
#
|
2013-02-08 11:39:27 +00:00
|
|
|
# Optionally, define a post install function, one of:
|
2013-02-12 21:12:57 +00:00
|
|
|
# 1. install_<distro>_<major_version>_<install_type>_post
|
|
|
|
# 2. install_<distro>_<major_version>_<minor_version>_<install_type>_post
|
|
|
|
# 3. install_<distro>_<major_version>_post
|
|
|
|
# 4 install_<distro>_<major_version>_<minor_version>_post
|
|
|
|
# 5. install_<distro>_<install_type>_post
|
|
|
|
# 6. install_<distro>_post
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
2013-02-08 11:39:27 +00:00
|
|
|
# Optionally, define a start daemons function, one of:
|
2013-02-16 10:04:25 +00:00
|
|
|
# 1. install_<distro>_<major_version>_<install_type>_restart_daemons
|
|
|
|
# 2. install_<distro>_<major_version>_<minor_version>_<install_type>_restart_daemons
|
|
|
|
# 3. install_<distro>_<major_version>_restart_daemons
|
|
|
|
# 4 install_<distro>_<major_version>_<minor_version>_restart_daemons
|
|
|
|
# 5. install_<distro>_<install_type>_restart_daemons
|
|
|
|
# 6. install_<distro>_restart_daemons
|
2013-02-08 11:39:27 +00:00
|
|
|
#
|
2013-02-11 22:30:56 +00:00
|
|
|
# NOTE: The start daemons function should be able to restart any daemons
|
|
|
|
# which are running, or start if they're not running.
|
|
|
|
#
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2013-02-19 21:30:12 +00:00
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
|
|
|
# Ubuntu Install Functions
|
|
|
|
#
|
|
|
|
install_ubuntu_deps() {
|
|
|
|
apt-get update
|
2013-02-12 21:12:57 +00:00
|
|
|
if [ $DISTRO_MAJOR_VERSION -gt 12 ] && [ $DISTRO_MINOR_VERSION -gt 04 ]; then
|
2013-01-24 19:43:34 +00:00
|
|
|
# Above Ubuntu 12.04 add-apt-repository is in a different package
|
|
|
|
__apt_get_noinput software-properties-common
|
|
|
|
else
|
|
|
|
__apt_get_noinput python-software-properties
|
|
|
|
fi
|
2013-02-12 21:12:57 +00:00
|
|
|
if [ $DISTRO_MAJOR_VERSION -lt 11 ] && [ $DISTRO_MINOR_VERSION -lt 10 ]; then
|
2013-01-24 19:57:03 +00:00
|
|
|
add-apt-repository ppa:saltstack/salt
|
|
|
|
else
|
|
|
|
add-apt-repository -y ppa:saltstack/salt
|
2013-01-18 02:42:49 +00:00
|
|
|
fi
|
2013-01-24 19:57:03 +00:00
|
|
|
apt-get update
|
2012-10-31 17:06:02 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 21:12:57 +00:00
|
|
|
install_ubuntu_11_10_deps() {
|
2012-10-17 14:02:09 +01:00
|
|
|
apt-get update
|
2012-10-31 19:10:54 -07:00
|
|
|
__apt_get_noinput python-software-properties
|
2012-10-17 14:02:09 +01:00
|
|
|
add-apt-repository -y 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
|
|
|
|
add-apt-repository -y ppa:saltstack/salt
|
2012-10-19 11:08:37 -07:00
|
|
|
apt-get update
|
|
|
|
}
|
|
|
|
|
2012-10-19 21:16:00 -07:00
|
|
|
install_ubuntu_git_deps() {
|
2013-01-24 19:57:03 +00:00
|
|
|
install_ubuntu_deps
|
2012-10-31 19:10:54 -07:00
|
|
|
__apt_get_noinput git-core python-yaml python-m2crypto python-crypto msgpack-python python-zmq python-jinja2
|
2013-01-18 02:42:49 +00:00
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
|
2013-01-25 01:20:33 +00:00
|
|
|
# Let's trigger config_salt()
|
2013-01-18 02:42:49 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
2013-01-18 02:42:49 +00:00
|
|
|
fi
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-12 21:12:57 +00:00
|
|
|
install_ubuntu_11_10_post() {
|
2012-10-17 14:02:09 +01:00
|
|
|
add-apt-repository -y --remove 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
|
|
|
|
}
|
|
|
|
|
|
|
|
install_ubuntu_stable() {
|
2013-01-25 20:18:08 +00:00
|
|
|
packages=""
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MINION -eq $BS_TRUE ]; then
|
2013-01-25 20:18:08 +00:00
|
|
|
packages="${packages} salt-minion"
|
|
|
|
fi
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MASTER -eq $BS_TRUE ]; then
|
2013-01-25 20:18:08 +00:00
|
|
|
packages="${packages} salt-master"
|
|
|
|
fi
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
2013-01-25 20:18:08 +00:00
|
|
|
packages="${packages} salt-syndic"
|
|
|
|
fi
|
2013-01-25 23:41:57 +00:00
|
|
|
__apt_get_noinput ${packages}
|
2012-10-17 14:02:09 +01:00
|
|
|
}
|
2012-10-19 11:08:37 -07:00
|
|
|
|
|
|
|
install_ubuntu_daily() {
|
2013-01-25 02:16:41 +00:00
|
|
|
install_ubuntu_stable
|
2012-10-19 11:08:37 -07:00
|
|
|
}
|
2012-10-19 21:16:00 -07:00
|
|
|
|
|
|
|
install_ubuntu_git() {
|
|
|
|
python setup.py install --install-layout=deb
|
|
|
|
}
|
|
|
|
|
|
|
|
install_ubuntu_git_post() {
|
2013-01-21 11:42:47 +00:00
|
|
|
for fname in minion master syndic; do
|
2013-01-25 23:41:57 +00:00
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-25 23:41:57 +00:00
|
|
|
|
2013-01-26 18:22:26 +00:00
|
|
|
if [ -f /sbin/initctl ]; then
|
2013-01-25 20:18:08 +00:00
|
|
|
# We have upstart support
|
2013-01-26 18:22:26 +00:00
|
|
|
/sbin/initctl status salt-$fname > /dev/null 2>&1
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
# upstart does not know about our service, let's copy the proper file
|
2013-01-25 20:18:08 +00:00
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/salt-$fname.upstart /etc/init/salt-$fname.conf
|
|
|
|
fi
|
2013-02-08 11:56:03 +00:00
|
|
|
# No upstart support in Ubuntu!?
|
|
|
|
elif [ -f ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init ]; then
|
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init /etc/init.d/salt-$fname
|
|
|
|
chmod +x /etc/init.d/salt-$fname
|
|
|
|
update-rc.d salt-$fname defaults
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_ubuntu_restart_daemons() {
|
2013-02-08 11:56:03 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-26 18:22:26 +00:00
|
|
|
|
2013-02-08 11:56:03 +00:00
|
|
|
if [ -f /sbin/initctl ]; then
|
|
|
|
# We have upstart support
|
2013-01-26 18:22:26 +00:00
|
|
|
/sbin/initctl status salt-$fname > /dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
2013-02-13 12:15:56 +00:00
|
|
|
# upstart knows about this service, let's stop and start it.
|
|
|
|
# We could restart but earlier versions of the upstart script
|
|
|
|
# did not support restart, so, it's safer this way
|
|
|
|
/sbin/initctl stop salt-$fname > /dev/null 2>&1
|
2013-01-26 18:22:26 +00:00
|
|
|
/sbin/initctl start salt-$fname > /dev/null 2>&1
|
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
# We failed to start the service, let's test the SysV code bellow
|
2013-01-25 20:18:08 +00:00
|
|
|
fi
|
2012-11-26 02:01:14 +00:00
|
|
|
fi
|
2013-02-13 12:15:56 +00:00
|
|
|
/etc/init.d/salt-$fname stop > /dev/null 2>&1
|
|
|
|
/etc/init.d/salt-$fname start &
|
2012-10-27 04:51:54 +01:00
|
|
|
done
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
|
|
|
# End of Ubuntu Install Functions
|
|
|
|
#
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
|
|
|
# Debian Install Functions
|
|
|
|
#
|
2012-11-11 10:12:12 -08:00
|
|
|
install_debian_deps() {
|
|
|
|
apt-get update
|
|
|
|
}
|
|
|
|
|
2013-02-12 21:12:57 +00:00
|
|
|
install_debian_6_0_deps() {
|
2013-02-22 18:51:49 +00:00
|
|
|
if [ "x$(grep -R 'backports.debian.org' /etc/apt)" = "x" ]; then
|
2013-02-22 17:52:17 +00:00
|
|
|
echo "deb http://backports.debian.org/debian-backports squeeze-backports main" >> \
|
|
|
|
/etc/apt/sources.list.d/backports.list
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f /etc/apt/preferences.d/local-salt-backport.pref ]; then
|
|
|
|
# Add madduck's repo since squeeze packages have been deprecated
|
|
|
|
for fname in salt-common salt-master salt-minion salt-syndic salt-doc; do
|
|
|
|
echo "Package: $fname"
|
|
|
|
echo "Pin: release a=squeeze-backports"
|
|
|
|
echo "Pin-Priority: 600"
|
|
|
|
echo
|
|
|
|
done > /etc/apt/preferences.d/local-salt-backport.pref
|
2012-12-20 09:40:27 -08:00
|
|
|
|
2013-02-22 17:52:17 +00:00
|
|
|
cat <<_eof > /etc/apt/sources.list.d/local-madduck-backports.list
|
2012-12-20 09:40:27 -08:00
|
|
|
deb http://debian.madduck.net/repo squeeze-backports main
|
|
|
|
deb-src http://debian.madduck.net/repo squeeze-backports main
|
|
|
|
_eof
|
|
|
|
|
2013-02-22 18:47:42 +00:00
|
|
|
wget -q http://debian.madduck.net/repo/gpg/archive.key -O - | apt-key add -
|
2013-02-22 17:52:17 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-17 14:02:09 +01:00
|
|
|
apt-get update
|
|
|
|
}
|
|
|
|
|
2012-12-11 16:31:54 +00:00
|
|
|
install_debian_git_deps() {
|
|
|
|
apt-get update
|
|
|
|
__apt_get_noinput lsb-release python python-pkg-resources python-crypto \
|
2012-12-20 09:58:17 -08:00
|
|
|
python-jinja2 python-m2crypto python-yaml msgpack-python git python-zmq
|
2012-12-11 16:31:54 +00:00
|
|
|
|
2013-01-18 02:42:49 +00:00
|
|
|
__git_clone_and_checkout
|
|
|
|
|
2013-01-25 01:20:33 +00:00
|
|
|
# Let's trigger config_salt()
|
2012-12-11 16:31:54 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
2012-12-11 16:31:54 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-02-12 21:12:57 +00:00
|
|
|
install_debian_6_0_git_deps() {
|
|
|
|
install_debian_6_0_deps # Add backports
|
2013-02-13 12:19:08 +00:00
|
|
|
install_debian_git_deps # Grab the actual deps
|
2012-10-18 19:54:05 -07:00
|
|
|
}
|
|
|
|
|
2013-01-25 02:16:41 +00:00
|
|
|
install_debian_stable() {
|
2013-01-25 20:18:08 +00:00
|
|
|
packages=""
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MINION -eq $BS_TRUE ]; then
|
2013-01-25 20:18:08 +00:00
|
|
|
packages="${packages} salt-minion"
|
|
|
|
fi
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MASTER -eq $BS_TRUE ]; then
|
2013-01-25 20:18:08 +00:00
|
|
|
packages="${packages} salt-master"
|
|
|
|
fi
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
2013-01-25 20:18:08 +00:00
|
|
|
packages="${packages} salt-syndic"
|
|
|
|
fi
|
2013-01-25 23:41:57 +00:00
|
|
|
__apt_get_noinput ${packages}
|
2013-01-25 02:16:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-12 21:12:57 +00:00
|
|
|
install_debian_6_0() {
|
2013-01-25 02:16:41 +00:00
|
|
|
install_debian_stable
|
|
|
|
}
|
|
|
|
|
|
|
|
install_debian_git() {
|
2012-10-18 19:54:05 -07:00
|
|
|
python setup.py install --install-layout=deb
|
|
|
|
}
|
2012-12-20 09:58:17 -08:00
|
|
|
|
2013-02-12 21:12:57 +00:00
|
|
|
install_debian_6_0_git() {
|
2013-01-25 02:16:41 +00:00
|
|
|
install_debian_git
|
|
|
|
}
|
|
|
|
|
2012-12-20 09:58:17 -08:00
|
|
|
install_debian_git_post() {
|
2013-01-21 11:42:47 +00:00
|
|
|
for fname in minion master syndic; do
|
2013-01-25 23:41:57 +00:00
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-25 23:41:57 +00:00
|
|
|
|
2012-12-20 09:58:17 -08:00
|
|
|
if [ -f ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init ]; then
|
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/debian/salt-$fname.init /etc/init.d/salt-$fname
|
|
|
|
fi
|
|
|
|
chmod +x /etc/init.d/salt-$fname
|
2013-02-08 11:59:06 +00:00
|
|
|
update-rc.d salt-$fname defaults
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_debian_restart_daemons() {
|
2013-02-08 11:59:06 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-02-08 11:59:06 +00:00
|
|
|
|
2013-02-13 12:19:08 +00:00
|
|
|
/etc/init.d/salt-$fname stop > /dev/null 2>&1
|
2013-01-28 13:21:07 +00:00
|
|
|
/etc/init.d/salt-$fname start &
|
2012-12-20 09:58:17 -08:00
|
|
|
done
|
|
|
|
}
|
2012-10-17 14:02:09 +01:00
|
|
|
#
|
|
|
|
# Ended Debian Install Functions
|
|
|
|
#
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2012-10-19 21:16:00 -07:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Fedora Install Functions
|
|
|
|
#
|
2012-10-27 07:31:14 +01:00
|
|
|
install_fedora_deps() {
|
|
|
|
yum install -y PyYAML libyaml m2crypto python-crypto python-jinja2 python-msgpack python-zmq
|
|
|
|
}
|
|
|
|
|
2012-10-19 21:16:00 -07:00
|
|
|
install_fedora_stable() {
|
2013-01-25 22:19:40 +00:00
|
|
|
packages=""
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MINION -eq $BS_TRUE ]; then
|
2013-01-25 22:19:40 +00:00
|
|
|
packages="${packages} salt-minion"
|
|
|
|
fi
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MASTER -eq $BS_TRUE ] || [ $INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
2013-01-25 22:19:40 +00:00
|
|
|
packages="${packages} salt-master"
|
|
|
|
fi
|
2013-01-25 22:27:35 +00:00
|
|
|
yum install -y ${packages}
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
|
|
|
|
2012-10-27 07:31:14 +01:00
|
|
|
install_fedora_git_deps() {
|
|
|
|
install_fedora_deps
|
|
|
|
yum install -y git
|
2013-01-18 02:42:49 +00:00
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
|
2013-01-25 01:20:33 +00:00
|
|
|
# Let's trigger config_salt()
|
2013-01-18 02:42:49 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
2013-01-18 02:42:49 +00:00
|
|
|
fi
|
2012-10-27 07:31:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
install_fedora_git() {
|
|
|
|
python setup.py install
|
|
|
|
}
|
|
|
|
|
|
|
|
install_fedora_git_post() {
|
2013-01-21 11:42:47 +00:00
|
|
|
for fname in minion master syndic; do
|
2013-01-25 23:41:57 +00:00
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-25 23:41:57 +00:00
|
|
|
|
2012-10-27 07:31:14 +01:00
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname.service /lib/systemd/system/salt-$fname.service
|
|
|
|
|
2013-01-25 22:19:40 +00:00
|
|
|
systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service)
|
|
|
|
sleep 0.1
|
2012-10-27 07:31:14 +01:00
|
|
|
systemctl daemon-reload
|
2013-02-08 12:01:50 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_fedora_restart_daemons() {
|
2013-02-08 12:01:50 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-02-08 12:01:50 +00:00
|
|
|
|
2013-02-13 12:22:47 +00:00
|
|
|
systemctl stop salt-$fname > /dev/null 2>&1
|
|
|
|
systemctl start salt-$fname.service
|
2012-10-27 07:31:14 +01:00
|
|
|
done
|
|
|
|
}
|
2012-10-19 21:16:00 -07:00
|
|
|
#
|
|
|
|
# Ended Fedora Install Functions
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2012-10-17 16:07:33 +01:00
|
|
|
#
|
|
|
|
# CentOS Install Functions
|
|
|
|
#
|
2013-01-27 18:11:30 +00:00
|
|
|
install_centos_stable_deps() {
|
2012-10-21 16:05:29 +01:00
|
|
|
if [ $CPU_ARCH_L = "i686" ]; then
|
2013-01-21 13:41:56 +00:00
|
|
|
EPEL_ARCH="i386"
|
2012-10-21 16:05:29 +01:00
|
|
|
else
|
2013-01-21 13:41:56 +00:00
|
|
|
EPEL_ARCH=$CPU_ARCH_L
|
2012-10-21 16:05:29 +01:00
|
|
|
fi
|
2013-01-31 11:21:00 -08:00
|
|
|
if [ $DISTRO_MAJOR_VERSION -eq 5 ]; then
|
2013-01-27 18:11:30 +00:00
|
|
|
rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/5/${EPEL_ARCH}/epel-release-5-4.noarch.rpm
|
2013-01-31 11:21:00 -08:00
|
|
|
elif [ $DISTRO_MAJOR_VERSION -eq 6 ]; then
|
2013-01-27 18:11:30 +00:00
|
|
|
rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/${EPEL_ARCH}/epel-release-6-8.noarch.rpm
|
2013-02-12 20:23:58 +00:00
|
|
|
else
|
|
|
|
echoerror "Failed add EPEL repository support."
|
|
|
|
exit 1
|
2013-01-27 18:11:30 +00:00
|
|
|
fi
|
2012-10-17 16:07:33 +01:00
|
|
|
yum -y update
|
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_centos_stable() {
|
2013-01-26 12:01:46 +00:00
|
|
|
packages=""
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MINION -eq $BS_TRUE ]; then
|
2013-01-26 12:01:46 +00:00
|
|
|
packages="${packages} salt-minion"
|
|
|
|
fi
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MASTER -eq $BS_TRUE ] || [ $INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
2013-01-26 12:01:46 +00:00
|
|
|
packages="${packages} salt-master"
|
|
|
|
fi
|
|
|
|
yum -y install ${packages} --enablerepo=epel-testing
|
2012-10-17 16:07:33 +01:00
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_centos_stable_post() {
|
2013-02-08 12:07:11 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-02-08 12:07:11 +00:00
|
|
|
|
|
|
|
if [ ! -f /sbin/initctl ] && [ -f /etc/init.d/salt-$fname ]; then
|
|
|
|
# Still in SysV init!?
|
|
|
|
/sbin/chkconfig salt-$fname on
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_centos_git_deps() {
|
|
|
|
install_centos_stable_deps
|
2013-02-12 22:44:12 +00:00
|
|
|
if [ $DISTRO_MAJOR_VERSION -eq 5 ]; then
|
|
|
|
yum -y install git PyYAML python26-m2crypto m2crypto python26 python26-crypto \
|
|
|
|
python26-msgpack python26-zmq python26-jinja2 --enablerepo=epel-testing
|
|
|
|
else
|
|
|
|
yum -y install git PyYAML m2crypto python-crypto python-msgpack python-zmq \
|
|
|
|
python-jinja2 --enablerepo=epel-testing
|
|
|
|
fi
|
2013-01-18 02:42:49 +00:00
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
|
2013-01-25 01:20:33 +00:00
|
|
|
# Let's trigger config_salt()
|
2013-01-18 02:42:49 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
2013-01-18 02:42:49 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-22 03:39:33 +01:00
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_centos_git() {
|
2013-02-12 22:44:12 +00:00
|
|
|
if [ $DISTRO_MAJOR_VERSION -eq 5 ]; then
|
|
|
|
python2.6 setup.py install
|
|
|
|
else
|
|
|
|
python2 setup.py install
|
|
|
|
fi
|
2012-10-22 03:39:33 +01:00
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_centos_git_post() {
|
2013-01-25 23:41:57 +00:00
|
|
|
for fname in master minion syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-25 23:41:57 +00:00
|
|
|
|
2013-01-26 18:00:10 +00:00
|
|
|
if [ -f /sbin/initctl ]; then
|
2013-01-26 17:38:48 +00:00
|
|
|
# We have upstart support
|
2013-01-26 18:00:10 +00:00
|
|
|
/sbin/initctl status salt-$fname > /dev/null 2>&1
|
|
|
|
if [ $? -eq 1 ]; then
|
2013-01-26 18:22:26 +00:00
|
|
|
# upstart does not know about our service, let's copy the proper file
|
2013-01-26 17:38:48 +00:00
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/salt-$fname.upstart /etc/init/salt-$fname.conf
|
|
|
|
fi
|
2013-02-08 12:09:37 +00:00
|
|
|
# Still in SysV init?!
|
|
|
|
elif [ ! -f /etc/init.d/salt-$fname ]; then
|
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname} /etc/init.d/
|
|
|
|
chmod +x /etc/init.d/salt-${fname}
|
2013-02-22 04:32:33 +00:00
|
|
|
/sbin/chkconfig salt-${fname} on
|
2013-02-08 12:09:37 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_centos_restart_daemons() {
|
2013-02-13 12:28:00 +00:00
|
|
|
for fname in minion master syndic; do
|
2013-02-08 12:09:37 +00:00
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-02-08 12:09:37 +00:00
|
|
|
|
|
|
|
if [ -f /sbin/initctl ]; then
|
|
|
|
# We have upstart support
|
2013-01-26 18:00:10 +00:00
|
|
|
/sbin/initctl status salt-$fname > /dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
2013-02-13 12:28:00 +00:00
|
|
|
# upstart knows about this service.
|
|
|
|
# Let's try to stop it, and then start it
|
|
|
|
/sbin/initctl stop salt-$fname > /dev/null 2>&1
|
2013-01-26 18:00:10 +00:00
|
|
|
/sbin/initctl start salt-$fname > /dev/null 2>&1
|
2013-02-13 12:28:00 +00:00
|
|
|
# Restart service
|
2013-01-26 18:00:10 +00:00
|
|
|
[ $? -eq 0 ] && continue
|
|
|
|
# We failed to start the service, let's test the SysV code bellow
|
2013-01-26 17:38:48 +00:00
|
|
|
fi
|
2013-01-26 18:00:10 +00:00
|
|
|
fi
|
|
|
|
|
2013-02-13 12:28:00 +00:00
|
|
|
if [ -f /etc/init.d/salt-$fname ]; then
|
|
|
|
# Still in SysV init!?
|
|
|
|
/etc/init.d/salt-$fname stop > /dev/null 2>&1
|
2013-02-26 13:14:11 -06:00
|
|
|
/etc/init.d/salt-$fname start
|
2013-02-13 12:28:00 +00:00
|
|
|
fi
|
2013-01-21 11:42:47 +00:00
|
|
|
done
|
2012-10-17 16:07:33 +01:00
|
|
|
}
|
|
|
|
#
|
|
|
|
# Ended CentOS Install Functions
|
|
|
|
#
|
2012-10-18 22:18:07 +01:00
|
|
|
##############################################################################
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2013-01-27 17:46:55 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# RedHat Install Functions
|
|
|
|
#
|
2013-01-27 18:11:30 +00:00
|
|
|
install_red_hat_linux_stable_deps() {
|
|
|
|
install_centos_stable_deps
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_linux_git_deps() {
|
|
|
|
install_centos_git_deps
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_enterprise_linux_stable_deps() {
|
|
|
|
install_red_hat_linux_stable_deps
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_enterprise_linux_git_deps() {
|
|
|
|
install_red_hat_linux_git_deps
|
|
|
|
}
|
|
|
|
|
2013-02-23 18:30:51 +00:00
|
|
|
install_red_hat_enterprise_server_stable_deps() {
|
|
|
|
install_red_hat_linux_stable_deps
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_enterprise_server_git_deps() {
|
|
|
|
install_red_hat_linux_git_deps
|
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_red_hat_linux_stable() {
|
|
|
|
install_centos_stable
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_linux_git() {
|
|
|
|
install_centos_git
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_enterprise_linux_stable() {
|
|
|
|
install_red_hat_linux_stable
|
2013-01-27 17:46:55 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_red_hat_enterprise_linux_git() {
|
|
|
|
install_red_hat_linux_git
|
2013-01-27 17:46:55 +00:00
|
|
|
}
|
|
|
|
|
2013-02-23 18:30:51 +00:00
|
|
|
install_red_hat_enterprise_server_stable() {
|
|
|
|
install_red_hat_linux_stable
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_enterprise_server_git() {
|
|
|
|
install_red_hat_linux_git
|
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_red_hat_linux_stable_post() {
|
|
|
|
install_centos_stable_post
|
2013-01-27 17:46:55 +00:00
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_red_hat_linux_restart_daemons() {
|
|
|
|
install_centos_restart_daemons
|
2013-02-08 12:12:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_red_hat_linux_git_post() {
|
|
|
|
install_centos_git_post
|
2013-01-27 17:46:55 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_red_hat_enterprise_linux_stable_post() {
|
|
|
|
install_red_hat_linux_stable_post
|
2013-01-27 17:46:55 +00:00
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_red_hat_enterprise_linux_restart_daemons() {
|
|
|
|
install_red_hat_linux_restart_daemons
|
2013-02-08 12:12:08 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 18:11:30 +00:00
|
|
|
install_red_hat_enterprise_linux_git_post() {
|
|
|
|
install_red_hat_linux_git_post
|
2013-01-27 17:46:55 +00:00
|
|
|
}
|
2013-02-23 18:30:51 +00:00
|
|
|
|
|
|
|
install_red_hat_enterprise_server_stable_post() {
|
|
|
|
install_red_hat_linux_stable_post
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_enterprise_server_restart_daemons() {
|
|
|
|
install_red_hat_linux_restart_daemons
|
|
|
|
}
|
|
|
|
|
|
|
|
install_red_hat_enterprise_server_git_post() {
|
|
|
|
install_red_hat_linux_git_post
|
|
|
|
}
|
2013-01-27 17:46:55 +00:00
|
|
|
#
|
|
|
|
# Ended RedHat Install Functions
|
|
|
|
#
|
|
|
|
##############################################################################
|
2013-01-31 18:52:58 +00:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Amazon Linux AMI Install Functions
|
|
|
|
#
|
|
|
|
install_amazon_linux_ami_deps() {
|
|
|
|
# Acording to http://aws.amazon.com/amazon-linux-ami/faqs/#epel we should
|
|
|
|
# enable the EPEL 6 repo
|
|
|
|
if [ $CPU_ARCH_L = "i686" ]; then
|
|
|
|
EPEL_ARCH="i386"
|
|
|
|
else
|
|
|
|
EPEL_ARCH=$CPU_ARCH_L
|
|
|
|
fi
|
|
|
|
rpm -Uvh --force http://mirrors.kernel.org/fedora-epel/6/${EPEL_ARCH}/epel-release-6-8.noarch.rpm
|
|
|
|
yum -y update
|
|
|
|
}
|
|
|
|
|
|
|
|
install_amazon_linux_ami_git_deps() {
|
|
|
|
install_amazon_linux_ami_deps
|
|
|
|
yum -y install git PyYAML m2crypto python-crypto python-msgpack python-zmq \
|
|
|
|
python-ordereddict python-jinja2 --enablerepo=epel-testing
|
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
|
|
|
|
# Let's trigger config_salt()
|
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_amazon_linux_ami_stable() {
|
|
|
|
install_centos_stable
|
|
|
|
}
|
|
|
|
|
2013-02-08 12:15:11 +00:00
|
|
|
install_amazon_linux_ami_stable_post() {
|
|
|
|
install_centos_stable_post
|
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_amazon_linux_ami_restart_daemons() {
|
|
|
|
install_centos_restart_daemons
|
2013-02-08 12:15:11 +00:00
|
|
|
}
|
|
|
|
|
2013-01-31 18:52:58 +00:00
|
|
|
install_amazon_linux_ami_git() {
|
|
|
|
install_centos_git
|
|
|
|
}
|
|
|
|
|
|
|
|
install_amazon_linux_ami_git_post() {
|
|
|
|
install_centos_git_post
|
|
|
|
}
|
|
|
|
#
|
|
|
|
# Ended Amazon Linux AMI Install Functions
|
|
|
|
#
|
|
|
|
##############################################################################
|
2013-01-27 17:46:55 +00:00
|
|
|
|
2012-10-19 21:16:00 -07:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Arch Install Functions
|
|
|
|
#
|
2013-02-23 02:13:26 +00:00
|
|
|
install_arch_linux_stable_deps() {
|
2013-01-22 17:36:25 +00:00
|
|
|
grep '\[salt\]' /etc/pacman.conf >/dev/null 2>&1 || echo '[salt]
|
2012-12-08 11:18:06 -07:00
|
|
|
Server = http://intothesaltmine.org/archlinux
|
2012-10-19 21:16:00 -07:00
|
|
|
' >> /etc/pacman.conf
|
|
|
|
}
|
|
|
|
|
2013-02-23 02:13:26 +00:00
|
|
|
install_arch_linux_git_deps() {
|
2013-01-23 14:33:06 +00:00
|
|
|
grep '\[salt\]' /etc/pacman.conf >/dev/null 2>&1 || echo '[salt]
|
|
|
|
Server = http://intothesaltmine.org/archlinux
|
|
|
|
' >> /etc/pacman.conf
|
|
|
|
|
2013-01-22 21:19:58 +00:00
|
|
|
pacman -Sy --noconfirm pacman git python2-crypto python2-distribute \
|
|
|
|
python2-jinja python2-m2crypto python2-markupsafe python2-msgpack \
|
|
|
|
python2-psutil python2-pyzmq zeromq
|
2013-01-18 02:42:49 +00:00
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
|
2013-01-25 01:20:33 +00:00
|
|
|
# Let's trigger config_salt()
|
2013-01-18 02:42:49 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
2013-01-18 02:42:49 +00:00
|
|
|
fi
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-23 02:13:26 +00:00
|
|
|
install_arch_linux_stable() {
|
2012-10-19 21:16:00 -07:00
|
|
|
pacman -Sy --noconfirm pacman
|
|
|
|
pacman -Syu --noconfirm salt
|
|
|
|
}
|
|
|
|
|
2013-02-23 02:13:26 +00:00
|
|
|
install_arch_linux_git() {
|
2012-10-19 21:16:00 -07:00
|
|
|
python2 setup.py install
|
|
|
|
}
|
|
|
|
|
2013-02-23 02:13:26 +00:00
|
|
|
install_arch_linux_post() {
|
2013-01-26 18:43:48 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-26 18:43:48 +00:00
|
|
|
|
|
|
|
if [ -f /usr/bin/systemctl ]; then
|
|
|
|
# Using systemd
|
2013-01-26 19:21:24 +00:00
|
|
|
/usr/bin/systemctl is-enabled salt-$fname.service > /dev/null 2>&1 || (
|
|
|
|
/usr/bin/systemctl preset salt-$fname.service > /dev/null 2>&1 &&
|
|
|
|
/usr/bin/systemctl enable salt-$fname.service > /dev/null 2>&1
|
2013-01-26 18:43:48 +00:00
|
|
|
)
|
|
|
|
sleep 0.1
|
2013-01-26 19:14:46 +00:00
|
|
|
/usr/bin/systemctl daemon-reload
|
2013-01-26 18:43:48 +00:00
|
|
|
continue
|
|
|
|
fi
|
2013-02-08 12:33:47 +00:00
|
|
|
|
|
|
|
# XXX: How do we enable old Arch init.d scripts?
|
2013-01-26 18:43:48 +00:00
|
|
|
done
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
2013-01-22 21:19:58 +00:00
|
|
|
|
2013-02-23 02:13:26 +00:00
|
|
|
install_arch_linux_git_post() {
|
2013-01-25 23:41:57 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-25 23:41:57 +00:00
|
|
|
|
|
|
|
if [ -f /usr/bin/systemctl ]; then
|
2013-01-22 21:19:58 +00:00
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname.service /lib/systemd/system/salt-$fname.service
|
|
|
|
|
2013-01-26 19:21:24 +00:00
|
|
|
/usr/bin/systemctl is-enabled salt-$fname.service > /dev/null 2>&1 || (
|
|
|
|
/usr/bin/systemctl preset salt-$fname.service > /dev/null 2>&1 &&
|
|
|
|
/usr/bin/systemctl enable salt-$fname.service > /dev/null 2>&1
|
2013-01-26 18:43:48 +00:00
|
|
|
)
|
|
|
|
sleep 0.1
|
2013-01-26 19:14:46 +00:00
|
|
|
/usr/bin/systemctl daemon-reload
|
2013-01-26 18:43:48 +00:00
|
|
|
continue
|
2013-01-25 23:41:57 +00:00
|
|
|
fi
|
2013-01-26 18:43:48 +00:00
|
|
|
|
|
|
|
# SysV init!?
|
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname /etc/rc.d/init.d/salt-$fname
|
|
|
|
chmod +x /etc/rc.d/init.d/salt-$fname
|
2013-01-25 23:41:57 +00:00
|
|
|
done
|
2013-01-22 21:19:58 +00:00
|
|
|
}
|
2013-02-08 12:33:47 +00:00
|
|
|
|
2013-02-23 02:13:26 +00:00
|
|
|
install_arch_linux_restart_daemons() {
|
2013-02-08 12:33:47 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-02-08 12:33:47 +00:00
|
|
|
|
|
|
|
if [ -f /usr/bin/systemctl ]; then
|
2013-02-13 12:31:51 +00:00
|
|
|
/usr/bin/systemctl stop salt-$fname.service > /dev/null 2>&1
|
|
|
|
/usr/bin/systemctl start salt-$fname.service
|
2013-02-08 12:33:47 +00:00
|
|
|
continue
|
|
|
|
fi
|
2013-02-13 12:31:51 +00:00
|
|
|
/etc/rc.d/salt-$fname stop > /dev/null 2>&1
|
2013-02-08 12:33:47 +00:00
|
|
|
/etc/rc.d/salt-$fname start &
|
|
|
|
done
|
|
|
|
}
|
2012-10-19 21:16:00 -07:00
|
|
|
#
|
|
|
|
# Ended Arch Install Functions
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# FreeBSD Install Functions
|
|
|
|
#
|
2013-02-12 00:20:58 +00:00
|
|
|
__freebsd_get_packagesite() {
|
2012-12-03 19:09:01 -07:00
|
|
|
if [ $CPU_ARCH_L = "amd64" ]; then
|
2013-01-21 13:41:56 +00:00
|
|
|
BSD_ARCH="x86:64"
|
2012-12-03 19:09:01 -07:00
|
|
|
elif [ $CPU_ARCH_L = "x86_64" ]; then
|
2013-01-21 13:41:56 +00:00
|
|
|
BSD_ARCH="x86:64"
|
2012-12-03 19:09:01 -07:00
|
|
|
elif [ $CPU_ARCH_L = "i386" ]; then
|
2013-01-21 13:41:56 +00:00
|
|
|
BSD_ARCH="x86:32"
|
2012-12-03 19:09:01 -07:00
|
|
|
elif [ $CPU_ARCH_L = "i686" ]; then
|
2013-01-21 13:41:56 +00:00
|
|
|
BSD_ARCH="x86:32"
|
2012-10-23 08:09:12 +01:00
|
|
|
fi
|
|
|
|
|
2013-02-24 09:24:06 +00:00
|
|
|
if [ "x${PACKAGESITE}" = "x" ]; then
|
|
|
|
echowarn "The environment variable PACKAGESITE is not set."
|
|
|
|
echowarn "The installation will, most likely fail since pkgbeta.freebsd.org does not yet contain any packages"
|
|
|
|
fi
|
2013-02-12 21:18:57 +00:00
|
|
|
BS_PACKAGESITE=${PACKAGESITE:-"http://pkgbeta.freebsd.org/freebsd:${DISTRO_MAJOR_VERSION}:${BSD_ARCH}/latest"}
|
2013-02-12 00:20:58 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 21:18:57 +00:00
|
|
|
install_freebsd_9_stable_deps() {
|
2013-02-12 00:20:58 +00:00
|
|
|
__freebsd_get_packagesite
|
|
|
|
|
2013-02-12 19:10:38 +00:00
|
|
|
fetch "${BS_PACKAGESITE}/Latest/pkg.txz"
|
2012-12-03 19:09:01 -07:00
|
|
|
tar xf ./pkg.txz -s ",/.*/,,g" "*/pkg-static"
|
|
|
|
./pkg-static add ./pkg.txz
|
2012-10-19 21:16:00 -07:00
|
|
|
/usr/local/sbin/pkg2ng
|
2013-02-12 19:10:38 +00:00
|
|
|
echo "PACKAGESITE: ${BS_PACKAGESITE}" > /usr/local/etc/pkg.conf
|
2012-12-03 14:34:38 -07:00
|
|
|
|
2012-12-03 19:09:01 -07:00
|
|
|
/usr/local/sbin/pkg install -y swig
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
install_freebsd_git_deps() {
|
2013-02-12 00:20:58 +00:00
|
|
|
__freebsd_get_packagesite
|
2012-10-23 08:09:12 +01:00
|
|
|
|
2013-02-12 19:10:38 +00:00
|
|
|
fetch "${BS_PACKAGESITE}/Latest/pkg.txz"
|
2012-12-03 19:09:01 -07:00
|
|
|
tar xf ./pkg.txz -s ",/.*/,,g" "*/pkg-static"
|
|
|
|
./pkg-static add ./pkg.txz
|
2012-10-19 21:16:00 -07:00
|
|
|
/usr/local/sbin/pkg2ng
|
2013-02-12 19:10:38 +00:00
|
|
|
echo "PACKAGESITE: ${BS_PACKAGESITE}" > /usr/local/etc/pkg.conf
|
2012-12-03 14:34:38 -07:00
|
|
|
|
2012-12-03 19:09:01 -07:00
|
|
|
/usr/local/sbin/pkg install -y swig
|
2013-01-18 02:42:49 +00:00
|
|
|
|
|
|
|
__git_clone_and_checkout
|
2013-01-25 01:20:33 +00:00
|
|
|
# Let's trigger config_salt()
|
2013-01-18 02:42:49 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
2013-01-18 02:42:49 +00:00
|
|
|
fi
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
|
|
|
|
2013-02-12 21:18:57 +00:00
|
|
|
install_freebsd_9_stable() {
|
2013-02-07 08:47:00 +00:00
|
|
|
/usr/local/sbin/pkg install -y sysutils/py-salt
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
install_freebsd_git() {
|
2013-02-07 08:47:00 +00:00
|
|
|
/usr/local/sbin/pkg install -y git sysutils/py-salt
|
|
|
|
/usr/local/sbin/pkg delete -y sysutils/py-salt
|
2012-10-27 07:31:14 +01:00
|
|
|
|
2012-10-19 21:16:00 -07:00
|
|
|
/usr/local/bin/python setup.py install
|
|
|
|
}
|
|
|
|
|
2013-02-12 21:18:57 +00:00
|
|
|
install_freebsd_9_stable_post() {
|
2013-02-08 12:38:00 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-02-08 12:38:00 +00:00
|
|
|
|
2013-02-11 23:56:04 +00:00
|
|
|
enable_string="salt_${fname}_enable=\"YES\""
|
|
|
|
grep "$enable_string" /etc/rc.conf >/dev/null 2>&1
|
|
|
|
[ $? -eq 1 ] && echo "$enable_string" >> /etc/rc.conf
|
2013-02-07 08:46:01 +00:00
|
|
|
|
2013-02-12 18:44:06 +00:00
|
|
|
[ -f /usr/local/etc/salt/${fname}.sample ] && cp /usr/local/etc/salt/${fname}.sample /usr/local/etc/salt/${fname}
|
2013-02-12 17:59:28 +00:00
|
|
|
|
2013-02-11 23:15:37 +00:00
|
|
|
if [ $fname = "minion" ] ; then
|
2013-02-11 23:56:04 +00:00
|
|
|
grep "salt_minion_paths" /etc/rc.conf >/dev/null 2>&1
|
|
|
|
[ $? -eq 1 ] && echo "salt_minion_paths=\"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin\"" >> /etc/rc.conf
|
2013-02-11 23:15:37 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
2013-02-07 08:46:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_freebsd_git_post() {
|
2013-02-13 16:47:07 +00:00
|
|
|
install_freebsd_9_stable_post
|
2013-02-08 12:38:00 +00:00
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_freebsd_restart_daemons() {
|
2013-02-08 12:38:00 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-02-08 12:38:00 +00:00
|
|
|
|
2013-02-13 12:33:42 +00:00
|
|
|
service salt_$fname stop > /dev/null 2>&1
|
2013-02-11 23:15:37 +00:00
|
|
|
service salt_$fname start &
|
2013-02-08 12:38:00 +00:00
|
|
|
done
|
2012-10-19 21:16:00 -07:00
|
|
|
}
|
|
|
|
#
|
|
|
|
# Ended FreeBSD Install Functions
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2013-01-27 23:12:58 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# SmartOS Install Functions
|
|
|
|
#
|
|
|
|
install_smartos_deps() {
|
2013-02-24 01:51:47 +00:00
|
|
|
ZEROMQ_VERSION='3.2.2'
|
2013-01-27 23:12:58 +00:00
|
|
|
pkgin -y in libtool-base autoconf automake libuuid gcc-compiler gmake \
|
2013-02-24 01:54:44 +00:00
|
|
|
python27 py27-pip py27-setuptools py27-yaml py27-crypto swig
|
2013-02-24 01:51:47 +00:00
|
|
|
[ -d zeromq-${ZEROMQ_VERSION} ] || (
|
|
|
|
wget http://download.zeromq.org/zeromq-${ZEROMQ_VERSION}.tar.gz &&
|
|
|
|
tar -xvf zeromq-${ZEROMQ_VERSION}.tar.gz
|
2013-01-27 23:12:58 +00:00
|
|
|
)
|
2013-02-24 01:51:47 +00:00
|
|
|
cd zeromq-${ZEROMQ_VERSION}
|
2013-01-27 23:12:58 +00:00
|
|
|
./configure
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
|
2013-02-24 01:56:25 +00:00
|
|
|
pip-2.7 install pyzmq
|
2013-01-27 23:12:58 +00:00
|
|
|
|
|
|
|
# Let's trigger config_salt()
|
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
2013-02-24 02:37:41 +00:00
|
|
|
# Let's set the configuration directory to /tmp
|
|
|
|
TEMP_CONFIG_DIR="/tmp"
|
2013-01-27 23:12:58 +00:00
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
2013-02-24 02:37:41 +00:00
|
|
|
|
|
|
|
# Let's download, since they were not provided, the default configuration files
|
|
|
|
if [ ! -f /etc/salt/minion ] && [ ! -f $TEMP_CONFIG_DIR/minion ]; then
|
|
|
|
curl -sk -o $TEMP_CONFIG_DIR/minion -L https://raw.github.com/saltstack/salt/blob/develop/conf/minion
|
|
|
|
fi
|
|
|
|
if [ ! -f /etc/salt/master ] && [ ! -f $TEMP_CONFIG_DIR/master ]; then
|
|
|
|
curl -sk -o $TEMP_CONFIG_DIR/master -L https://raw.github.com/saltstack/salt/blob/develop/conf/master
|
|
|
|
fi
|
2013-01-27 23:12:58 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-27 23:31:26 +00:00
|
|
|
install_smartos_git_deps() {
|
|
|
|
install_smartos_deps
|
|
|
|
pkgin -y in scmgit
|
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
# Let's trigger config_salt()
|
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-01-27 23:12:58 +00:00
|
|
|
install_smartos_stable() {
|
2013-02-24 03:32:53 +00:00
|
|
|
USE_SETUPTOOLS=1 pip-2.7 install salt
|
2013-01-27 23:12:58 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 23:31:26 +00:00
|
|
|
install_smartos_git() {
|
2013-02-08 12:43:01 +00:00
|
|
|
# Use setuptools in order to also install dependencies
|
2013-01-29 13:17:11 +00:00
|
|
|
USE_SETUPTOOLS=1 /opt/local/bin/python setup.py install
|
2013-02-08 12:43:01 +00:00
|
|
|
}
|
2013-01-29 13:17:11 +00:00
|
|
|
|
2013-02-08 12:43:01 +00:00
|
|
|
install_smartos_post() {
|
2013-02-24 02:02:17 +00:00
|
|
|
# Install manifest files if needed.
|
|
|
|
for fname in minion master syndic; do
|
|
|
|
svcs network/salt-$fname > /dev/null 2>&1
|
|
|
|
if [ $? -eq 1 ]; then
|
2013-02-24 02:37:41 +00:00
|
|
|
if [ ! -f $TEMP_CONFIG_DIR/salt-$fname.xml ]; then
|
|
|
|
curl -sk -o $TEMP_CONFIG_DIR/salt-$fname.xml -L https://raw.github.com/saltstack/salt/develop/pkg/solaris/salt-$fname.xml
|
2013-02-24 02:02:17 +00:00
|
|
|
fi
|
2013-02-24 02:37:41 +00:00
|
|
|
svccfg import $TEMP_CONFIG_DIR/salt-$fname.xml
|
2013-02-24 02:02:17 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_smartos_git_post() {
|
2013-01-29 13:17:11 +00:00
|
|
|
# Install manifest files if needed.
|
|
|
|
for fname in minion master syndic; do
|
|
|
|
svcs network/salt-$fname > /dev/null 2>&1
|
|
|
|
if [ $? -eq 1 ]; then
|
2013-02-24 03:23:00 +00:00
|
|
|
svccfg import ${SALT_GIT_CHECKOUT_DIR}/pkg/solaris/salt-$fname.xml
|
2013-01-29 13:17:11 +00:00
|
|
|
fi
|
|
|
|
done
|
2013-01-27 23:31:26 +00:00
|
|
|
}
|
|
|
|
|
2013-02-16 10:04:25 +00:00
|
|
|
install_smartos_restart_daemons() {
|
2013-01-28 13:16:28 +00:00
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
2013-02-11 20:44:46 +00:00
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
2013-01-28 13:16:28 +00:00
|
|
|
|
2013-02-13 12:37:21 +00:00
|
|
|
# Stop if running && Start service
|
|
|
|
svcadm disable salt-$fname > /dev/null 2>&1
|
2013-02-08 12:43:01 +00:00
|
|
|
svcadm enable salt-$fname
|
2013-01-28 13:16:28 +00:00
|
|
|
done
|
2013-01-27 23:12:58 +00:00
|
|
|
}
|
|
|
|
#
|
|
|
|
# Ended SmartOS Install Functions
|
|
|
|
#
|
|
|
|
##############################################################################
|
2012-10-23 08:09:12 +01:00
|
|
|
|
2013-02-25 17:03:46 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# openSUSE Install Functions.
|
|
|
|
#
|
|
|
|
install_opensuse_stable_deps() {
|
|
|
|
DISTRO_REPO="openSUSE_${DISTRO_MAJOR_VERSION}.${DISTRO_MINOR_VERSION}"
|
2013-02-25 17:18:34 +00:00
|
|
|
zypper --non-interactive addrepo --refresh \
|
|
|
|
http://download.opensuse.org/repositories/devel:/languages:/python/${DISTRO_REPO}/devel:languages:python.repo
|
2013-02-25 17:03:46 +00:00
|
|
|
zypper --gpg-auto-import-keys --non-interactive refresh
|
|
|
|
zypper --non-interactive install --auto-agree-with-licenses libzmq3 python \
|
|
|
|
python-Jinja2 python-M2Crypto python-PyYAML python-msgpack-python \
|
|
|
|
python-pycrypto python-pyzmq
|
|
|
|
}
|
|
|
|
|
|
|
|
install_opensuse_git_deps() {
|
|
|
|
install_opensuse_stable_deps
|
|
|
|
zypper --non-interactive install --auto-agree-with-licenses git
|
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
|
|
|
|
# Let's trigger config_salt()
|
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_opensuse_stable() {
|
|
|
|
packages=""
|
|
|
|
if [ $INSTALL_MINION -eq $BS_TRUE ]; then
|
|
|
|
packages="${packages} salt-minion"
|
|
|
|
fi
|
2013-02-25 17:52:39 +00:00
|
|
|
if [ $INSTALL_MASTER -eq $BS_TRUE ]; then
|
2013-02-25 17:03:46 +00:00
|
|
|
packages="${packages} salt-master"
|
|
|
|
fi
|
2013-02-25 17:52:39 +00:00
|
|
|
if [ $INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
|
|
|
packages="${packages} salt-syndic"
|
|
|
|
fi
|
2013-02-25 17:03:46 +00:00
|
|
|
zypper --non-interactive install --auto-agree-with-licenses $packages
|
|
|
|
}
|
|
|
|
|
|
|
|
install_opensuse_git() {
|
2013-02-26 18:20:50 +00:00
|
|
|
python setup.py install --prefix=/usr
|
2013-02-25 17:03:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_opensuse_stable_post() {
|
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
|
|
|
|
2013-02-26 18:16:26 +00:00
|
|
|
if [ -f /bin/systemctl ]; then
|
|
|
|
systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service)
|
|
|
|
sleep 0.1
|
|
|
|
systemctl daemon-reload
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
/sbin/chkconfig --add salt-$fname
|
|
|
|
/sbin/chkconfig salt-$fname on
|
|
|
|
|
2013-02-25 17:03:46 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_opensuse_git_post() {
|
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
|
|
|
|
2013-02-26 18:16:26 +00:00
|
|
|
if [ -f /bin/systemctl ]; then
|
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/salt-$fname.service /lib/systemd/system/salt-$fname.service
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp ${SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-$fname /etc/init.d/salt-$fname
|
|
|
|
chmod +x /etc/init.d/salt-$fname
|
|
|
|
|
2013-02-25 17:03:46 +00:00
|
|
|
done
|
2013-02-26 18:16:26 +00:00
|
|
|
|
2013-02-25 17:03:46 +00:00
|
|
|
install_opensuse_stable_post
|
|
|
|
}
|
|
|
|
|
|
|
|
install_opensuse_restart_daemons() {
|
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
|
|
|
|
2013-02-26 18:16:26 +00:00
|
|
|
if [ -f /bin/systemctl ]; then
|
|
|
|
systemctl stop salt-$fname > /dev/null 2>&1
|
|
|
|
systemctl start salt-$fname.service
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
service salt-$fname stop > /dev/null 2>&1
|
|
|
|
service salt-$fname start &
|
|
|
|
|
2013-02-25 17:03:46 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
#
|
|
|
|
# End of openSUSE Install Functions.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2013-02-19 21:30:51 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# SuSE Install Functions.
|
|
|
|
#
|
2013-02-26 14:01:02 +00:00
|
|
|
install_suse_11_stable_deps() {
|
2013-02-26 20:16:56 +00:00
|
|
|
SUSE_PATCHLEVEL=$(grep PATCHLEVEL /etc/SuSE-release | awk '{print $3}')
|
|
|
|
if [ "x${SUSE_PATCHLEVEL}" != "x" ]; then
|
|
|
|
DISTRO_PATCHLEVEL="_SP${SUSE_PATCHLEVEL}"
|
2013-02-19 21:30:51 +00:00
|
|
|
fi
|
2013-02-26 14:01:02 +00:00
|
|
|
DISTRO_REPO="SLE_${DISTRO_MAJOR_VERSION}${DISTRO_PATCHLEVEL}"
|
|
|
|
|
|
|
|
zypper --non-interactive addrepo --refresh \
|
|
|
|
http://download.opensuse.org/repositories/devel:/languages:/python/${DISTRO_REPO}/devel:languages:python.repo
|
|
|
|
zypper --gpg-auto-import-keys --non-interactive refresh
|
2013-02-26 20:16:56 +00:00
|
|
|
if [ $SUSE_PATCHLEVEL -eq 1 ]; then
|
2013-02-26 19:12:13 +00:00
|
|
|
zypper --non-interactive install --auto-agree-with-licenses libzmq3 python \
|
|
|
|
python-Jinja2 'python-M2Crypto>=0.21' python-msgpack-python \
|
|
|
|
python-pycrypto python-pyzmq python-pip
|
|
|
|
# There's no python-PyYaml in SP1, let's install it using pip
|
|
|
|
pip install PyYaml
|
|
|
|
else
|
|
|
|
zypper --non-interactive install --auto-agree-with-licenses libzmq3 python \
|
2013-02-26 17:34:05 +00:00
|
|
|
python-Jinja2 'python-M2Crypto>=0.21' python-PyYAML python-msgpack-python \
|
2013-02-26 14:01:02 +00:00
|
|
|
python-pycrypto python-pyzmq
|
2013-02-26 19:12:13 +00:00
|
|
|
fi
|
2013-02-19 21:30:51 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 14:01:02 +00:00
|
|
|
install_suse_11_git_deps() {
|
2013-02-19 21:30:51 +00:00
|
|
|
install_suse_11_stable_deps
|
2013-02-26 20:51:17 +00:00
|
|
|
zypper --non-interactive install --auto-agree-with-licenses git
|
|
|
|
|
|
|
|
__git_clone_and_checkout
|
|
|
|
|
|
|
|
# Let's trigger config_salt()
|
|
|
|
if [ "$TEMP_CONFIG_DIR" = "null" ]; then
|
|
|
|
TEMP_CONFIG_DIR="${SALT_GIT_CHECKOUT_DIR}/conf/"
|
|
|
|
CONFIG_SALT_FUNC="config_salt"
|
|
|
|
fi
|
2013-02-19 21:30:51 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 14:01:02 +00:00
|
|
|
install_suse_11_stable() {
|
2013-02-26 20:24:59 +00:00
|
|
|
if [ $SUSE_PATCHLEVEL -gt 1 ]; then
|
2013-02-26 20:16:56 +00:00
|
|
|
install_opensuse_stable
|
|
|
|
else
|
2013-02-26 20:42:08 +00:00
|
|
|
# USE_SETUPTOOLS=1 To work around
|
|
|
|
# error: option --single-version-externally-managed not recognized
|
|
|
|
USE_SETUPTOOLS=1 pip install salt
|
2013-02-26 20:16:56 +00:00
|
|
|
fi
|
2013-02-19 21:30:51 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 14:01:02 +00:00
|
|
|
install_suse_11_git() {
|
|
|
|
install_opensuse_git
|
|
|
|
}
|
2013-02-19 21:30:51 +00:00
|
|
|
|
2013-02-26 14:01:02 +00:00
|
|
|
install_suse_11_stable_post() {
|
2013-02-26 20:24:59 +00:00
|
|
|
if [ $SUSE_PATCHLEVEL -gt 1 ]; then
|
2013-02-26 20:16:56 +00:00
|
|
|
install_opensuse_stable_post
|
|
|
|
else
|
|
|
|
for fname in minion master syndic; do
|
|
|
|
|
|
|
|
# Skip if not meant to be installed
|
|
|
|
[ $fname = "minion" ] && [ $INSTALL_MINION -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "master" ] && [ $INSTALL_MASTER -eq $BS_FALSE ] && continue
|
|
|
|
[ $fname = "syndic" ] && [ $INSTALL_SYNDIC -eq $BS_FALSE ] && continue
|
|
|
|
|
|
|
|
if [ -f /bin/systemctl ]; then
|
|
|
|
curl -k -L https://github.com/saltstack/salt/raw/develop/pkg/salt-$fname.service \
|
|
|
|
-o /lib/systemd/system/salt-$fname.service
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
curl -k -L https://github.com/saltstack/salt/raw/develop/pkg/rpm/salt-$fname \
|
|
|
|
-o /etc/init.d/salt-$fname
|
|
|
|
chmod +x /etc/init.d/salt-$fname
|
|
|
|
|
|
|
|
done
|
|
|
|
fi
|
2013-02-19 21:30:51 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 14:01:02 +00:00
|
|
|
install_suse_11_git_post() {
|
|
|
|
install_opensuse_git_post
|
2013-02-19 21:30:51 +00:00
|
|
|
}
|
|
|
|
|
2013-02-26 14:01:02 +00:00
|
|
|
install_suse_11_restart_daemons() {
|
|
|
|
install_opensuse_restart_daemons
|
2013-02-19 21:30:51 +00:00
|
|
|
}
|
|
|
|
#
|
|
|
|
# End of SuSE Install Functions.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-11-28 04:29:33 +00:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Default minion configuration function. Matches ANY distribution as long as
|
2013-01-18 02:42:49 +00:00
|
|
|
# the -c options is passed.
|
2012-11-28 04:29:33 +00:00
|
|
|
#
|
2013-01-25 00:03:27 +00:00
|
|
|
config_salt() {
|
2012-11-28 04:29:33 +00:00
|
|
|
# If the configuration directory is not passed, return
|
2012-11-28 18:13:19 +00:00
|
|
|
[ "$TEMP_CONFIG_DIR" = "null" ] && return
|
2013-02-11 22:11:00 +00:00
|
|
|
|
|
|
|
CONFIGURED_ANYTHING=$BS_FALSE
|
2012-11-28 04:29:33 +00:00
|
|
|
|
2013-01-25 02:01:00 +00:00
|
|
|
SALT_DIR=/etc/salt
|
|
|
|
PKI_DIR=$SALT_DIR/pki
|
2013-02-11 22:11:00 +00:00
|
|
|
|
2012-11-28 04:29:33 +00:00
|
|
|
# Let's create the necessary directories
|
2013-01-25 02:01:00 +00:00
|
|
|
[ -d $SALT_DIR ] || mkdir $SALT_DIR
|
2013-01-07 21:25:58 -08:00
|
|
|
[ -d $PKI_DIR ] || mkdir -p $PKI_DIR && chmod 700 $PKI_DIR
|
2012-11-28 04:29:33 +00:00
|
|
|
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MINION -eq $BS_TRUE ]; then
|
2013-01-25 02:01:00 +00:00
|
|
|
# Create the PKI directory
|
|
|
|
[ -d $PKI_DIR/minion ] || mkdir -p $PKI_DIR/minion && chmod 700 $PKI_DIR/minion
|
2012-11-28 04:29:33 +00:00
|
|
|
|
2013-01-25 02:01:00 +00:00
|
|
|
# Copy the minions configuration if found
|
2013-02-11 21:58:59 +00:00
|
|
|
[ -f "$TEMP_CONFIG_DIR/minion" ] && mv "$TEMP_CONFIG_DIR/minion" /etc/salt && CONFIGURED_ANYTHING=$BS_TRUE
|
2013-01-07 19:20:10 -08:00
|
|
|
|
2013-01-25 02:01:00 +00:00
|
|
|
# Copy the minion's keys if found
|
|
|
|
if [ -f "$TEMP_CONFIG_DIR/minion.pem" ]; then
|
|
|
|
mv "$TEMP_CONFIG_DIR/minion.pem" $PKI_DIR/minion/
|
|
|
|
chmod 400 $PKI_DIR/minion/minion.pem
|
2013-02-11 21:58:59 +00:00
|
|
|
CONFIGURED_ANYTHING=$BS_TRUE
|
2013-01-25 02:01:00 +00:00
|
|
|
fi
|
|
|
|
if [ -f "$TEMP_CONFIG_DIR/minion.pub" ]; then
|
|
|
|
mv "$TEMP_CONFIG_DIR/minion.pub" $PKI_DIR/minion/
|
|
|
|
chmod 664 $PKI_DIR/minion/minion.pub
|
2013-02-11 21:58:59 +00:00
|
|
|
CONFIGURED_ANYTHING=$BS_TRUE
|
2013-01-25 02:01:00 +00:00
|
|
|
fi
|
2012-11-28 04:29:33 +00:00
|
|
|
fi
|
2013-01-24 13:23:33 -07:00
|
|
|
|
2013-01-25 02:01:00 +00:00
|
|
|
|
2013-02-11 20:44:46 +00:00
|
|
|
if [ $INSTALL_MASTER -eq $BS_TRUE ] || [ $INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
2013-01-25 02:01:00 +00:00
|
|
|
# Create the PKI directory
|
|
|
|
[ -d $PKI_DIR/master ] || mkdir -p $PKI_DIR/master && chmod 700 $PKI_DIR/master
|
|
|
|
|
|
|
|
# Copy the masters configuration if found
|
2013-02-11 21:58:59 +00:00
|
|
|
[ -f "$TEMP_CONFIG_DIR/master" ] && mv "$TEMP_CONFIG_DIR/master" /etc/salt && CONFIGURED_ANYTHING=$BS_TRUE
|
2013-01-25 02:01:00 +00:00
|
|
|
|
|
|
|
# Copy the master's keys if found
|
|
|
|
if [ -f "$TEMP_CONFIG_DIR/master.pem" ]; then
|
|
|
|
mv "$TEMP_CONFIG_DIR/master.pem" $PKI_DIR/master/
|
|
|
|
chmod 400 $PKI_DIR/master/master.pem
|
2013-02-11 21:58:59 +00:00
|
|
|
CONFIGURED_ANYTHING=$BS_TRUE
|
2013-01-25 02:01:00 +00:00
|
|
|
fi
|
|
|
|
if [ -f "$TEMP_CONFIG_DIR/master.pub" ]; then
|
|
|
|
mv "$TEMP_CONFIG_DIR/master.pub" $PKI_DIR/master/
|
|
|
|
chmod 664 $PKI_DIR/master/master.pub
|
2013-02-11 21:58:59 +00:00
|
|
|
CONFIGURED_ANYTHING=$BS_TRUE
|
2013-01-25 02:01:00 +00:00
|
|
|
fi
|
2013-01-24 13:23:33 -07:00
|
|
|
fi
|
2013-02-11 21:58:59 +00:00
|
|
|
|
|
|
|
if [ $CONFIG_ONLY -eq $BS_TRUE ] && [ $CONFIGURED_ANYTHING -eq $BS_FALSE ]; then
|
|
|
|
echoerror "No configuration or keys were copied over. No configuration was done!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-11-28 04:29:33 +00:00
|
|
|
}
|
|
|
|
#
|
|
|
|
# Ended Default Configuration function
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
|
2012-10-18 22:18:07 +01:00
|
|
|
#=============================================================================
|
|
|
|
# LET'S PROCEED WITH OUR INSTALLATION
|
|
|
|
#=============================================================================
|
2012-10-18 17:28:00 +01:00
|
|
|
# Let's get the dependencies install function
|
2013-02-12 21:12:57 +00:00
|
|
|
DEP_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_deps"
|
|
|
|
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_deps"
|
|
|
|
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_deps"
|
|
|
|
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_deps"
|
2012-10-18 23:54:58 +01:00
|
|
|
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_deps"
|
|
|
|
DEP_FUNC_NAMES="$DEP_FUNC_NAMES install_${DISTRO_NAME_L}_deps"
|
2012-10-18 17:28:00 +01:00
|
|
|
|
|
|
|
DEPS_INSTALL_FUNC="null"
|
2013-02-24 07:54:28 +00:00
|
|
|
for DEP_FUNC_NAME in $(__strip_duplicates $DEP_FUNC_NAMES); do
|
2012-10-18 17:28:00 +01:00
|
|
|
if __function_defined $DEP_FUNC_NAME; then
|
|
|
|
DEPS_INSTALL_FUNC=$DEP_FUNC_NAME
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2012-11-28 04:29:33 +00:00
|
|
|
# Let's get the minion config function
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC="null"
|
2012-11-28 18:13:19 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" != "null" ]; then
|
2013-02-12 21:12:57 +00:00
|
|
|
|
|
|
|
CONFIG_FUNC_NAMES="config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_salt"
|
|
|
|
CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_salt"
|
|
|
|
CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_salt"
|
|
|
|
CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_salt"
|
2013-01-25 00:03:27 +00:00
|
|
|
CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_${ITYPE}_salt"
|
|
|
|
CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_${DISTRO_NAME_L}_salt"
|
|
|
|
CONFIG_FUNC_NAMES="$CONFIG_FUNC_NAMES config_salt"
|
2012-11-28 04:29:33 +00:00
|
|
|
|
2013-02-24 07:54:28 +00:00
|
|
|
for FUNC_NAME in $(__strip_duplicates $CONFIG_FUNC_NAMES); do
|
2012-11-28 04:29:33 +00:00
|
|
|
if __function_defined $FUNC_NAME; then
|
2013-01-25 01:20:33 +00:00
|
|
|
CONFIG_SALT_FUNC=$FUNC_NAME
|
2012-11-28 04:29:33 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2013-01-18 02:42:49 +00:00
|
|
|
# Let's get the install function
|
2013-02-12 21:12:57 +00:00
|
|
|
INSTALL_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}"
|
|
|
|
INSTALL_FUNC_NAMES="$INSTALL_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}"
|
2013-01-18 02:42:49 +00:00
|
|
|
INSTALL_FUNC_NAMES="$INSTALL_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}"
|
|
|
|
|
|
|
|
INSTALL_FUNC="null"
|
2013-02-24 07:54:28 +00:00
|
|
|
for FUNC_NAME in $(__strip_duplicates $INSTALL_FUNC_NAMES); do
|
2013-01-18 02:42:49 +00:00
|
|
|
if __function_defined $FUNC_NAME; then
|
|
|
|
INSTALL_FUNC=$FUNC_NAME
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2012-11-28 04:29:33 +00:00
|
|
|
# Let's get the post install function
|
2013-02-12 21:12:57 +00:00
|
|
|
POST_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_post"
|
|
|
|
POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_post"
|
|
|
|
POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_post"
|
|
|
|
POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_post"
|
2012-10-22 01:51:59 +01:00
|
|
|
POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_post"
|
|
|
|
POST_FUNC_NAMES="$POST_FUNC_NAMES install_${DISTRO_NAME_L}_post"
|
2012-10-18 17:28:00 +01:00
|
|
|
|
2013-02-12 21:12:57 +00:00
|
|
|
|
2012-10-18 17:28:00 +01:00
|
|
|
POST_INSTALL_FUNC="null"
|
2013-02-24 07:54:28 +00:00
|
|
|
for FUNC_NAME in $(__strip_duplicates $POST_FUNC_NAMES); do
|
2012-10-18 17:28:00 +01:00
|
|
|
if __function_defined $FUNC_NAME; then
|
2012-10-22 02:01:01 +01:00
|
|
|
POST_INSTALL_FUNC=$FUNC_NAME
|
2012-10-18 17:28:00 +01:00
|
|
|
break
|
2012-10-17 14:02:09 +01:00
|
|
|
fi
|
2012-10-18 17:28:00 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
|
2013-02-08 11:39:27 +00:00
|
|
|
# Let's get the start daemons install function
|
2013-02-16 10:04:25 +00:00
|
|
|
STARTDAEMONS_FUNC_NAMES="install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_${ITYPE}_restart_daemons"
|
|
|
|
STARTDAEMONS_FUNC_NAMES="$STARTDAEMONS_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_${ITYPE}_restart_daemons"
|
|
|
|
STARTDAEMONS_FUNC_NAMES="$STARTDAEMONS_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}_restart_daemons"
|
|
|
|
STARTDAEMONS_FUNC_NAMES="$STARTDAEMONS_FUNC_NAMES install_${DISTRO_NAME_L}${PREFIXED_DISTRO_MAJOR_VERSION}${PREFIXED_DISTRO_MINOR_VERSION}_restart_daemons"
|
|
|
|
STARTDAEMONS_FUNC_NAMES="$STARTDAEMONS_FUNC_NAMES install_${DISTRO_NAME_L}_${ITYPE}_restart_daemons"
|
|
|
|
STARTDAEMONS_FUNC_NAMES="$STARTDAEMONS_FUNC_NAMES install_${DISTRO_NAME_L}_restart_daemons"
|
2013-02-08 11:39:27 +00:00
|
|
|
|
|
|
|
STARTDAEMONS_INSTALL_FUNC="null"
|
2013-02-24 07:54:28 +00:00
|
|
|
for FUNC_NAME in $(__strip_duplicates $STARTDAEMONS_FUNC_NAMES); do
|
2013-02-08 11:39:27 +00:00
|
|
|
if __function_defined $FUNC_NAME; then
|
|
|
|
STARTDAEMONS_INSTALL_FUNC=$FUNC_NAME
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2012-10-18 17:28:00 +01:00
|
|
|
if [ $DEPS_INSTALL_FUNC = "null" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "No dependencies installation function found. Exiting..."
|
2012-10-18 17:28:00 +01:00
|
|
|
exit 1
|
2012-10-17 14:02:09 +01:00
|
|
|
fi
|
|
|
|
|
2012-11-28 04:25:40 +00:00
|
|
|
if [ $INSTALL_FUNC = "null" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "No installation function found. Exiting..."
|
2012-10-18 17:28:00 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2012-10-17 14:02:09 +01:00
|
|
|
# Install dependencies
|
2013-02-11 21:27:54 +00:00
|
|
|
if [ $CONFIG_ONLY -eq $BS_FALSE ]; then
|
2013-02-10 19:46:56 +00:00
|
|
|
# Only execute function is not in config mode only
|
|
|
|
echoinfo "Running ${DEPS_INSTALL_FUNC}()"
|
|
|
|
$DEPS_INSTALL_FUNC
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echoerror "Failed to run ${DEPS_INSTALL_FUNC}()!!!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-10-27 07:31:14 +01:00
|
|
|
fi
|
2012-10-17 14:02:09 +01:00
|
|
|
|
2013-01-18 02:42:49 +00:00
|
|
|
|
2012-11-28 04:29:33 +00:00
|
|
|
# Configure Salt
|
2013-01-25 01:20:33 +00:00
|
|
|
if [ "$TEMP_CONFIG_DIR" != "null" ] && [ "$CONFIG_SALT_FUNC" != "null" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoinfo "Running ${CONFIG_SALT_FUNC}()"
|
2013-01-25 01:20:33 +00:00
|
|
|
$CONFIG_SALT_FUNC
|
2012-11-28 04:29:33 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Failed to run ${CONFIG_SALT_FUNC}()!!!"
|
2012-11-28 04:29:33 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-01-18 02:42:49 +00:00
|
|
|
|
2013-01-08 18:51:54 -08:00
|
|
|
# Install Salt
|
2013-02-11 21:27:54 +00:00
|
|
|
if [ $CONFIG_ONLY -eq $BS_FALSE ]; then
|
2013-02-10 19:46:56 +00:00
|
|
|
# Only execute function is not in config mode only
|
|
|
|
echoinfo "Running ${INSTALL_FUNC}()"
|
|
|
|
$INSTALL_FUNC
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echoerror "Failed to run ${INSTALL_FUNC}()!!!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-01-08 18:51:54 -08:00
|
|
|
fi
|
|
|
|
|
2013-01-18 02:42:49 +00:00
|
|
|
|
2013-02-10 19:46:56 +00:00
|
|
|
# Run any post install function, Only execute function is not in config mode only
|
2013-02-11 21:27:54 +00:00
|
|
|
if [ $CONFIG_ONLY -eq $BS_FALSE ] && [ "$POST_INSTALL_FUNC" != "null" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoinfo "Running ${POST_INSTALL_FUNC}()"
|
2012-10-17 14:02:09 +01:00
|
|
|
$POST_INSTALL_FUNC
|
2012-10-27 07:31:14 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Failed to run ${POST_INSTALL_FUNC}()!!!"
|
2012-10-27 07:31:14 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2012-10-17 14:02:09 +01:00
|
|
|
fi
|
|
|
|
|
2013-01-18 02:42:49 +00:00
|
|
|
|
2013-02-08 11:39:27 +00:00
|
|
|
# Run any start daemons function
|
|
|
|
if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoinfo "Running ${STARTDAEMONS_INSTALL_FUNC}()"
|
2013-02-08 11:39:27 +00:00
|
|
|
$STARTDAEMONS_INSTALL_FUNC
|
|
|
|
if [ $? -ne 0 ]; then
|
2013-02-11 19:17:21 +00:00
|
|
|
echoerror "Failed to run ${STARTDAEMONS_INSTALL_FUNC}()!!!"
|
2013-02-08 11:39:27 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-10-17 14:02:09 +01:00
|
|
|
# Done!
|
2013-02-11 21:27:54 +00:00
|
|
|
if [ $CONFIG_ONLY -eq $BS_FALSE ]; then
|
2013-02-10 19:46:56 +00:00
|
|
|
echoinfo "Salt installed!"
|
|
|
|
else
|
|
|
|
echoinfo "Salt configured"
|
|
|
|
fi
|
2012-10-22 03:39:33 +01:00
|
|
|
exit 0
|