2013-01-18 00:24:01 +00:00
#!/bin/sh -
2014-02-17 15:21:29 +00:00
#======================================================================================================================
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en cc=120
#======================================================================================================================
2012-10-17 14:02:09 +01:00
#
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
#
2014-01-16 16:25:39 -06:00
# BUGS: https://github.com/saltstack/salt-bootstrap/issues
2013-08-05 22:48:14 +01:00
#
2014-02-16 22:52:03 +00:00
# COPYRIGHT: (c) 2012-2014 by the SaltStack Team, see AUTHORS.rst for more
Add an authors file.
Added @akoumjian, @alexvh, @plueschopath, @bruce-one, @cvrebert, @deployboy, @terminalmage, @geoffgarside, @jeffh, @ixela, @mguegan, @nevins-b, @aboe76, @s0undt3ch, @visualphoenix, @rca, @tateeskew, @thatch45, @kozhukalov and @whitmo to the authors file.
2013-08-05 22:51:09 +01:00
# details.
#
2013-01-24 17:46:40 +00:00
# LICENSE: Apache 2.0
2014-02-16 22:32:56 +00:00
# ORGANIZATION: SaltStack (saltstack.org)
2012-10-17 14:02:09 +01:00
# CREATED: 10/15/2012 09:49:37 PM WEST
2014-02-17 15:21:29 +00:00
#======================================================================================================================
2012-10-17 14:02:09 +01:00
set -o nounset # Treat unset variables as an error
2015-07-17 12:12:39 +01:00
__ScriptVersion = "2015.07.17"
2013-08-22 20:50:48 +01:00
__ScriptName = "bootstrap-salt.sh"
2012-10-18 22:18:07 +01:00
2014-02-17 15:21:29 +00:00
#======================================================================================================================
2013-02-12 18:35:31 +00:00
# Environment variables taken into account.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2014-04-16 19:27:40 +01:00
# * BS_COLORS: If 0 disables colour support
# * BS_PIP_ALLOWED: If 1 enable pip based installations(if needed)
# * BS_ECHO_DEBUG: If 1 enable debug echo which can also be set by -D
# * BS_SALT_ETC_DIR: Defaults to /etc/salt (Only tweak'able on git based installations)
# * BS_KEEP_TEMP_FILES: If 1, don't move temporary files, instead copy them
# * BS_FORCE_OVERWRITE: Force overriding copied files(config, init.d, etc)
# * BS_UPGRADE_SYS: If 1 and an option, upgrade system. Default 0.
# * BS_GENTOO_USE_BINHOST: If 1 add `--getbinpkg` to gentoo's emerge
2014-09-07 17:23:53 -07:00
# * BS_SALT_MASTER_ADDRESS: The IP or DNS name of the salt-master the minion should connect to
2014-08-14 03:37:14 +01:00
# * BS_SALT_GIT_CHECKOUT_DIR: The directory where to clone Salt on git installations
2014-02-17 15:21:29 +00:00
#======================================================================================================================
#======================================================================================================================
2012-10-18 22:18:07 +01:00
# LET THE BLACK MAGIC BEGIN!!!!
2014-02-17 15:21:29 +00:00
#======================================================================================================================
2012-10-18 22:18:07 +01:00
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
2014-07-20 22:51:56 +01:00
# Default sleep time used when waiting for daemons to start, restart and checking for these running
2014-08-03 21:51:14 +01:00
__DEFAULT_SLEEP = 3
__DEFAULT_SLEEP_ORIGINAL = " ${ __DEFAULT_SLEEP } "
2014-07-20 22:51:56 +01:00
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-11 20:22:33 +00:00
# NAME: __detect_color_support
# DESCRIPTION: Try to detect color support.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-08-22 20:50:48 +01:00
_COLORS = ${ BS_COLORS :- $( tput colors 2>/dev/null || echo 0) }
2013-02-11 20:22:33 +00:00
__detect_color_support( ) {
2013-08-22 20:50:48 +01:00
if [ $? -eq 0 ] && [ " $_COLORS " -gt 2 ] ; then
2013-02-11 20:22:33 +00:00
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
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-11 19:17:21 +00:00
# NAME: echoerr
# DESCRIPTION: Echo errors to stderr.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-11 19:17:21 +00:00
echoerror( ) {
2014-04-03 05:49:55 +01:00
printf " ${ RC } * ERROR ${ EC } : %s\n " " $@ " 1>& 2;
2013-02-11 19:17:21 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-11 19:17:21 +00:00
# NAME: echoinfo
# DESCRIPTION: Echo information to stdout.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-11 19:17:21 +00:00
echoinfo( ) {
2013-03-16 18:29:06 +00:00
printf " ${ GC } * INFO ${ EC } : %s\n " " $@ " ;
2013-02-11 19:17:21 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-20 12:09:35 +00:00
# NAME: echowarn
# DESCRIPTION: Echo warning informations to stdout.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-20 12:09:35 +00:00
echowarn( ) {
2013-03-16 18:29:06 +00:00
printf " ${ YC } * WARN ${ EC } : %s\n " " $@ " ;
2013-02-20 12:09:35 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-11 19:17:21 +00:00
# NAME: echodebug
# DESCRIPTION: Echo debug information to stdout.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-11 19:17:21 +00:00
echodebug( ) {
2014-06-21 18:58:16 +01:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
2013-03-16 18:29:06 +00:00
printf " ${ BC } * DEBUG ${ EC } : %s\n " " $@ " ;
2013-02-11 20:44:46 +00:00
fi
2013-02-11 19:17:21 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-04-23 10:38:42 +01:00
# NAME: check_pip_allowed
2013-02-27 17:12:45 +00:00
# DESCRIPTION: Simple function to let the users know that -P needs to be
# used.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-04-23 10:38:42 +01:00
check_pip_allowed( ) {
2014-02-16 14:31:33 +00:00
if [ $# -eq 1 ] ; then
2014-02-19 11:06:42 +00:00
_PIP_ALLOWED_ERROR_MSG = $1
2014-02-16 14:31:33 +00:00
else
_PIP_ALLOWED_ERROR_MSG = "pip based installations were not allowed. Retry using '-P'"
fi
2014-02-17 15:22:28 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_PIP_ALLOWED " -eq $BS_FALSE ] ; then
2014-02-19 11:06:42 +00:00
echoerror " $_PIP_ALLOWED_ERROR_MSG "
2013-04-23 10:38:42 +01:00
usage
exit 1
fi
2013-02-27 17:12:45 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2014-01-24 23:42:45 +00:00
# NAME: __check_config_dir
# DESCRIPTION: Checks the config directory, retrieves URLs if provided.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2014-01-24 23:42:45 +00:00
__check_config_dir( ) {
CC_DIR_NAME = " $1 "
CC_DIR_BASE = $( basename " ${ CC_DIR_NAME } " )
case " $CC_DIR_NAME " in
http://*| https://*)
__fetch_url " /tmp/ ${ CC_DIR_BASE } " " ${ CC_DIR_NAME } "
CC_DIR_NAME = " /tmp/ ${ CC_DIR_BASE } "
; ;
ftp://*)
__fetch_url " /tmp/ ${ CC_DIR_BASE } " " ${ CC_DIR_NAME } "
CC_DIR_NAME = " /tmp/ ${ CC_DIR_BASE } "
; ;
*)
if [ ! -e " ${ CC_DIR_NAME } " ] ; then
echo "null"
return 0
fi
; ;
esac
case " $CC_DIR_NAME " in
*.tgz| *.tar.gz)
tar -zxf " ${ CC_DIR_NAME } " -C /tmp
2014-06-21 18:58:16 +01:00
CC_DIR_BASE = $( basename " ${ CC_DIR_BASE } " ".tgz" )
CC_DIR_BASE = $( basename " ${ CC_DIR_BASE } " ".tar.gz" )
2014-01-24 23:42:45 +00:00
CC_DIR_NAME = " /tmp/ ${ CC_DIR_BASE } "
; ;
*.tbz| *.tar.bz2)
tar -xjf " ${ CC_DIR_NAME } " -C /tmp
2014-06-21 18:58:16 +01:00
CC_DIR_BASE = $( basename " ${ CC_DIR_BASE } " ".tbz" )
CC_DIR_BASE = $( basename " ${ CC_DIR_BASE } " ".tar.bz2" )
2014-01-24 23:42:45 +00:00
CC_DIR_NAME = " /tmp/ ${ CC_DIR_BASE } "
; ;
*.txz| *.tar.xz)
tar -xJf " ${ CC_DIR_NAME } " -C /tmp
2014-06-21 18:58:16 +01:00
CC_DIR_BASE = $( basename " ${ CC_DIR_BASE } " ".txz" )
CC_DIR_BASE = $( basename " ${ CC_DIR_BASE } " ".tar.xz" )
2014-01-24 23:42:45 +00:00
CC_DIR_NAME = " /tmp/ ${ CC_DIR_BASE } "
; ;
esac
echo " ${ CC_DIR_NAME } "
}
2014-08-21 00:52:23 +01:00
#----------------------------------------------------------------------------------------------------------------------
# Handle command line arguments
#----------------------------------------------------------------------------------------------------------------------
_KEEP_TEMP_FILES = ${ BS_KEEP_TEMP_FILES :- $BS_FALSE }
_TEMP_CONFIG_DIR = "null"
_SALTSTACK_REPO_URL = "git://github.com/saltstack/salt.git"
_SALT_REPO_URL = ${ _SALTSTACK_REPO_URL }
_TEMP_KEYS_DIR = "null"
_INSTALL_MASTER = $BS_FALSE
_INSTALL_SYNDIC = $BS_FALSE
_INSTALL_MINION = $BS_TRUE
_INSTALL_CLOUD = $BS_FALSE
_START_DAEMONS = $BS_TRUE
_ECHO_DEBUG = ${ BS_ECHO_DEBUG :- $BS_FALSE }
_CONFIG_ONLY = $BS_FALSE
_PIP_ALLOWED = ${ BS_PIP_ALLOWED :- $BS_FALSE }
_SALT_ETC_DIR = ${ BS_SALT_ETC_DIR :- /etc/salt }
_PKI_DIR = ${ _SALT_ETC_DIR } /pki
_FORCE_OVERWRITE = ${ BS_FORCE_OVERWRITE :- $BS_FALSE }
_GENTOO_USE_BINHOST = ${ BS_GENTOO_USE_BINHOST :- $BS_FALSE }
_EPEL_REPO = ${ BS_EPEL_REPO :- epel }
__EPEL_REPOS_INSTALLED = ${ BS_FALSE }
_UPGRADE_SYS = ${ BS_UPGRADE_SYS :- $BS_FALSE }
_INSECURE_DL = ${ BS_INSECURE_DL :- $BS_FALSE }
_WGET_ARGS = ${ BS_WGET_ARGS :- }
_CURL_ARGS = ${ BS_CURL_ARGS :- }
_FETCH_ARGS = ${ BS_FETCH_ARGS :- }
2014-10-20 20:44:16 +01:00
_ENABLE_EXTERNAL_ZMQ_REPOS = ${ BS_ENABLE_EXTERNAL_ZMQ_REPOS :- $BS_FALSE }
2014-08-21 00:52:23 +01:00
_SALT_MASTER_ADDRESS = ${ BS_SALT_MASTER_ADDRESS :- null }
_SALT_MINION_ID = "null"
# __SIMPLIFY_VERSION is mostly used in Solaris based distributions
__SIMPLIFY_VERSION = $BS_TRUE
_LIBCLOUD_MIN_VERSION = "0.14.0"
2015-05-07 09:42:36 +01:00
_PY_REQUESTS_MIN_VERSION = "2.0"
2014-08-21 00:52:23 +01:00
_EXTRA_PACKAGES = ""
_HTTP_PROXY = ""
2014-09-01 21:21:29 +10:00
_DISABLE_SALT_CHECKS = $BS_FALSE
2014-08-21 00:52:23 +01:00
__SALT_GIT_CHECKOUT_DIR = ${ BS_SALT_GIT_CHECKOUT_DIR :- /tmp/git/salt }
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-17 16:07:33 +01:00
# NAME: usage
# DESCRIPTION: Display usage information.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-17 16:07:33 +01:00
usage( ) {
cat << EOT
2013-08-22 20:50:48 +01:00
Usage : ${ __ScriptName } [ options] <install-type> <install-type-args>
2012-10-17 16:07:33 +01:00
Installation types:
- stable ( default)
2015-03-12 03:52:31 -07:00
- stable [ version] ( ubuntu specific)
2012-10-19 12:22:59 +01:00
- daily ( ubuntu specific)
2015-03-12 03:56:11 -07:00
- testing ( redhat specific)
2012-10-17 16:07:33 +01:00
- git
2012-10-19 12:22:59 +01:00
Examples:
2014-04-03 07:46:32 +01:00
- ${ __ScriptName }
- ${ __ScriptName } stable
2015-03-12 03:52:31 -07:00
- ${ __ScriptName } stable 2014.7
2014-04-03 07:46:32 +01:00
- ${ __ScriptName } daily
2015-03-12 03:56:11 -07:00
- ${ __ScriptName } testing
2014-04-03 07:46:32 +01:00
- ${ __ScriptName } git
- ${ __ScriptName } git develop
- ${ __ScriptName } git v0.17.0
- ${ __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-11-04 04:42:45 -03:00
-g Salt repository URL. ( default: git://github.com/saltstack/salt.git)
2014-11-16 20:39:45 -05:00
-G Instead of cloning from git://github.com/saltstack/salt.git, clone from https://github.com/saltstack/salt.git ( Usually necessary on systems which have the regular git protocol port blocked, where https usually is not)
2013-04-23 11:15:54 +01:00
-k Temporary directory holding the minion keys which will pre-seed
the master.
2014-07-20 22:51:56 +01:00
-s Sleep time used when waiting for daemons to start, restart and when checking
for the services running. Default: ${ __DEFAULT_SLEEP }
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-10-24 16:49:04 +02:00
-X Do not start daemons after installation
2013-07-08 14:46:06 +10:00
-C Only run the configuration function . This option automatically
2013-02-10 19:46:56 +00:00
bypasses any installation.
2013-02-27 17:12:45 +00:00
-P Allow pip based installations. On some distributions the required salt
2013-05-29 14:59:22 +01:00
packages or its dependencies are not available as a package for that
2013-02-27 17:12:45 +00:00
distribution. Using this flag allows the script to use pip as a last
2014-01-09 18:37:54 +00:00
resort method. NOTE: This only works for functions which actually
implement pip based installations.
2013-03-18 16:50:49 +00:00
-F Allow copied files to overwrite existing( config, init.d, etc)
2013-09-24 17:10:06 -07:00
-U If set, fully upgrade the system prior to bootstrapping salt
-K If set, keep the temporary files in the temporary directories specified
with -c and -k.
2014-01-22 23:14:38 +00:00
-I If set, allow insecure connections while downloading any files. For
example, pass '--no-check-certificate' to 'wget' or '--insecure' to 'curl'
2014-02-15 23:29:10 +00:00
-A Pass the salt-master DNS name or IP. This will be stored under
2014-08-21 00:58:16 +01:00
${ _SALT_ETC_DIR } /minion.d/99-master-address.conf
2014-03-21 13:52:54 +01:00
-i Pass the salt-minion id. This will be stored under
2014-08-21 00:58:16 +01:00
${ _SALT_ETC_DIR } /minion_id
2014-02-16 14:31:33 +00:00
-L Install the Apache Libcloud package if possible( required for salt-cloud)
2014-02-16 21:38:15 +00:00
-p Extra-package to install while installing salt dependencies. One package
per -p flag. You' re responsible for providing the proper package name.
2014-09-01 21:21:29 +10:00
-d Disable check_service functions. Setting this flag disables the
'install_<distro>_check_services' checks. You can also do this by
touching /tmp/disable_salt_checks on the target host. Defaults \$ { BS_FALSE}
2014-06-19 15:09:31 +02:00
-H Use the specified http proxy for the installation
2014-10-20 20:44:16 +01:00
-Z Enable external software source for newer ZeroMQ( Only available for RHEL/CentOS/Fedora based distributions)
2013-02-10 19:46:56 +00:00
2012-10-17 16:07:33 +01:00
EOT
} # ---------- end of function usage ----------
2013-05-15 10:44:07 +01:00
2014-09-01 21:21:29 +10:00
while getopts ":hvnDc:Gg:k:MSNXCPFUKIA:i:Lp:dH:Z" 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
2014-01-22 23:14:38 +00:00
v ) echo " $0 -- Version $__ScriptVersion " ; exit 0 ; ;
n ) _COLORS = 0; __detect_color_support ; ;
2013-08-22 20:50:48 +01:00
D ) _ECHO_DEBUG = $BS_TRUE ; ;
c ) _TEMP_CONFIG_DIR = $( __check_config_dir " $OPTARG " )
2013-02-11 22:11:00 +00:00
# If the configuration directory does not exist, error out
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2013-05-15 15:14:30 +01:00
echoerror " Unsupported URI scheme for $OPTARG "
exit 1
fi
2013-08-22 20:50:48 +01:00
if [ ! -d " $_TEMP_CONFIG_DIR " ] ; then
echoerror " The configuration directory ${ _TEMP_CONFIG_DIR } does not exist. "
2013-02-11 22:11:00 +00:00
exit 1
fi
; ;
2014-04-07 22:28:04 +01:00
g ) _SALT_REPO_URL = $OPTARG ; ;
2014-10-28 02:04:53 +00:00
G ) if [ " ${ _SALT_REPO_URL } " = " ${ _SALTSTACK_REPO_URL } " ] ; then
_SALTSTACK_REPO_URL = "https://github.com/saltstack/salt.git"
_SALT_REPO_URL = ${ _SALTSTACK_REPO_URL }
else
_SALTSTACK_REPO_URL = "https://github.com/saltstack/salt.git"
fi
2014-10-28 17:03:29 +01:00
; ;
2013-08-22 20:50:48 +01:00
k ) _TEMP_KEYS_DIR = " $OPTARG "
2013-04-23 11:15:54 +01:00
# If the configuration directory does not exist, error out
2013-08-22 20:50:48 +01:00
if [ ! -d " $_TEMP_KEYS_DIR " ] ; then
echoerror " The pre-seed keys directory ${ _TEMP_KEYS_DIR } does not exist. "
2013-04-23 11:15:54 +01:00
exit 1
fi
; ;
2013-08-22 20:50:48 +01:00
M ) _INSTALL_MASTER = $BS_TRUE ; ;
S ) _INSTALL_SYNDIC = $BS_TRUE ; ;
N ) _INSTALL_MINION = $BS_FALSE ; ;
2013-10-24 16:49:04 +02:00
X ) _START_DAEMONS = $BS_FALSE ; ;
2013-08-22 20:50:48 +01:00
C ) _CONFIG_ONLY = $BS_TRUE ; ;
P ) _PIP_ALLOWED = $BS_TRUE ; ;
F ) _FORCE_OVERWRITE = $BS_TRUE ; ;
U ) _UPGRADE_SYS = $BS_TRUE ; ;
2013-09-24 17:10:06 -07:00
K ) _KEEP_TEMP_FILES = $BS_TRUE ; ;
2014-01-22 23:14:38 +00:00
I ) _INSECURE_DL = $BS_TRUE ; ;
2014-02-15 23:29:10 +00:00
A ) _SALT_MASTER_ADDRESS = $OPTARG ; ;
2014-03-21 13:52:54 +01:00
i ) _SALT_MINION_ID = $OPTARG ; ;
2014-02-16 14:31:33 +00:00
L ) _INSTALL_CLOUD = $BS_TRUE ; ;
2014-02-16 21:38:15 +00:00
p ) _EXTRA_PACKAGES = " $_EXTRA_PACKAGES $OPTARG " ; ;
2014-09-01 21:21:29 +10:00
d ) _DISABLE_SALT_CHECKS = $BS_TRUE ; ;
2014-06-19 15:09:31 +02:00
H ) _HTTP_PROXY = " $OPTARG " ; ;
2014-10-20 20:44:16 +01:00
Z) _ENABLE_EXTERNAL_ZMQ_REPOS = $BS_TRUE ; ;
2014-02-16 14:31:33 +00:00
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
2014-04-03 05:29:00 +01:00
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 "
2013-05-18 15:36:53 +02:00
# grep alternative for SunOS
if [ -f /usr/xpg4/bin/grep ] ; then
grep = '/usr/xpg4/bin/grep'
else
grep = 'grep'
fi
2014-01-04 13:53:56 +00:00
unparsed_options = $( echo " $shellopts " | ${ grep } -E '(^|[[:space:]])[-]+[[:alnum:]]' )
2014-06-22 10:52:10 +01:00
if [ " $unparsed_options " != "" ] ; then
2012-11-29 01:27:43 +00:00
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
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_FALSE ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2013-03-06 23:10:51 +00:00
echowarn "Nothing to install or configure"
exit 0
2013-01-25 02:01:00 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_CONFIG_ONLY " -eq $BS_TRUE ] && [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2013-02-11 21:27:54 +00:00
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
2014-02-15 23:29:10 +00:00
# Check that we're installing a minion if we're being passed a master address
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_FALSE ] && [ " $_SALT_MASTER_ADDRESS " != "null" ] ; then
2014-03-21 13:51:27 +01:00
echoerror "Don't pass a master address (-A) if no minion is going to be bootstrapped."
2014-02-15 23:29:10 +00:00
exit 1
fi
2014-03-21 13:52:54 +01:00
# Check that we're installing a minion if we're being passed a master address
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_FALSE ] && [ " $_SALT_MINION_ID " != "null" ] ; then
2014-03-21 13:52:54 +01:00
echoerror "Don't pass a minion id (-i) if no minion is going to be bootstrapped."
2014-02-15 23:29:10 +00:00
exit 1
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
2014-06-22 10:40:05 +01:00
if [ " $( echo " $ITYPE " | egrep '(stable|testing|daily|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
2014-06-21 18:58:16 +01:00
if [ " $ITYPE " = "git" ] ; then
2012-10-19 12:22:59 +01:00
if [ " $# " -eq 0 ] ; then
2014-01-15 16:00:47 +00:00
GIT_REV = "develop"
2012-10-19 12:22:59 +01:00
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
2015-03-12 03:52:31 -07:00
# If doing stable install, check if version specified
elif [ " $ITYPE " = "stable" ] ; then
if [ " $# " -eq 0 ] ; then
STABLE_REV = "latest"
else
__check_unparsed_options " $* "
2015-07-22 12:10:41 +01:00
if [ " $( echo " $1 " | egrep '^(latest|1\.6|1\.7|2014\.1|2014\.7|2015\.5|2015\.8)$' ) " = "" ] ; then
echo " Unknown stable version: $1 (valid: 1.6, 1.7, 2014.1, 2014.7, 2015.5, 2015.8, latest) "
2015-03-12 03:52:31 -07:00
exit 1
2015-03-28 21:36:10 -07:00
else
STABLE_REV = " $1 "
shift
2015-03-12 03:52:31 -07:00
fi
fi
2012-10-19 12:22:59 +01:00
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-03-06 17:40:01 +00:00
exit 1
2012-10-19 12:22:59 +01:00
fi
2013-08-04 16:35:47 +01:00
2013-05-18 15:36:53 +02:00
# whoami alternative for SunOS
if [ -f /usr/xpg4/bin/id ] ; then
whoami = '/usr/xpg4/bin/id -un'
else
whoami = 'whoami'
fi
2013-08-04 16:35:47 +01:00
2012-10-17 14:02:09 +01:00
# Root permissions are required to run this script
2013-08-04 16:35:47 +01:00
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
2014-06-19 15:09:31 +02:00
# Export the http_proxy configuration to our current environment
2014-06-22 10:52:10 +01:00
if [ " ${ _HTTP_PROXY } " != "" ] ; then
2014-06-19 15:09:31 +02:00
export http_proxy = " $_HTTP_PROXY "
2014-06-19 20:56:42 +02:00
export https_proxy = " $_HTTP_PROXY "
2014-06-19 15:09:31 +02:00
fi
2013-08-04 16:35:47 +01:00
# Let's discover how we're being called
2014-05-09 19:24:00 +01:00
# shellcheck disable=SC2009
2014-05-06 07:45:08 +01:00
CALLER = $( ps -a -o pid,args | grep $$ | grep -v grep | tr -s ' ' | cut -d ' ' -f 3)
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-09-26 23:25:28 +01:00
2014-09-01 21:21:29 +10:00
# Work around for 'Docker + salt-bootstrap failure' https://github.com/saltstack/salt-bootstrap/issues/394
if [ ${ _DISABLE_SALT_CHECKS } -eq 0 ] ; then
[ -f /tmp/disable_salt_checks ] && _DISABLE_SALT_CHECKS = $BS_TRUE && \
echowarn "Found file: /tmp/disable_salt_checks, setting \$_DISABLE_SALT_CHECKS=true"
fi
2013-08-22 20:50:48 +01:00
echoinfo " ${ CALLER } ${ 0 } -- Version ${ __ScriptVersion } "
2014-08-03 21:58:59 +01:00
echowarn " Running the unstable version of ${ __ScriptName } "
2013-02-24 09:06:24 +00:00
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-23 04:16:03 +01:00
# 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
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-23 04:16:03 +01:00
__exit_cleanup( ) {
EXIT_CODE = $?
2014-08-14 03:37:14 +01:00
if [ " $ITYPE " = "git" ] && [ -d " ${ __SALT_GIT_CHECKOUT_DIR } " ] ; then
2014-01-24 23:09:57 +00:00
if [ $_KEEP_TEMP_FILES -eq $BS_FALSE ] ; then
2014-08-14 03:37:14 +01:00
# Clean up the checked out repository
2014-01-24 23:09:57 +00:00
echodebug "Cleaning up the Salt Temporary Git Repository"
2014-08-14 03:37:14 +01:00
rm -rf " ${ __SALT_GIT_CHECKOUT_DIR } "
2014-01-24 23:09:57 +00:00
else
2014-07-30 20:27:02 +01:00
echowarn "Not cleaning up the Salt Temporary git repository on request"
echowarn "Note that if you intend to re-run this script using the git approach, you might encounter some issues"
2014-01-24 23:09:57 +00:00
fi
fi
2012-10-23 04:16:03 +01:00
# Remove the logging pipe when the script exits
2013-02-11 19:17:21 +00:00
echodebug " Removing the logging pipe $LOGPIPE "
2014-06-21 18:58:16 +01:00
rm -f " $LOGPIPE "
2012-10-23 04:16:03 +01:00
# Kill tee when exiting, CentOS, at least requires this
2014-05-09 19:24:00 +01:00
# shellcheck disable=SC2009
2014-06-21 19:22:42 +01:00
TEE_PID = $( ps ax | grep tee | grep " $LOGFILE " | awk '{print $1}' )
2012-11-28 01:02:25 +00:00
2014-06-22 10:52:10 +01:00
[ " $TEE_PID " = "" ] && 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
2014-06-21 18:58:16 +01: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
2013-08-22 20:50:48 +01: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
2014-06-21 18:58:16 +01:00
mknod " $LOGPIPE " p >/dev/null 2>& 1 || mkfifo " $LOGPIPE " >/dev/null 2>& 1
2012-11-28 01:02:25 +00:00
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
2014-06-21 18:58:16 +01:00
tee < " $LOGPIPE " " $LOGFILE " &
2012-11-28 01:02:25 +00:00
# Close STDOUT, reopen it directing it to the logpipe
exec 1>& -
2014-06-21 18:58:16 +01:00
exec 1>" $LOGPIPE "
2012-11-28 01:02:25 +00:00
# Close STDERR, reopen it directing it to the logpipe
exec 2>& -
2014-06-21 18:58:16 +01:00
exec 2>" $LOGPIPE "
2012-11-28 01:02:25 +00:00
2014-01-22 23:14:38 +00:00
# Handle the insecure flags
2014-06-21 18:58:16 +01:00
if [ " $_INSECURE_DL " -eq $BS_TRUE ] ; then
2014-01-22 23:14:38 +00:00
_CURL_ARGS = " ${ _CURL_ARGS } --insecure "
_WGET_ARGS = " ${ _WGET_ARGS } --no-check-certificate "
2014-01-30 20:09:29 -07:00
_FETCH_ARGS = " ${ _FETCH_ARGS } --no-verify-peer "
2014-01-22 23:14:38 +00:00
fi
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2014-01-22 23:14:38 +00:00
# NAME: __fetch_url
# DESCRIPTION: Retrieves a URL and writes it to a given path
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2014-01-22 23:14:38 +00:00
__fetch_url( ) {
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-01-22 23:14:38 +00:00
curl $_CURL_ARGS -s -o " $1 " " $2 " >/dev/null 2>& 1 ||
wget $_WGET_ARGS -q -O " $1 " " $2 " >/dev/null 2>& 1 ||
2014-01-30 20:09:29 -07:00
fetch $_FETCH_ARGS -q -o " $1 " " $2 " >/dev/null 2>& 1 ||
fetch -q -o " $1 " " $2 " >/dev/null 2>& 1 # Pre FreeBSD 10
2014-01-22 23:14:38 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-21 16:04:57 +01:00
# NAME: __gather_hardware_info
# DESCRIPTION: Discover hardware information
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-21 16:04:57 +01:00
__gather_hardware_info( ) {
2012-11-28 01:21:44 +00:00
if [ -f /proc/cpuinfo ] ; then
2013-04-12 15:49:32 +01:00
CPU_VENDOR_ID = $( awk '/vendor_id|Processor/ {sub(/-.*$/,"",$3); print $3; exit}' /proc/cpuinfo )
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
2014-06-22 10:55:18 +01:00
# shellcheck disable=SC2034
2014-06-21 18:58:16 +01:00
CPU_VENDOR_ID_L = $( echo " $CPU_VENDOR_ID " | tr '[:upper:]' '[:lower:]' )
2012-10-21 16:04:57 +01:00
CPU_ARCH = $( uname -m 2>/dev/null || uname -p 2>/dev/null || echo "unknown" )
2014-06-21 18:58:16 +01:00
CPU_ARCH_L = $( echo " $CPU_ARCH " | tr '[:upper:]' '[:lower:]' )
2012-10-21 16:04:57 +01:00
}
__gather_hardware_info
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
# NAME: __gather_os_info
2012-10-18 22:30:20 +01:00
# DESCRIPTION: Discover operating system information
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
__gather_os_info( ) {
OS_NAME = $( uname -s 2>/dev/null)
2014-06-21 18:58:16 +01:00
OS_NAME_L = $( echo " $OS_NAME " | tr '[:upper:]' '[:lower:]' )
2012-10-18 22:18:07 +01:00
OS_VERSION = $( uname -r)
2014-06-22 10:55:18 +01:00
# shellcheck disable=SC2034
2014-06-21 18:58:16 +01:00
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
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-24 01:32:48 +01:00
# NAME: __parse_version_string
# DESCRIPTION: Parse version strings ignoring the revision.
# MAJOR.MINOR.REVISION becomes MAJOR.MINOR
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-24 01:32:48 +01:00
__parse_version_string( ) {
VERSION_STRING = " $1 "
PARSED_VERSION = $(
2014-06-21 19:13:43 +01:00
echo " $VERSION_STRING " |
2012-10-24 01:32:48 +01:00
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/^#.*$//'
)
2014-06-21 19:13:43 +01:00
echo " $PARSED_VERSION "
2012-10-24 01:32:48 +01:00
}
2014-12-06 14:51:07 -08:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __derive_debian_numeric_version
# DESCRIPTION: Derive the numeric version from a Debian version string.
#----------------------------------------------------------------------------------------------------------------------
__derive_debian_numeric_version( ) {
NUMERIC_VERSION = ""
INPUT_VERSION = " $1 "
if echo " $INPUT_VERSION " | grep -q '^[0-9]' ; then
NUMERIC_VERSION = " $INPUT_VERSION "
elif [ -z " $INPUT_VERSION " -a -f "/etc/debian_version" ] ; then
INPUT_VERSION = " $( cat /etc/debian_version) "
fi
if [ -z " $NUMERIC_VERSION " ] ; then
if [ " $INPUT_VERSION " = "wheezy/sid" ] ; then
# I've found an EC2 wheezy image which did not tell its version
NUMERIC_VERSION = $( __parse_version_string "7.0" )
elif [ " $INPUT_VERSION " = "jessie/sid" ] ; then
# Let's start detecting the upcoming Debian 8 (Jessie)
NUMERIC_VERSION = $( __parse_version_string "8.0" )
else
echowarn " Unable to parse the Debian Version (codename: ' $INPUT_VERSION ') "
fi
fi
echo " $NUMERIC_VERSION "
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-23 02:49:14 +00:00
# NAME: __unquote_string
# DESCRIPTION: Strip single or double quotes from the provided string.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-23 02:49:14 +00:00
__unquote_string( ) {
2014-04-04 13:28:27 +01:00
echo " ${ @ } " | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"
2013-02-23 02:49:14 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-23 18:30:51 +00:00
# NAME: __camelcase_split
# DESCRIPTION: Convert CamelCased strings to Camel_Cased
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-23 18:30:51 +00:00
__camelcase_split( ) {
2014-04-04 13:28:27 +01:00
echo " ${ @ } " | sed -r 's/([^A-Z-])([A-Z])/\1 \2/g'
2013-02-23 18:30:51 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-02-24 07:54:28 +00:00
# NAME: __strip_duplicates
# DESCRIPTION: Strip duplicate strings
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-24 07:54:28 +00:00
__strip_duplicates( ) {
2014-04-04 13:28:27 +01:00
echo " ${ @ } " | tr -s '[:space:]' '\n' | awk '!x[$0]++'
2013-02-24 07:54:28 +00:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
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
# NAME: __sort_release_files
# DESCRIPTION: Custom sort function. Alphabetical or numerical sort is not
# enough.
2014-02-17 15:21:29 +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
__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| \
2014-03-15 08:57:54 +00:00
oracle| 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
2014-04-04 13:28:27 +01:00
for release_file in $( echo " ${ @ } " | sed -r 's:[[:space:]]:\n:g' | sort --unique --ignore-case) ; do
2014-06-21 18:58:16 +01:00
match = $( echo " $release_file " | egrep -i " ${ KNOWN_RELEASE_FILES } " )
2014-06-22 10:52:10 +01:00
if [ " ${ match } " != "" ] ; 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
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
2014-07-20 23:12:50 +01:00
max_prio = "redhat-release centos-release oracle-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
for entry in $max_prio ; do
2014-06-22 10:40:05 +01:00
if [ " $( echo " ${ primary_release_files } " | grep " $entry " ) " != "" ] ; then
2014-06-21 18:58:16 +01:00
primary_release_files = $( echo " ${ primary_release_files } " | sed -e " s:\(.*\)\( $entry \)\(.*\):\2 \1 \3: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
fi
done
# Now, least important goes last in the min_prio list
min_prio = "lsb-release"
2014-04-26 20:15:35 +02:00
for entry in $min_prio ; do
2014-06-22 10:40:05 +01:00
if [ " $( echo " ${ primary_release_files } " | grep " $entry " ) " != "" ] ; then
2014-06-21 18:58:16 +01:00
primary_release_files = $( echo " ${ primary_release_files } " | sed -e " s:\(.*\)\( $entry \)\(.*\):\1 \3 \2: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
fi
done
# Echo the results collapsing multiple white-space into a single white-space
2014-07-20 23:18:14 +01:00
echo " ${ primary_release_files } ${ secondary_release_files } " | sed -r 's:[[:space:]]+:\n: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
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
# NAME: __gather_linux_system_info
2012-10-18 22:30:20 +01:00
# DESCRIPTION: Discover Linux system information
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
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)
2014-03-19 19:10:27 +00:00
if [ " ${ DISTRO_NAME } " = "Scientific" ] ; then
DISTRO_NAME = "Scientific Linux"
2014-06-22 10:52:10 +01:00
elif [ " $( echo " $DISTRO_NAME " | grep RedHat) " != "" ] ; then
2013-02-23 18:30:51 +00:00
# Let's convert CamelCase to Camel Case
DISTRO_NAME = $( __camelcase_split " $DISTRO_NAME " )
2014-03-19 19:10:27 +00:00
elif [ " ${ DISTRO_NAME } " = "openSUSE project" ] ; then
2013-04-23 10:38:02 +01:00
# lsb_release -si returns "openSUSE project" on openSUSE 12.3
2013-04-16 15:11:34 +02:00
DISTRO_NAME = "opensuse"
2014-03-19 19:10:27 +00:00
elif [ " ${ DISTRO_NAME } " = "SUSE LINUX" ] ; then
2014-07-22 13:56:47 +01:00
if [ " $( lsb_release -sd | grep -i opensuse) " != "" ] ; then
# openSUSE 12.2 reports SUSE LINUX on lsb_release -si
DISTRO_NAME = "opensuse"
else
# lsb_release -si returns "SUSE LINUX" on SLES 11 SP3
DISTRO_NAME = "suse"
fi
2014-04-15 23:45:28 +01:00
elif [ " ${ DISTRO_NAME } " = "EnterpriseEnterpriseServer" ] ; then
# This the Oracle Linux Enterprise ID before ORACLE LINUX 5 UPDATE 3
DISTRO_NAME = "Oracle Linux"
2014-06-21 13:11:21 +01:00
elif [ " ${ DISTRO_NAME } " = "OracleServer" ] ; then
# This the Oracle Linux Server 6.5
DISTRO_NAME = "Oracle Linux"
2014-06-29 00:31:15 +01:00
elif [ " ${ DISTRO_NAME } " = "AmazonAMI" ] ; then
DISTRO_NAME = "Amazon Linux AMI"
2014-08-29 20:24:40 +01:00
elif [ " ${ DISTRO_NAME } " = "Arch" ] ; then
DISTRO_NAME = "Arch Linux"
return
2013-07-09 21:47:45 +02:00
fi
2013-02-20 12:39:35 +00:00
rv = $( lsb_release -sr)
2014-06-22 10:52:10 +01:00
[ " ${ rv } " != "" ] && DISTRO_VERSION = $( __parse_version_string " $rv " )
2013-02-20 12:39:35 +00:00
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/.*=//' )
2014-06-22 10:52:10 +01:00
[ " ${ rv } " != "" ] && DISTRO_VERSION = $( __parse_version_string " $rv " )
2012-10-19 12:07:14 +01:00
fi
2014-06-22 10:52:10 +01:00
if [ " $DISTRO_NAME " != "" ] && [ " $DISTRO_VERSION " != "" ] ; then
2012-10-19 12:07:14 +01:00
# We already have the distribution name and version
return
fi
2014-06-29 00:35:40 +01:00
# shellcheck disable=SC2035,SC2086
2014-06-22 11:06:31 +01:00
for rsource in $( __sort_release_files " $(
2014-06-27 22:05:59 -05:00
cd /etc && /bin/ls *[ _-] release *[ _-] version 2>/dev/null | env -i sort | \
2012-10-18 22:27:38 +01:00
sed -e '/^redhat-release$/d' -e '/^lsb-release$/d' ; \
echo redhat-release lsb-release
2014-06-22 11:06:31 +01: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
2014-06-21 18:58:16 +01:00
n = $( echo " ${ rsource } " | sed -e 's/[_-]release$//' -e 's/[_-]version$//' )
2014-09-07 03:51:16 +01:00
shortname = $( echo " ${ n } " | tr '[:upper:]' '[:lower:]' )
2014-12-06 14:51:07 -08:00
if [ " $shortname " = "debian" ] ; then
2015-04-30 14:42:40 +01:00
rv = $( __derive_debian_numeric_version " $( cat /etc/${ rsource } ) " )
2014-12-06 14:51:07 -08:00
else
rv = $( ( grep VERSION " /etc/ ${ rsource } " ; cat " /etc/ ${ rsource } " ) | grep '[0-9]' | sed -e 'q' )
fi
2014-09-07 03:51:16 +01:00
[ " ${ rv } " = "" ] && [ " $shortname " != "arch" ] && continue # There's no version information. Continue to next rsource
2013-02-16 10:17:46 +00:00
v = $( __parse_version_string " $rv " )
2014-09-07 03:51:16 +01:00
case $shortname in
2013-02-23 02:49:14 +00:00
redhat )
2014-06-22 10:52:10 +01:00
if [ " $( egrep 'CentOS' /etc/${ rsource } ) " != "" ] ; then
2013-02-12 22:36:05 +00:00
n = "CentOS"
2014-06-22 10:52:10 +01:00
elif [ " $( egrep 'Scientific' /etc/${ rsource } ) " != "" ] ; then
2014-03-19 19:10:27 +00:00
n = "Scientific Linux"
2014-06-22 10:52:10 +01:00
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" ; ;
2014-03-15 08:57:54 +00:00
oracle ) n = "Oracle Linux" ; ;
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
2014-06-21 18:58:16 +01:00
done < " /etc/ ${ rsource } "
2013-01-30 13:06:11 +00:00
; ;
2013-02-19 21:15:14 +00:00
os )
2014-06-22 11:06:31 +01:00
nn = " $( __unquote_string " $( grep '^ID=' /etc/os-release | sed -e 's/^ID=\(.*\)$/\1/g' ) " ) "
rv = " $( __unquote_string " $( grep '^VERSION_ID=' /etc/os-release | sed -e 's/^VERSION_ID=\(.*\)$/\1/g' ) " ) "
2014-06-22 10:52:10 +01:00
[ " ${ rv } " != "" ] && v = $( __parse_version_string " $rv " ) || v = ""
2014-06-21 18:58:16 +01:00
case $( echo " ${ nn } " | tr '[:upper:]' '[:lower:]' ) in
2014-09-25 16:35:39 +01:00
amzn )
# Amazon AMI's after 2014.9 match here
n = "Amazon Linux AMI"
; ;
2013-03-23 10:58:19 +00:00
arch )
n = "Arch Linux"
v = "" # Arch Linux does not provide a version.
; ;
debian )
n = "Debian"
2014-12-06 14:51:07 -08:00
v = $( __derive_debian_numeric_version " $v " )
2013-03-23 10:58:19 +00:00
; ;
* )
n = ${ nn }
; ;
esac
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
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
# NAME: __gather_sunos_system_info
# DESCRIPTION: Discover SunOS system info
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
__gather_sunos_system_info( ) {
2013-01-27 22:54:21 +00:00
if [ -f /sbin/uname ] ; then
2013-03-21 03:02:51 -07:00
DISTRO_VERSION = $( /sbin/uname -X | awk '/[kK][eE][rR][nN][eE][lL][iI][dD]/ { print $3}' )
2013-01-27 22:54:21 +00:00
fi
DISTRO_NAME = ""
if [ -f /etc/release ] ; then
while read -r line; do
2014-06-22 10:52:10 +01:00
[ " ${ DISTRO_NAME } " != "" ] && break
2013-01-27 22:54:21 +00:00
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-06-05 10:25:12 +01:00
# Let's make sure we not actually on a Joyent's SmartOS VM since some releases
# don't have SmartOS in `/etc/release`, only `Solaris`
2014-04-03 05:46:11 +01:00
uname -v | grep joyent >/dev/null 2>& 1
2013-06-05 10:25:12 +01:00
if [ $? -eq 0 ] ; then
DISTRO_NAME = "SmartOS"
fi
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
; ;
2013-06-20 19:56:27 +01:00
*OmniOS*)
DISTRO_NAME = "OmniOS"
2013-06-20 20:16:04 +01:00
DISTRO_VERSION = $( echo " $line " | awk '{print $3}' )
2013-06-20 19:56:27 +01:00
__SIMPLIFY_VERSION = $BS_FALSE
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
2014-06-22 10:52:10 +01:00
if [ " ${ DISTRO_NAME } " = "" ] ; then
2013-01-27 22:54:21 +00:00
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
2013-05-14 23:42:39 +02:00
if [ " ${ DISTRO_NAME } " = "SmartOS" ] ; then
VIRTUAL_TYPE = "smartmachine"
if [ " $( zonename) " = "global" ] ; then
VIRTUAL_TYPE = "global"
fi
fi
2012-10-17 14:02:09 +01:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
# NAME: __gather_bsd_system_info
2012-10-18 22:30:20 +01:00
# DESCRIPTION: Discover OpenBSD, NetBSD and FreeBSD systems information
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
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
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
# NAME: __gather_system_info
2012-10-18 22:30:20 +01:00
# DESCRIPTION: Discover which system and distribution we are running.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
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
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-07-26 21:24:09 -04:00
# NAME: __ubuntu_derivatives_translation
# DESCRIPTION: Map Ubuntu derivatives to their Ubuntu base versions.
# If distro has a known Ubuntu base version, use those install
# functions by pretending to be Ubuntu (i.e. change global vars)
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2014-06-22 10:55:18 +01:00
# shellcheck disable=SC2034
2013-07-26 21:24:09 -04:00
__ubuntu_derivatives_translation( ) {
2014-04-15 12:44:28 -03:00
UBUNTU_DERIVATIVES = "(trisquel|linuxmint|linaro|elementary_os)"
2013-07-26 21:24:09 -04:00
# Mappings
trisquel_6_ubuntu_base = "12.04"
linuxmint_13_ubuntu_base = "12.04"
linuxmint_14_ubuntu_base = "12.10"
#linuxmint_15_ubuntu_base="13.04"
# Bug preventing add-apt-repository from working on Mint 15:
# https://bugs.launchpad.net/linuxmint/+bug/1198751
2013-12-22 20:28:56 +00:00
linuxmint_16_ubuntu_base = "13.10"
2014-09-25 20:16:28 -07:00
linuxmint_17_ubuntu_base = "14.04"
2013-08-02 12:29:20 -05:00
linaro_12_ubuntu_base = "12.04"
2014-04-15 12:44:28 -03:00
elementary_os_02_ubuntu_base = "12.04"
2013-07-26 21:24:09 -04:00
# Translate Ubuntu derivatives to their base Ubuntu version
2014-06-21 18:58:16 +01:00
match = $( echo " $DISTRO_NAME_L " | egrep ${ UBUNTU_DERIVATIVES } )
2014-04-15 12:44:28 -03:00
2014-06-22 10:52:10 +01:00
if [ " ${ match } " != "" ] ; then
2014-04-15 12:44:28 -03:00
case $match in
2014-05-25 01:27:47 +01:00
"elementary_os" )
2014-06-21 19:13:43 +01:00
_major = $( echo " $DISTRO_VERSION " | sed 's/\.//g' )
2014-05-25 01:27:47 +01:00
; ;
2015-04-04 15:44:43 +02:00
"linuxmint" )
export LSB_ETC_LSB_RELEASE = /etc/upstream-release/lsb-release
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
; ;
2014-05-25 01:27:47 +01:00
*)
2014-06-21 19:13:43 +01:00
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
2014-05-25 01:27:47 +01:00
; ;
esac
2014-06-22 12:18:39 +01:00
_ubuntu_version = $( eval echo " \$ ${ match } _ ${ _major } _ubuntu_base " )
2014-05-25 01:27:47 +01:00
2014-06-22 10:52:10 +01:00
if [ " $_ubuntu_version " != "" ] ; then
2013-07-26 21:24:09 -04:00
echodebug " Detected Ubuntu $_ubuntu_version derivative "
DISTRO_NAME_L = "ubuntu"
DISTRO_VERSION = " $_ubuntu_version "
fi
fi
}
2014-05-22 11:06:37 +03:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __debian_derivatives_translation
# DESCRIPTION: Map Debian derivatives to their Debian base versions.
# If distro has a known Debian base version, use those install
# functions by pretending to be Debian (i.e. change global vars)
#----------------------------------------------------------------------------------------------------------------------
2014-06-22 10:55:18 +01:00
# shellcheck disable=SC2034
2014-05-22 11:06:37 +03:00
__debian_derivatives_translation( ) {
2014-06-06 08:44:48 +01:00
# If the file does not exist, return
[ ! -f /etc/os-release ] && return
2014-10-28 17:28:45 +01:00
DEBIAN_DERIVATIVES = "(kali|linuxmint)"
2014-05-22 11:06:37 +03:00
# Mappings
kali_1_debian_base = "7.0"
2014-10-28 17:28:45 +01:00
linuxmint_1_debian_base = "8.0"
2014-05-22 11:06:37 +03:00
2014-10-28 17:28:45 +01:00
# Detect derivates, Kali and LinuxMint *only* for now
2014-05-22 11:06:37 +03:00
rv = $( grep ^ID= /etc/os-release | sed -e 's/.*=//' )
# Translate Debian derivatives to their base Debian version
2014-06-21 19:14:28 +01:00
match = $( echo " $rv " | egrep ${ DEBIAN_DERIVATIVES } )
2014-05-22 11:06:37 +03:00
2014-06-22 10:52:10 +01:00
if [ " ${ match } " != "" ] ; then
2014-05-22 11:06:37 +03:00
case $match in
2014-05-25 01:27:47 +01:00
kali)
2014-06-21 19:14:28 +01:00
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
2014-05-25 01:27:47 +01:00
_debian_derivative = "kali"
; ;
2014-10-28 17:28:45 +01:00
linuxmint)
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
_debian_derivative = "linuxmint"
; ;
2014-05-25 01:27:47 +01:00
esac
2014-06-21 19:14:40 +01:00
_debian_version = $( eval echo " \$ ${ _debian_derivative } _ ${ _major } _debian_base " )
2014-05-25 01:27:47 +01:00
2014-06-22 10:52:10 +01:00
if [ " $_debian_version " != "" ] ; then
2014-05-22 11:06:37 +03:00
echodebug " Detected Debian $_debian_version derivative "
DISTRO_NAME_L = "debian"
DISTRO_VERSION = " $_debian_version "
fi
fi
}
2013-07-26 21:24:09 -04:00
__gather_system_info
2013-01-18 01:19:18 +00:00
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
2014-08-03 21:41:57 +01:00
echodebug " Binaries will be searched using the following \$PATH: ${ PATH } "
2014-06-19 15:09:31 +02:00
# Let users know that we'll use a proxy
2014-06-22 10:52:10 +01:00
if [ " ${ _HTTP_PROXY } " != "" ] ; then
2014-06-19 15:09:31 +02:00
echoinfo " Using http proxy $_HTTP_PROXY "
fi
2013-02-11 21:58:59 +00:00
# Let users know what's going to be installed/configured
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
if [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2013-02-11 21:58:59 +00:00
echoinfo "Installing minion"
else
echoinfo "Configuring minion"
fi
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
if [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2013-02-11 21:58:59 +00:00
echoinfo "Installing master"
else
echoinfo "Configuring master"
fi
fi
2013-01-18 01:19:18 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
if [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2013-02-11 21:58:59 +00:00
echoinfo "Installing syndic"
else
echoinfo "Configuring syndic"
fi
fi
2013-01-18 01:19:18 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2014-02-18 12:07:21 +00:00
echoinfo "Installing Apache-Libcloud required for salt-cloud"
2014-02-16 14:31:33 +00:00
fi
2013-10-24 16:49:04 +02:00
if [ $_START_DAEMONS -eq $BS_FALSE ] ; then
echoinfo "Daemons will not be started"
fi
2013-07-26 21:24:09 -04:00
# Simplify distro name naming on functions
2014-06-21 18:58:16 +01:00
DISTRO_NAME_L = $( echo " $DISTRO_NAME " | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -re 's/([[:space:]])+/_/g' )
2013-07-26 21:24:09 -04:00
# For Ubuntu derivatives, pretend to be their Ubuntu base version
2014-05-25 01:29:43 +01:00
__ubuntu_derivatives_translation
2013-07-26 21:24:09 -04:00
2014-05-22 11:06:37 +03:00
# For Debian derivates, pretend to be their Debian base version
__debian_derivatives_translation
2013-07-26 21:24:09 -04:00
2013-01-18 01:19:18 +00:00
# Simplify version naming on functions
2014-06-22 10:52:10 +01:00
if [ " ${ DISTRO_VERSION } " = "" ] || [ $__SIMPLIFY_VERSION -eq $BS_FALSE ] ; 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
2014-06-21 18:58:16 +01:00
DISTRO_MAJOR_VERSION = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
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
# Only Ubuntu has daily packages, let's let users know about that
2014-06-21 18:58:16 +01:00
if ( [ " ${ DISTRO_NAME_L } " != "ubuntu" ] && [ " $ITYPE " = "daily" ] ) ; then
2013-03-17 23:02:23 +00:00
echoerror " ${ DISTRO_NAME } does not have daily packages support "
2013-01-18 01:19:18 +00:00
exit 1
2015-06-08 11:23:17 +02:00
elif ( [ " ${ DISTRO_NAME_L } " != "ubuntu" ] && [ " $ITYPE " = "stable" ] && [ " $STABLE_REV " != "latest" ] ) ; then
2015-03-28 21:38:55 -07:00
echoerror " ${ DISTRO_NAME } does not have major version pegged packages support "
2015-03-12 03:52:31 -07:00
exit 1
2013-01-18 01:19:18 +00:00
fi
2012-10-17 14:02:09 +01:00
2013-08-04 16:35:47 +01:00
# Only RedHat based distros have testing support
2014-06-21 18:58:16 +01:00
if [ " ${ ITYPE } " = "testing" ] ; then
2014-06-22 10:52:10 +01:00
if [ " $( echo " ${ DISTRO_NAME_L } " | egrep '(centos|red_hat|amazon|oracle)' ) " = "" ] ; then
2013-08-04 16:35:47 +01:00
echoerror " ${ DISTRO_NAME } does not have testing packages support "
exit 1
fi
2013-08-22 20:50:48 +01:00
_EPEL_REPO = "epel-testing"
2013-08-04 16:35:47 +01:00
fi
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
# 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
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-18 22:18:07 +01:00
__function_defined( ) {
FUNC_NAME = $1
2014-06-22 10:40:05 +01:00
if [ " $( command -v " $FUNC_NAME " ) " != "" ] ; 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
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2012-10-27 07:31:14 +01:00
# NAME: __git_clone_and_checkout
# DESCRIPTION: (DRY) Helper function to clone and checkout salt to a
# specific revision.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2012-10-27 07:31:14 +01:00
__git_clone_and_checkout( ) {
2014-08-04 15:42:36 +01:00
echodebug " Installed git version: $( git --version | awk '{ print $3 }' ) "
2015-04-30 14:42:40 +01:00
__SALT_GIT_CHECKOUT_PARENT_DIR = $( dirname " ${ __SALT_GIT_CHECKOUT_DIR } " 2>/dev/null)
2014-10-16 14:45:50 +08:00
__SALT_GIT_CHECKOUT_PARENT_DIR = " ${ __SALT_GIT_CHECKOUT_PARENT_DIR :- /tmp/git } "
2015-04-30 14:42:40 +01:00
__SALT_CHECKOUT_REPONAME = " $( basename " ${ __SALT_GIT_CHECKOUT_DIR } " 2>/dev/null) "
2014-10-28 17:03:29 +01:00
__SALT_CHECKOUT_REPONAME = " ${ __SALT_CHECKOUT_REPONAME :- salt } "
2014-08-14 03:37:14 +01:00
[ -d " ${ __SALT_GIT_CHECKOUT_PARENT_DIR } " ] || mkdir " ${ __SALT_GIT_CHECKOUT_PARENT_DIR } "
cd " ${ __SALT_GIT_CHECKOUT_PARENT_DIR } "
2014-08-17 00:58:55 +01:00
if [ -d " ${ __SALT_GIT_CHECKOUT_DIR } " ] ; then
2014-07-29 13:11:35 +01:00
echodebug "Found a checked out Salt repository"
2014-08-17 00:58:55 +01:00
cd " ${ __SALT_GIT_CHECKOUT_DIR } "
2014-07-29 13:11:35 +01:00
echodebug "Fetching git changes"
2013-03-06 22:05:31 +00:00
git fetch || return 1
2013-03-11 01:05:02 +00:00
# Tags are needed because of salt's versioning, also fetch that
2014-07-29 13:11:35 +01:00
echodebug "Fetching git tags"
2013-03-11 01:05:02 +00:00
git fetch --tags || return 1
2014-04-07 22:28:04 +01:00
# If we have the SaltStack remote set as upstream, we also need to fetch the tags from there
2014-06-22 10:52:10 +01:00
if [ " $( git remote -v | grep $_SALTSTACK_REPO_URL ) " != "" ] ; then
2014-07-29 13:11:35 +01:00
echodebug "Fetching upstream(SaltStack's Salt repository) git tags"
2014-04-07 22:28:04 +01:00
git fetch --tags upstream
else
2014-07-29 13:11:35 +01:00
echoinfo "Adding SaltStack's Salt repository as a remote"
2014-06-21 18:58:16 +01:00
git remote add upstream " $_SALTSTACK_REPO_URL "
2014-07-29 13:11:35 +01:00
echodebug "Fetching upstream(SaltStack's Salt repository) git tags"
2014-04-07 22:28:04 +01:00
git fetch --tags upstream
fi
2014-07-29 13:11:35 +01:00
echodebug " Hard reseting the cloned repository to ${ GIT_REV } "
2014-06-21 18:58:16 +01:00
git reset --hard " $GIT_REV " || return 1
2013-03-08 11:18:14 -08:00
# Just calling `git reset --hard $GIT_REV` on a branch name that has
# already been checked out will not update that branch to the upstream
# HEAD; instead it will simply reset to itself. Check the ref to see
# if it is a branch name, check out the branch, and pull in the
# changes.
2014-06-21 18:58:16 +01:00
git branch -a | grep -q " ${ GIT_REV } "
2013-03-11 01:05:02 +00:00
if [ $? -eq 0 ] ; then
2014-07-29 13:11:35 +01:00
echodebug "Rebasing the cloned repository branch"
2013-03-11 01:05:02 +00:00
git pull --rebase || return 1
fi
2013-03-01 00:05:57 -08:00
else
2014-08-04 15:42:36 +01:00
__SHALLOW_CLONE = " ${ BS_FALSE } "
2014-10-02 22:20:15 +01:00
if [ " $( echo " $GIT_REV " | sed 's/^.*\(v[[:digit:]]\{1,4\}\.[[:digit:]]\{1,2\}\)\(\.[[:digit:]]\{1,2\}\)\?.*$/MATCH/' ) " = "MATCH" ] ; then
2014-08-17 00:58:55 +01:00
echoinfo "Git revision matches a Salt version tag"
# Let's try shallow cloning to speed up.
# Test for "--single-branch" option introduced in git 1.7.10, the minimal version of git where the shallow
# cloning we need actually works
if [ " $( git clone --help | grep 'single-branch' ) " != "" ] ; then
# The "--single-branch" option is supported, attempt shallow cloning
echoinfo " Attempting to shallow clone $GIT_REV from Salt's repository ${ _SALT_REPO_URL } "
2014-10-16 14:45:50 +08:00
git clone --depth 1 --branch " $GIT_REV " " $_SALT_REPO_URL " " $__SALT_CHECKOUT_REPONAME "
2014-08-17 00:58:55 +01:00
if [ $? -eq 0 ] ; then
cd " ${ __SALT_GIT_CHECKOUT_DIR } "
__SHALLOW_CLONE = " ${ BS_TRUE } "
else
# Shallow clone above failed(missing upstream tags???), let's resume the old behaviour.
echowarn "Failed to shallow clone."
echoinfo "Resuming regular git clone and remote SaltStack repository addition procedure"
2014-10-16 14:45:50 +08:00
git clone " $_SALT_REPO_URL " " $__SALT_CHECKOUT_REPONAME " || return 1
2014-08-17 00:58:55 +01:00
cd " ${ __SALT_GIT_CHECKOUT_DIR } "
fi
2014-08-04 16:14:48 +01:00
else
2014-08-17 00:58:55 +01:00
echodebug "Shallow cloning not possible. Required git version not met."
2014-10-16 14:45:50 +08:00
git clone " $_SALT_REPO_URL " " $__SALT_CHECKOUT_REPONAME " || return 1
2014-08-17 00:58:55 +01:00
cd " ${ __SALT_GIT_CHECKOUT_DIR } "
2014-08-04 16:14:48 +01:00
fi
2014-08-04 15:42:36 +01:00
else
2014-08-17 00:58:55 +01:00
echowarn "The git revision being installed does not match a Salt version tag. Shallow cloning disabled"
2014-10-16 14:45:50 +08:00
git clone " $_SALT_REPO_URL " " $__SALT_CHECKOUT_REPONAME " || return 1
2014-08-17 00:58:55 +01:00
cd " ${ __SALT_GIT_CHECKOUT_DIR } "
2014-07-29 13:11:35 +01:00
fi
2015-04-01 02:30:12 +02:00
if [ " $( echo " $_SALT_REPO_URL " | grep -c -e '\(\(git\|https\)://github\.com/\|git@github\.com:\)saltstack/salt\.git' ) " -eq 0 ] ; then
2014-04-07 22:28:04 +01:00
# We need to add the saltstack repository as a remote and fetch tags for proper versioning
2014-07-29 13:11:35 +01:00
echoinfo "Adding SaltStack's Salt repository as a remote"
2014-08-19 19:13:58 +01:00
git remote add upstream " $_SALTSTACK_REPO_URL " || return 1
2014-07-29 13:11:35 +01:00
echodebug "Fetching upstream(SaltStack's Salt repository) git tags"
2014-08-19 19:13:58 +01:00
git fetch --tags upstream || return 1
2014-04-07 22:28:04 +01:00
fi
2014-08-04 15:42:36 +01:00
if [ " $__SHALLOW_CLONE " -eq " ${ BS_FALSE } " ] ; then
echodebug " Checking out $GIT_REV "
git checkout " $GIT_REV " || return 1
fi
2014-04-07 22:28:04 +01:00
2013-03-01 00:05:57 -08:00
fi
2014-07-29 13:11:35 +01:00
echoinfo "Cloning Salt's git repository succeeded"
2013-03-06 22:05:31 +00:00
return 0
2012-10-27 07:31:14 +01:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-09-25 17:32:59 +01:00
# NAME: __apt_get_install_noinput
2012-10-31 19:10:54 -07:00
# DESCRIPTION: (DRY) apt-get install with noinput options
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput( ) {
2014-04-04 13:28:27 +01:00
apt-get install -y -o DPkg::Options::= --force-confold " ${ @ } " ; return $?
2012-10-31 19:10:54 -07:00
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-09-25 17:35:06 +01:00
# NAME: __apt_get_upgrade_noinput
# DESCRIPTION: (DRY) apt-get upgrade with noinput options
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput( ) {
2014-04-03 05:42:25 +01:00
apt-get upgrade -y -o DPkg::Options::= --force-confold; return $?
2013-09-25 17:35:06 +01:00
}
2013-09-25 17:32:59 +01:00
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-09-25 21:52:37 +01:00
# NAME: __check_end_of_life_versions
# DESCRIPTION: Check for end of life distribution versions
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-09-25 21:32:20 +01:00
__check_end_of_life_versions( ) {
2013-09-25 21:52:37 +01:00
case " ${ DISTRO_NAME_L } " in
2013-09-26 11:19:24 +01:00
debian)
# Debian versions bellow 6 are not supported
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -lt 6 ] ; then
2013-09-26 11:19:24 +01:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://wiki.debian.org/DebianReleases"
exit 1
fi
; ;
2013-09-26 11:28:35 +01:00
2013-09-25 21:52:37 +01:00
ubuntu)
2013-09-26 11:04:47 +01:00
# Ubuntu versions not supported
#
# < 10
# = 10.10
# = 11.04
# = 11.10
2014-06-21 18:58:16 +01:00
if ( [ " $DISTRO_MAJOR_VERSION " -eq 10 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ) || \
( [ " $DISTRO_MAJOR_VERSION " -eq 11 ] && [ " $DISTRO_MINOR_VERSION " -eq 04 ] ) || \
( [ " $DISTRO_MAJOR_VERSION " -eq 11 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ) || \
[ " $DISTRO_MAJOR_VERSION " -lt 10 ] ; then
2013-09-25 21:32:20 +01:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://wiki.ubuntu.com/Releases"
exit 1
2013-09-25 21:52:37 +01:00
fi
; ;
2013-09-25 21:32:20 +01:00
2013-09-25 21:52:37 +01:00
opensuse)
2013-09-26 11:04:47 +01:00
# openSUSE versions not supported
#
2013-09-26 19:57:31 +01:00
# <= 12.1
2014-06-21 18:58:16 +01:00
if ( [ " $DISTRO_MAJOR_VERSION " -eq 12 ] && [ " $DISTRO_MINOR_VERSION " -eq 1 ] ) || [ " $DISTRO_MAJOR_VERSION " -lt 12 ] ; then
2013-09-25 21:52:37 +01:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " http://en.opensuse.org/Lifetime"
exit 1
fi
; ;
2013-09-26 10:59:08 +01:00
suse)
2013-09-26 11:04:47 +01:00
# SuSE versions not supported
#
# < 11 SP2
2013-09-26 10:59:08 +01:00
SUSE_PATCHLEVEL = $( awk '/PATCHLEVEL/ {print $3}' /etc/SuSE-release )
2014-06-22 10:52:10 +01:00
if [ " ${ SUSE_PATCHLEVEL } " = "" ] ; then
2013-09-26 10:59:08 +01:00
SUSE_PATCHLEVEL = "00"
fi
2014-06-21 18:58:16 +01:00
if ( [ " $DISTRO_MAJOR_VERSION " -eq 11 ] && [ " $SUSE_PATCHLEVEL " -lt 02 ] ) || [ " $DISTRO_MAJOR_VERSION " -lt 11 ] ; then
2013-09-26 10:59:08 +01:00
echoerror "Versions lower than SuSE 11 SP2 are not supported."
echoerror "Please consider upgrading to the next stable"
exit 1
fi
2013-09-26 11:28:35 +01:00
; ;
2013-09-26 10:59:08 +01:00
2013-09-26 11:29:59 +01:00
fedora)
# Fedora lower than 18 are no longer supported
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -lt 18 ] ; then
2013-09-26 11:29:59 +01:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://fedoraproject.org/wiki/Releases"
exit 1
fi
; ;
2013-09-26 16:41:04 +01:00
centos)
# CentOS versions lower than 5 are no longer supported
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -lt 5 ] ; then
2013-09-26 16:41:04 +01:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " http://wiki.centos.org/Download"
exit 1
fi
; ;
2013-09-26 16:49:42 +01:00
red_hat*linux)
# Red Hat (Enterprise) Linux versions lower than 5 are no longer supported
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -lt 5 ] ; then
2013-09-26 16:49:42 +01:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://access.redhat.com/support/policy/updates/errata/"
exit 1
fi
; ;
2013-09-26 16:55:38 +01:00
freebsd)
# FreeBSD versions lower than 9.1 are not supported.
2014-06-21 18:58:16 +01:00
if ( [ " $DISTRO_MAJOR_VERSION " -eq 9 ] && [ " $DISTRO_MINOR_VERSION " -lt 01 ] ) || [ " $DISTRO_MAJOR_VERSION " -lt 9 ] ; then
2013-09-26 16:55:38 +01:00
echoerror "Versions lower than FreeBSD 9.1 are not supported."
exit 1
fi
; ;
2013-09-25 21:52:37 +01:00
*)
; ;
esac
}
2013-09-25 21:32:20 +01:00
# Fail soon for end of life versions
__check_end_of_life_versions
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-03-18 16:50:49 +00:00
# NAME: copyfile
# DESCRIPTION: Simple function to copy files. Overrides if asked.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-03-18 16:50:49 +00:00
copyfile( ) {
2013-08-22 20:50:48 +01:00
overwrite = $_FORCE_OVERWRITE
2013-03-18 16:50:49 +00:00
if [ $# -eq 2 ] ; then
sfile = $1
dfile = $2
elif [ $# -eq 3 ] ; then
sfile = $1
dfile = $2
overwrite = $3
else
echoerror "Wrong number of arguments for copyfile()"
echoinfo "USAGE: copyfile <source> <dest> OR copyfile <source> <dest> <overwrite>"
exit 1
fi
# Does the source file exist?
if [ ! -f " $sfile " ] ; then
echowarn " $sfile does not exist! "
return 1
fi
2014-02-16 19:19:39 +00:00
# If the destination is a directory, let's make it a full path so the logic
# below works as expected
if [ -d " $dfile " ] ; then
echodebug " The passed destination( $dfile ) is a directory "
2014-06-22 10:40:05 +01:00
dfile = " ${ dfile } / $( basename " $sfile " ) "
2014-02-16 19:19:39 +00:00
echodebug " Full destination path is now: $dfile "
fi
2013-03-18 16:50:49 +00:00
if [ ! -f " $dfile " ] ; then
# The destination file does not exist, copy
echodebug " Copying $sfile to $dfile "
2013-04-23 11:15:54 +01:00
cp " $sfile " " $dfile " || return 1
2014-06-21 18:58:16 +01:00
elif [ -f " $dfile " ] && [ " $overwrite " -eq $BS_TRUE ] ; then
2013-03-18 16:50:49 +00:00
# The destination exist and we're overwriting
echodebug " Overriding $dfile with $sfile "
2013-08-16 21:25:01 +01:00
cp -f " $sfile " " $dfile " || return 1
2014-06-21 18:58:16 +01:00
elif [ -f " $dfile " ] && [ " $overwrite " -ne $BS_TRUE ] ; then
2013-03-18 16:50:49 +00:00
echodebug " Not overriding $dfile with $sfile "
fi
return 0
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2013-04-23 11:15:54 +01:00
# NAME: movefile
# DESCRIPTION: Simple function to move files. Overrides if asked.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-04-23 11:15:54 +01:00
movefile( ) {
2013-08-22 20:50:48 +01:00
overwrite = $_FORCE_OVERWRITE
2013-04-23 11:15:54 +01:00
if [ $# -eq 2 ] ; then
sfile = $1
dfile = $2
elif [ $# -eq 3 ] ; then
sfile = $1
dfile = $2
overwrite = $3
else
echoerror "Wrong number of arguments for movefile()"
echoinfo "USAGE: movefile <source> <dest> OR movefile <source> <dest> <overwrite>"
exit 1
fi
2013-08-22 20:50:48 +01:00
if [ $_KEEP_TEMP_FILES -eq $BS_TRUE ] ; then
2013-07-16 20:31:34 +01:00
# We're being told not to move files, instead copy them so we can keep
# them around
echodebug "Since BS_KEEP_TEMP_FILES=1 we're copying files instead of moving them"
2014-06-21 18:58:16 +01:00
copyfile " $sfile " " $dfile " " $overwrite "
2013-08-16 21:25:01 +01:00
return $?
2013-07-16 20:31:34 +01:00
fi
2013-04-23 11:15:54 +01:00
# Does the source file exist?
if [ ! -f " $sfile " ] ; then
echowarn " $sfile does not exist! "
return 1
fi
2014-02-16 19:19:39 +00:00
# If the destination is a directory, let's make it a full path so the logic
# below works as expected
if [ -d " $dfile " ] ; then
echodebug " The passed destination( $dfile ) is a directory "
2014-06-22 10:40:05 +01:00
dfile = " ${ dfile } / $( basename " $sfile " ) "
2014-02-16 19:19:39 +00:00
echodebug " Full destination path is now: $dfile "
fi
2013-04-23 11:15:54 +01:00
if [ ! -f " $dfile " ] ; then
# The destination file does not exist, copy
echodebug " Moving $sfile to $dfile "
mv " $sfile " " $dfile " || return 1
2014-06-21 18:58:16 +01:00
elif [ -f " $dfile " ] && [ " $overwrite " -eq $BS_TRUE ] ; then
2013-04-23 11:15:54 +01:00
# The destination exist and we're overwriting
echodebug " Overriding $dfile with $sfile "
mv -f " $sfile " " $dfile " || return 1
2014-06-21 18:58:16 +01:00
elif [ -f " $dfile " ] && [ " $overwrite " -ne $BS_TRUE ] ; then
2013-04-23 11:15:54 +01:00
echodebug " Not overriding $dfile with $sfile "
fi
return 0
}
2014-02-20 10:57:04 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_services_systemd
# DESCRIPTION: Return 0 or 1 in case the service is enabled or not
# PARAMETERS: servicename
#----------------------------------------------------------------------------------------------------------------------
__check_services_systemd( ) {
2014-02-20 11:44:01 +00:00
if [ $# -eq 0 ] ; then
echoerror "You need to pass a service name to check!"
exit 1
2014-02-20 11:48:20 +00:00
elif [ $# -ne 1 ] ; then
2014-02-20 11:44:01 +00:00
echoerror "You need to pass a service name to check as the single argument to the function"
fi
2014-02-20 11:54:03 +00:00
2014-02-20 11:48:20 +00:00
servicename = $1
2014-02-20 11:57:51 +00:00
echodebug " Checking if service ${ servicename } is enabled "
2014-02-20 11:54:03 +00:00
2014-06-22 10:40:05 +01:00
if [ " $( systemctl is-enabled " ${ servicename } " ) " = "enabled" ] ; then
2014-02-20 11:57:51 +00:00
echodebug " Service ${ servicename } is enabled "
2014-02-20 10:57:04 +00:00
return 0
else
2014-02-20 11:57:51 +00:00
echodebug " Service ${ servicename } is NOT enabled "
2014-02-20 10:57:04 +00:00
return 1
fi
} # ---------- end of function __check_services_systemd ----------
2014-02-20 12:57:37 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_services_upstart
# DESCRIPTION: Return 0 or 1 in case the service is enabled or not
# PARAMETERS: servicename
#----------------------------------------------------------------------------------------------------------------------
__check_services_upstart( ) {
if [ $# -eq 0 ] ; then
echoerror "You need to pass a service name to check!"
exit 1
elif [ $# -ne 1 ] ; then
echoerror "You need to pass a service name to check as the single argument to the function"
fi
servicename = $1
echodebug " Checking if service ${ servicename } is enabled "
# Check if service is enabled to start at boot
2014-06-21 18:58:16 +01:00
initctl list | grep " ${ servicename } " > /dev/null 2>& 1
2014-02-20 12:57:37 +00:00
if [ $? -eq 0 ] ; then
echodebug " Service ${ servicename } is enabled "
return 0
else
echodebug " Service ${ servicename } is NOT enabled "
return 1
fi
} # ---------- end of function __check_services_upstart ----------
2014-03-10 11:46:14 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_services_sysvinit
# DESCRIPTION: Return 0 or 1 in case the service is enabled or not
# PARAMETERS: servicename
#----------------------------------------------------------------------------------------------------------------------
__check_services_sysvinit( ) {
if [ $# -eq 0 ] ; then
echoerror "You need to pass a service name to check!"
exit 1
elif [ $# -ne 1 ] ; then
echoerror "You need to pass a service name to check as the single argument to the function"
fi
servicename = $1
echodebug " Checking if service ${ servicename } is enabled "
2015-03-20 21:49:31 +01:00
if [ " $( LC_ALL = C /sbin/chkconfig --list | grep salt-" $fname " | grep '[2-5]:on' ) " != "" ] ; then
2014-03-10 11:46:14 +00:00
echodebug " Service ${ servicename } is enabled "
return 0
else
echodebug " Service ${ servicename } is NOT enabled "
return 1
fi
} # ---------- end of function __check_services_sysvinit ----------
2014-03-10 12:11:20 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_services_debian
# DESCRIPTION: Return 0 or 1 in case the service is enabled or not
# PARAMETERS: servicename
#----------------------------------------------------------------------------------------------------------------------
__check_services_debian( ) {
if [ $# -eq 0 ] ; then
echoerror "You need to pass a service name to check!"
exit 1
elif [ $# -ne 1 ] ; then
echoerror "You need to pass a service name to check as the single argument to the function"
fi
servicename = $1
echodebug " Checking if service ${ servicename } is enabled "
2014-10-21 01:24:36 +01:00
# shellcheck disable=SC2086,SC2046,SC2144
2014-03-10 13:52:27 +00:00
if [ -f /etc/rc$( runlevel | awk '{ print $2 }' ) .d/S*${ servicename } ] ; then
2014-03-10 12:11:20 +00:00
echodebug " Service ${ servicename } is enabled "
return 0
else
echodebug " Service ${ servicename } is NOT enabled "
return 1
fi
} # ---------- end of function __check_services_debian ----------
2014-02-20 10:36:34 +00: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
2013-04-23 11:15:54 +01: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-04-23 11:15:54 +01:00
# Optionally, define a salt master pre-seed function, which will be called if
# the -k (pre-seed master keys) option is passed. One of:
2013-10-24 16:49:04 +02:00
# 1. preseed_<distro>_<major_version>_<install_type>_master
# 2. preseed_<distro>_<major_version>_<minor_version>_<install_type>_master
# 3. preseed_<distro>_<major_version>_master
# 4 preseed_<distro>_<major_version>_<minor_version>_master
# 5. preseed_<distro>_<install_type>_master
# 6. preseed_<distro>_master
# 7. preseed_master [THIS ONE IS ALREADY DEFINED AS THE DEFAULT]
2013-04-23 11:15:54 +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.
#
2014-02-01 09:04:28 +00:00
# Optionally, define a daemons running function, one of:
# 1. daemons_running_<distro>_<major_version>_<install_type>
# 2. daemons_running_<distro>_<major_version>_<minor_version>_<install_type>
# 3. daemons_running_<distro>_<major_version>
# 4 daemons_running_<distro>_<major_version>_<minor_version>
# 5. daemons_running_<distro>_<install_type>
# 6. daemons_running_<distro>
# 7. daemons_running [THIS ONE IS ALREADY DEFINED AS THE DEFAULT]
2014-02-16 22:32:56 +00:00
#
# Optionally, check enabled Services:
# 1. install_<distro>_<major_version>_<install_type>_check_services
# 2. install_<distro>_<major_version>_<minor_version>_<install_type>_check_services
# 3. install_<distro>_<major_version>_check_services
# 4 install_<distro>_<major_version>_<minor_version>_check_services
# 5. install_<distro>_<install_type>_check_services
# 6. install_<distro>_check_services
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-02-19 21:30:12 +00:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-17 14:02:09 +01:00
#
# Ubuntu Install Functions
#
2013-09-25 17:38:27 +01:00
__enable_universe_repository( ) {
2014-06-22 10:52:10 +01:00
if [ " $( grep -R universe /etc/apt/sources.list /etc/apt/sources.list.d/ | grep -v '#' ) " != "" ] ; then
2013-09-25 17:38:27 +01:00
# The universe repository is already enabled
return 0
fi
echodebug "Enabling the universe repository"
# Ubuntu versions higher than 12.04 do not live in the old repositories
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -gt 12 ] || ( [ " $DISTRO_MAJOR_VERSION " -eq 12 ] && [ " $DISTRO_MINOR_VERSION " -gt 04 ] ) ; then
2013-09-25 17:38:27 +01:00
add-apt-repository -y " deb http://archive.ubuntu.com/ubuntu $( lsb_release -sc) universe " || return 1
2014-06-21 18:58:16 +01:00
elif [ " $DISTRO_MAJOR_VERSION " -lt 11 ] && [ " $DISTRO_MINOR_VERSION " -lt 10 ] ; then
2013-09-26 11:07:39 +01:00
# Below Ubuntu 11.10, the -y flag to add-apt-repository is not supported
2013-09-25 17:38:27 +01:00
add-apt-repository " deb http://old-releases.ubuntu.com/ubuntu $( lsb_release -sc) universe " || return 1
fi
add-apt-repository -y " deb http://old-releases.ubuntu.com/ubuntu $( lsb_release -sc) universe " || return 1
return 0
}
2012-10-17 14:02:09 +01:00
install_ubuntu_deps( ) {
2015-05-03 15:57:43 +01:00
if ( [ " ${ __DEFAULT_SLEEP } " -eq " ${ __DEFAULT_SLEEP_ORIGINAL } " ] && [ " $DISTRO_MAJOR_VERSION " -lt 15 ] ) ; then
2014-08-03 21:51:14 +01:00
# The user did not pass a custom sleep value as an argument, let's increase the default value
echodebug "On Ubuntu systems we increase the default sleep value to 10."
echodebug "See https://github.com/saltstack/salt/issues/12248 for more info."
__DEFAULT_SLEEP = 10
fi
2014-02-17 15:26:33 +00:00
if [ $_START_DAEMONS -eq $BS_FALSE ] ; then
echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
fi
2015-04-13 16:20:49 -06:00
# No user interaction, libc6 restart services for example
export DEBIAN_FRONTEND = noninteractive
2014-04-03 07:40:37 +01:00
2012-10-17 14:02:09 +01:00
apt-get update
2014-04-03 07:40:37 +01:00
# Install Keys
2014-04-04 13:23:40 +01:00
__apt_get_install_noinput debian-archive-keyring && apt-get update
2014-04-03 07:40:37 +01:00
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -gt 12 ] || ( [ " $DISTRO_MAJOR_VERSION " -eq 12 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ) ; then
2013-09-27 23:26:21 +01:00
# Above Ubuntu 12.04 add-apt-repository is in a different package
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput software-properties-common || return 1
2013-01-24 19:43:34 +00:00
else
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput python-software-properties || return 1
2013-01-24 19:43:34 +00:00
fi
2013-09-24 15:17:26 -05:00
2013-09-25 17:38:27 +01:00
__enable_universe_repository || return 1
2013-09-24 15:17:26 -05:00
2013-11-12 00:52:00 +00:00
# Minimal systems might not have upstart installed, install it
2015-07-22 12:54:37 +01:00
__PACKAGES = "upstart"
2013-11-12 00:52:00 +00:00
2014-07-31 13:40:51 -07:00
# Need python-apt for managing packages via Salt
2015-07-22 12:54:37 +01:00
__PACKAGES = " ${ __PACKAGES } python-apt "
2015-07-22 13:11:01 +01:00
echoinfo "Installing Python Requests/Chardet from Chris Lea's PPA repository"
2015-07-22 12:54:37 +01:00
if [ " $DISTRO_MAJOR_VERSION " -gt 11 ] || ( [ " $DISTRO_MAJOR_VERSION " -eq 11 ] && [ " $DISTRO_MINOR_VERSION " -gt 04 ] ) ; then
# Above Ubuntu 11.04 add a -y flag
add-apt-repository -y "ppa:chris-lea/python-requests" || return 1
2015-07-22 13:11:01 +01:00
add-apt-repository -y "ppa:chris-lea/python-chardet" || return 1
2015-07-22 12:54:37 +01:00
else
add-apt-repository "ppa:chris-lea/python-requests" || return 1
2015-07-22 13:11:01 +01:00
add-apt-repository "ppa:chris-lea/python-chardet" || return 1
2015-07-22 12:54:37 +01:00
fi
__PACKAGES = " ${ __PACKAGES } python-requests "
2014-07-31 13:40:51 -07:00
2015-05-07 09:42:36 +01:00
if [ " $DISTRO_MAJOR_VERSION " -gt 12 ] || ( [ " $DISTRO_MAJOR_VERSION " -eq 12 ] && [ " $DISTRO_MINOR_VERSION " -gt 03 ] ) ; then
if ( [ " $DISTRO_MAJOR_VERSION " -lt 15 ] && [ " $_ENABLE_EXTERNAL_ZMQ_REPOS " -eq $BS_TRUE ] ) ; then
2014-10-21 01:54:50 +01:00
echoinfo "Installing ZMQ>=4/PyZMQ>=14 from Chris Lea's PPA repository"
add-apt-repository -y ppa:chris-lea/zeromq || return 1
fi
2014-04-07 19:38:48 +01:00
fi
2014-04-07 19:40:50 +01:00
# Additionally install procps and pciutils which allows for Docker boostraps. See 366#issuecomment-39666813
2015-07-22 12:54:37 +01:00
__PACKAGES = " ${ __PACKAGES } procps pciutils "
2014-04-07 19:40:50 +01:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install 'apache-libcloud'"
2015-07-22 12:54:37 +01:00
if [ " $( which pip) " = "" ] ; then
__PACKAGES = " ${ __PACKAGES } python-setuptools python-pip "
2014-04-09 13:10:08 +01:00
fi
2014-06-22 11:29:16 +01:00
# shellcheck disable=SC2089
2014-04-07 19:40:50 +01:00
__PIP_PACKAGES = " ${ __PIP_PACKAGES } 'apache-libcloud>= $_LIBCLOUD_MIN_VERSION ' "
fi
2015-07-22 12:54:37 +01:00
apt-get update
# shellcheck disable=SC2086,SC2090
__apt_get_install_noinput ${ __PACKAGES } || return 1
2014-06-22 10:52:10 +01:00
if [ " ${ __PIP_PACKAGES } " != "" ] ; then
2014-06-22 11:30:43 +01:00
# shellcheck disable=SC2086,SC2090
2014-04-09 13:10:08 +01:00
pip install -U ${ __PIP_PACKAGES }
2014-02-16 14:31:33 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput || return 1
2013-08-05 23:48:10 +01:00
fi
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
__apt_get_install_noinput ${ _EXTRA_PACKAGES } || return 1
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-31 17:06:02 +00:00
}
2015-03-12 03:52:31 -07:00
install_ubuntu_stable_deps( ) {
install_ubuntu_deps || return 1
# Alternate PPAs: salt16, salt17, salt2014-1, salt2014-7
2015-03-28 21:36:10 -07:00
if [ ! " $( echo " $STABLE_REV " | egrep '^(1\.6|1\.7)$' ) " = "" ] ; then
STABLE_PPA = " saltstack/salt $( echo " $STABLE_REV " | tr -d .) "
2015-05-07 09:55:55 +01:00
elif [ ! " $( echo " $STABLE_REV " | egrep '^(2014\.1|2014\.7|2015\.5)$' ) " = "" ] ; then
2015-03-28 21:36:10 -07:00
STABLE_PPA = " saltstack/salt $( echo " $STABLE_REV " | tr . -) "
else
STABLE_PPA = "saltstack/salt"
2015-03-12 03:52:31 -07:00
fi
if [ " $DISTRO_MAJOR_VERSION " -gt 11 ] || ( [ " $DISTRO_MAJOR_VERSION " -eq 11 ] && [ " $DISTRO_MINOR_VERSION " -gt 04 ] ) ; then
# Above Ubuntu 11.04 add a -y flag
add-apt-repository -y " ppa: $STABLE_PPA " || return 1
else
add-apt-repository " ppa: $STABLE_PPA " || return 1
fi
2015-07-22 12:10:41 +01:00
if [ ! " $( echo " $STABLE_REV " | egrep '^(2015\.8|latest)$' ) " = "" ] ; then
# We need a recent tornado package
__REQUIRED_TORNADO = "tornado >= 4.0"
check_pip_allowed " You need to allow pip based installations (-P) in order to install the python package ' ${ __REQUIRED_TORNADO } ' "
if [ " $( which pip) " = "" ] ; then
__apt_get_install_noinput python-setuptools python-pip
fi
pip install -U " ${ __REQUIRED_TORNADO } "
fi
2015-03-12 03:52:31 -07:00
apt-get update
}
2013-03-16 13:12:41 +00:00
install_ubuntu_daily_deps( ) {
2014-08-03 21:51:14 +01:00
install_ubuntu_deps || return 1
2014-07-22 14:01:26 +01:00
if [ " $DISTRO_MAJOR_VERSION " -ge 12 ] ; then
2013-09-25 20:02:57 +01:00
# Above Ubuntu 11.10 add-apt-repository is in a different package
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput software-properties-common || return 1
2013-03-16 13:12:41 +00:00
else
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput python-software-properties || return 1
2013-03-16 13:12:41 +00:00
fi
2013-09-25 18:28:34 +01:00
__enable_universe_repository || return 1
2013-09-24 17:10:06 -07:00
# for anything up to and including 11.04 do not use the -y option
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -gt 11 ] || ( [ " $DISTRO_MAJOR_VERSION " -eq 11 ] && [ " $DISTRO_MINOR_VERSION " -gt 04 ] ) ; then
2013-09-24 17:10:06 -07:00
# Above Ubuntu 11.04 add a -y flag
2013-03-23 11:55:45 +00:00
add-apt-repository -y ppa:saltstack/salt-daily || return 1
2013-09-24 17:10:06 -07:00
else
add-apt-repository ppa:saltstack/salt-daily || return 1
2013-03-16 13:12:41 +00:00
fi
2012-10-19 11:08:37 -07:00
apt-get update
2013-08-05 23:48:10 +01:00
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput || return 1
2013-08-05 23:48:10 +01:00
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 11:08:37 -07:00
}
2012-10-19 21:16:00 -07:00
install_ubuntu_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_ubuntu_deps || return 1
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput git-core python-yaml python-m2crypto python-crypto \
2013-03-23 11:55:45 +00:00
msgpack-python python-zmq python-jinja2 || return 1
2013-01-18 02:42:49 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-18 02:42:49 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
check_pip_allowed " You need to allow pip based installations (-P) in order to install the python package ' ${ __REQUIRED_TORNADO } ' "
if [ " $( which pip) " = "" ] ; then
__apt_get_install_noinput python-setuptools python-pip
fi
2015-07-19 21:06:50 +09:00
pip install -U " ${ __REQUIRED_TORNADO } "
2015-05-01 14:30:55 +01:00
fi
fi
2013-01-25 01:20:33 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_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
2013-03-06 22:05:31 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2012-10-17 14:02:09 +01:00
install_ubuntu_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
2013-01-25 20:18:08 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-master "
2013-01-25 20:18:08 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
2013-01-25 20:18:08 +00:00
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-07-06 00:38:13 +01:00
__apt_get_install_noinput ${ __PACKAGES } || return 1
2013-03-23 11:55:45 +00:00
return 0
2012-10-17 14:02:09 +01:00
}
2012-10-19 11:08:37 -07:00
install_ubuntu_daily( ) {
2013-03-23 11:55:45 +00:00
install_ubuntu_stable || return 1
return 0
2012-10-19 11:08:37 -07:00
}
2012-10-19 21:16:00 -07:00
install_ubuntu_git( ) {
2014-08-17 00:58:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /salt/syspaths.py " ] ; then
2015-07-16 21:13:20 +01:00
python setup.py install --install-layout= deb --salt-config-dir= " $_SALT_ETC_DIR " || \
python setup.py --salt-config-dir= " $_SALT_ETC_DIR " install --install-layout= deb || return 1
2014-02-16 22:01:31 +00:00
else
python setup.py install --install-layout= deb || return 1
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
install_ubuntu_git_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2015-05-20 18:20:34 +01:00
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 15 ] ; then
2015-05-03 15:43:58 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
sleep 0.1
systemctl daemon-reload
elif [ -f /sbin/initctl ] ; then
2013-07-26 21:19:04 -04:00
_upstart_conf = " /etc/init/salt- $fname .conf "
2013-01-25 20:18:08 +00:00
# We have upstart support
2013-03-17 23:19:27 +00:00
echodebug "There's upstart support"
2013-07-26 21:19:04 -04:00
if [ ! -f $_upstart_conf ] ; then
2013-01-26 18:22:26 +00:00
# upstart does not know about our service, let's copy the proper file
2013-07-26 21:19:04 -04:00
echowarn " Upstart does not appear to know about salt- $fname "
2014-08-17 00:58:55 +01:00
echodebug " Copying ${ __SALT_GIT_CHECKOUT_DIR } /pkg/salt- $fname .upstart to $_upstart_conf "
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/salt- ${ fname } .upstart " $_upstart_conf
2013-01-25 20:18:08 +00:00
fi
2013-02-08 11:56:03 +00:00
# No upstart support in Ubuntu!?
2014-08-17 00:58:55 +01:00
elif [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /debian/salt- ${ fname } .init " ] ; then
2013-03-17 23:19:27 +00:00
echodebug "There's NO upstart support!?"
2014-08-17 00:58:55 +01:00
echodebug " Copying ${ __SALT_GIT_CHECKOUT_DIR } /debian/salt- ${ fname } .init to /etc/init.d/salt- $fname "
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /debian/salt- ${ fname } .init " " /etc/init.d/salt- $fname "
2013-02-08 11:56:03 +00:00
chmod +x /etc/init.d/salt-$fname
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-08 11:56:03 +00:00
update-rc.d salt-$fname defaults
2013-03-17 23:30:25 +00:00
else
echoerror " Neither upstart not init.d was setup for salt- $fname "
2013-02-08 11:56:03 +00:00
fi
done
}
2013-02-16 10:04:25 +00:00
install_ubuntu_restart_daemons( ) {
2013-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2015-05-20 18:20:34 +01:00
# Ensure upstart configs / systemd units are loaded
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 15 ] ; then
2015-05-03 15:57:02 +01:00
systemctl daemon-reload
elif [ -f /sbin/initctl ] ; then
/sbin/initctl reload-configuration
fi
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-08 11:56:03 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-26 18:22:26 +00:00
2015-05-20 18:20:34 +01:00
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 15 ] ; then
2015-05-03 15:43:58 +01:00
echodebug " There's systemd support while checking salt- $fname "
systemctl stop salt-$fname > /dev/null 2>& 1
systemctl start salt-$fname .service
[ $? -eq 0 ] && continue
# We failed to start the service, let's test the SysV code below
echodebug " Failed to start salt- $fname using systemd "
fi
2013-02-08 11:56:03 +00:00
if [ -f /sbin/initctl ] ; then
2013-03-24 09:37:34 +00:00
echodebug " There's upstart support while checking salt- $fname "
2013-07-26 21:19:04 -04:00
status salt-$fname 2>/dev/null | grep -q running
2013-01-26 18:22:26 +00:00
if [ $? -eq 0 ] ; then
2013-07-26 21:19:04 -04:00
stop salt-$fname || ( echodebug " Failed to stop salt- $fname " && return 1)
2013-01-25 20:18:08 +00:00
fi
2013-07-26 21:19:04 -04:00
start salt-$fname
[ $? -eq 0 ] && continue
# We failed to start the service, let's test the SysV code below
echodebug " Failed to start salt- $fname using Upstart "
2012-11-26 02:01:14 +00:00
fi
2013-03-17 22:45:31 +00:00
2013-03-17 22:54:18 +00:00
if [ ! -f /etc/init.d/salt-$fname ] ; then
2013-03-17 22:45:31 +00:00
echoerror " No init.d support for salt- $fname was found "
return 1
fi
2013-02-13 12:15:56 +00:00
/etc/init.d/salt-$fname stop > /dev/null 2>& 1
2013-03-06 20:15:36 +00:00
/etc/init.d/salt-$fname start
2012-10-27 04:51:54 +01:00
done
2013-03-17 22:45:31 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2014-02-20 13:01:07 +00:00
install_ubuntu_check_services( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-20 13:01:07 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2015-05-03 15:43:58 +01:00
2015-05-20 18:20:34 +01:00
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 15 ] ; then
2015-05-03 15:43:58 +01:00
__check_services_systemd salt-$fname || return 1
elif [ -f /sbin/initctl ] && [ -f /etc/init/salt-${ fname } .conf ] ; then
2014-03-10 11:49:39 +00:00
__check_services_upstart salt-$fname || return 1
elif [ -f /etc/init.d/salt-$fname ] ; then
2014-03-10 12:11:20 +00:00
__check_services_debian salt-$fname || return 1
2014-03-10 11:49:39 +00:00
fi
2014-02-20 13:01:07 +00:00
done
return 0
}
2012-10-17 14:02:09 +01:00
#
# End of Ubuntu Install Functions
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-17 14:02:09 +01:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-17 14:02:09 +01:00
#
# Debian Install Functions
#
2012-11-11 10:12:12 -08:00
install_debian_deps( ) {
2014-02-17 15:26:33 +00:00
if [ $_START_DAEMONS -eq $BS_FALSE ] ; then
echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
fi
2013-03-23 11:30:54 +00:00
# No user interaction, libc6 restart services for example
export DEBIAN_FRONTEND = noninteractive
2012-11-11 10:12:12 -08:00
apt-get update
2013-08-05 23:48:10 +01:00
2014-04-03 07:39:30 +01:00
# Install Keys
2014-04-04 13:23:40 +01:00
__apt_get_install_noinput debian-archive-keyring && apt-get update
2014-04-03 07:39:30 +01:00
2014-07-06 00:33:17 +01:00
# Install procps and pciutils which allows for Docker bootstraps. See #366#issuecomment-39666813
2014-07-06 00:38:13 +01:00
__PACKAGES = "procps pciutils"
2014-07-06 00:33:17 +01:00
__PIP_PACKAGES = ""
2014-04-06 15:08:04 +01:00
2015-05-07 09:42:36 +01:00
if [ " $DISTRO_MAJOR_VERSION " -lt 6 ] ; then
# Both python-requests which is a hard dependency and apache-libcloud which is a soft dependency, under debian < 6
2014-07-06 00:33:17 +01:00
# need to be installed using pip
check_pip_allowed "You need to allow pip based installations (-P) in order to install the python 'requests' package"
# Additionally install procps and pciutils which allows for Docker boostraps. See 366#issuecomment-39666813
__PACKAGES = " ${ __PACKAGES } python-pip "
2015-04-30 14:42:40 +01:00
# shellcheck disable=SC2089
2015-04-30 14:27:04 +01:00
__PIP_PACKAGES = " ${ __PIP_PACKAGES } 'requests>= $_PY_REQUESTS_MIN_VERSION ' "
2014-07-06 00:33:17 +01:00
fi
2014-04-06 15:08:04 +01:00
2014-07-06 00:33:17 +01:00
# shellcheck disable=SC2086
2015-05-07 09:42:36 +01:00
__apt_get_install_noinput ${ __PACKAGES } || return 1
2014-04-06 15:08:04 +01:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-06-22 11:29:16 +01:00
# shellcheck disable=SC2089
2014-04-06 15:08:04 +01:00
__PIP_PACKAGES = " ${ __PIP_PACKAGES } 'apache-libcloud>= $_LIBCLOUD_MIN_VERSION ' "
2014-02-16 14:31:33 +00:00
fi
2015-05-07 09:42:36 +01:00
if [ " ${ __PIP_PACKAGES } " != "" ] ; then
# shellcheck disable=SC2086,SC2090
pip install -U ${ __PIP_PACKAGES } || return 1
fi
2014-02-16 14:31:33 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput || return 1
2013-08-05 23:48:10 +01:00
fi
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
__apt_get_install_noinput ${ _EXTRA_PACKAGES } || return 1
fi
return 0
2012-11-11 10:12:12 -08:00
}
2013-03-23 11:30:54 +00:00
install_debian_6_deps( ) {
2014-02-17 15:26:33 +00:00
if [ $_START_DAEMONS -eq $BS_FALSE ] ; then
echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
fi
2013-02-28 00:06:01 +00:00
# No user interaction, libc6 restart services for example
export DEBIAN_FRONTEND = noninteractive
2014-04-03 07:39:30 +01:00
apt-get update
2014-12-09 14:18:41 +01:00
# Make sure wget is available
__apt_get_install_noinput wget
2014-04-03 07:39:30 +01:00
# Install Keys
2014-04-04 13:23:40 +01:00
__apt_get_install_noinput debian-archive-keyring && apt-get update
2014-04-03 07:39:30 +01:00
2015-04-09 00:02:00 -05:00
# Install Debian Archive Automatic Signing Key (6.0/squeeze), see #557
2015-04-22 10:59:48 +01:00
if [ " $( apt-key finger | grep '9FED 2BCB DCD2 9CDF 7626 78CB AED4 B06F 4730 41FA' ) " = "" ] ; then
2015-04-09 00:02:00 -05:00
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AED4B06F473041FA || return 1
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-01-22 23:21:04 +00:00
wget $_WGET_ARGS -q http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key -O - | apt-key add - || return 1
2012-12-20 09:40:27 -08:00
2014-06-21 18:58:16 +01:00
if [ " $_PIP_ALLOWED " -eq $BS_TRUE ] ; then
2013-05-17 22:28:40 -06:00
echowarn "PyZMQ will be installed from PyPI in order to compile it against ZMQ3"
2013-05-03 22:42:51 +01:00
echowarn "This is required for long term stable minion connections to the master."
2013-10-08 17:15:50 +11:00
echowarn "YOU WILL END UP WITH QUITE A FEW PACKAGES FROM DEBIAN UNSTABLE"
2014-07-20 22:40:20 +01:00
echowarn "Sleeping for 5 seconds so you can cancel..."
sleep 5
2013-02-22 17:52:17 +00:00
2013-05-07 18:33:50 +01:00
if [ ! -f /etc/apt/sources.list.d/debian-unstable.list ] ; then
cat <<_eof > /etc/apt/sources.list.d/debian-unstable.list
deb http://ftp.debian.org/debian unstable main
deb-src http://ftp.debian.org/debian unstable main
2013-02-22 05:44:08 +00:00
_eof
2013-05-07 18:33:50 +01:00
cat <<_eof > /etc/apt/preferences.d/libzmq3-debian-unstable.pref
2013-02-22 05:44:08 +00:00
Package: libzmq3
2013-05-07 18:33:50 +01:00
Pin: release a = unstable
2013-02-22 05:44:08 +00:00
Pin-Priority: 800
Package: libzmq3-dev
2013-05-07 18:33:50 +01:00
Pin: release a = unstable
2013-02-22 05:44:08 +00:00
Pin-Priority: 800
_eof
2013-05-15 14:14:25 +01:00
fi
2013-05-03 20:53:59 +00:00
apt-get update
2013-05-15 14:14:25 +01:00
# We NEED to install the unstable dpkg or mime-support WILL fail to install
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput -t unstable dpkg liblzma5 python mime-support || return 1
__apt_get_install_noinput -t unstable libzmq3 libzmq3-dev || return 1
2015-05-08 11:39:46 +01:00
__apt_get_install_noinput build-essential python-dev python-pip python-setuptools || return 1
2013-05-15 14:14:25 +01:00
# Saltstack's Unstable Debian repository
2014-06-22 10:52:10 +01:00
if [ " $( grep -R 'debian.saltstack.com' /etc/apt) " = "" ] ; then
2013-05-15 14:14:25 +01:00
echo "deb http://debian.saltstack.com/debian unstable main" >> \
/etc/apt/sources.list.d/saltstack.list
fi
return 0
2013-02-27 17:26:29 +00:00
fi
2013-02-22 05:44:08 +00:00
2013-05-15 14:14:25 +01:00
# Debian Backports
2015-02-27 19:22:04 +00:00
if [ " $( grep -R 'squeeze-backports' /etc/apt | grep -v "^#" ) " = "" ] ; then
2015-04-27 18:08:56 +02:00
echo "deb http://ftp.de.debian.org/debian-backports squeeze-backports main" >> \
2013-05-15 14:14:25 +01:00
/etc/apt/sources.list.d/backports.list
fi
# Saltstack's Stable Debian repository
2014-06-22 10:52:10 +01:00
if [ " $( grep -R 'squeeze-saltstack' /etc/apt) " = "" ] ; then
2013-05-15 14:14:25 +01:00
echo "deb http://debian.saltstack.com/debian squeeze-saltstack main" >> \
/etc/apt/sources.list.d/saltstack.list
2013-05-03 20:53:59 +00:00
fi
2013-05-15 14:14:25 +01:00
apt-get update || return 1
2013-08-05 23:48:10 +01:00
2014-04-06 15:12:07 +01:00
# Python requests is available through Squeeze backports
2014-04-06 15:19:12 +01:00
# Additionally install procps and pciutils which allows for Docker boostraps. See 366#issuecomment-39666813
2015-05-07 09:42:36 +01:00
__apt_get_install_noinput python-pip procps pciutils python-requests
2014-04-06 15:08:04 +01:00
2014-07-31 13:40:51 -07:00
# Need python-apt for managing packages via Salt
__apt_get_install_noinput python-apt
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2015-04-30 14:27:04 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud/requests"
2015-05-07 09:42:36 +01:00
pip install -U " apache-libcloud>= $_LIBCLOUD_MIN_VERSION "
2015-04-30 14:27:04 +01:00
2014-02-16 14:31:33 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput || return 1
2013-08-05 23:48:10 +01:00
fi
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput python-zmq || return 1
2014-02-16 21:38:15 +00:00
2015-05-08 11:39:46 +01:00
if [ " $_PIP_ALLOWED " -eq $BS_TRUE ] ; then
# Building pyzmq from source to build it against libzmq3.
# Should override current installation
# Using easy_install instead of pip because at least on Debian 6,
# there's no default virtualenv active.
easy_install -U pyzmq || return 1
fi
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2015-03-12 04:00:24 -07:00
__apt_get_install_noinput ${ _EXTRA_PACKAGES } || return 1
2014-02-16 21:38:15 +00:00
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-17 14:02:09 +01:00
}
2013-03-23 11:37:44 +00:00
install_debian_7_deps( ) {
2014-02-17 15:26:33 +00:00
if [ $_START_DAEMONS -eq $BS_FALSE ] ; then
echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
fi
2013-05-15 14:36:46 +01:00
# No user interaction, libc6 restart services for example
export DEBIAN_FRONTEND = noninteractive
2014-04-03 07:39:30 +01:00
apt-get update
2014-12-09 14:18:41 +01:00
# Make sure wget is available
__apt_get_install_noinput wget
2014-04-03 07:39:30 +01:00
# Install Keys
2014-04-04 13:23:40 +01:00
__apt_get_install_noinput debian-archive-keyring && apt-get update
2014-04-03 07:39:30 +01:00
2015-04-09 00:02:00 -05:00
# Install Debian Archive Automatic Signing Key (7.0/wheezy), see #557
2015-04-22 10:59:48 +01:00
if [ " $( apt-key finger | grep 'A1BD 8E9D 78F7 FE5C 3E65 D8AF 8B48 AD62 4692 5553' ) " = "" ] ; then
2015-04-09 00:02:00 -05:00
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553 || return 1
fi
2015-02-27 10:14:47 +00:00
# Debian Backports
2015-02-27 10:45:41 +00:00
if [ " $( grep -R 'wheezy-backports' /etc/apt | grep -v "^#" ) " = "" ] ; then
2015-06-03 12:33:50 +02:00
echo "deb http://httpredir.debian.org/debian wheezy-backports main" >> \
2015-02-27 10:14:47 +00:00
/etc/apt/sources.list.d/backports.list
fi
2013-05-15 14:36:46 +01:00
# Saltstack's Stable Debian repository
2014-06-22 10:52:10 +01:00
if [ " $( grep -R 'wheezy-saltstack' /etc/apt) " = "" ] ; then
2013-05-03 22:42:51 +01:00
echo "deb http://debian.saltstack.com/debian wheezy-saltstack main" >> \
/etc/apt/sources.list.d/saltstack.list
fi
2013-03-23 11:37:44 +00:00
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-01-22 23:21:04 +00:00
wget $_WGET_ARGS -q http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key -O - | apt-key add - || return 1
2013-05-15 14:36:46 +01:00
2014-12-22 17:23:14 -08:00
apt-get update || return 1
2015-04-30 14:27:04 +01:00
__apt_get_install_noinput -t wheezy-backports libzmq3 libzmq3-dev python-zmq python-apt || return 1
2014-12-22 17:23:14 -08:00
# Additionally install procps and pciutils which allows for Docker boostraps. See 366#issuecomment-39666813
2014-12-23 12:47:24 -08:00
__PACKAGES = "procps pciutils"
2015-05-07 09:42:36 +01:00
# Also install python-requests
__PACKAGES = " ${ __PACKAGES } python-requests "
2014-12-22 17:23:14 -08:00
# shellcheck disable=SC2086
__apt_get_install_noinput ${ __PACKAGES } || return 1
2013-08-05 23:48:10 +01:00
2015-05-01 21:34:01 +01:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2015-05-07 09:42:36 +01:00
__PACKAGES = "build-essential python-dev python-pip"
# shellcheck disable=SC2086
__apt_get_install_noinput ${ __PACKAGES } || return 1
2015-05-01 21:34:01 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2015-05-07 09:42:36 +01:00
pip install -U " apache-libcloud>= $_LIBCLOUD_MIN_VERSION " || return 1
2014-02-16 14:31:33 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput || return 1
2013-08-05 23:48:10 +01:00
fi
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
__apt_get_install_noinput ${ _EXTRA_PACKAGES } || return 1
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-17 14:02:09 +01:00
}
2015-03-16 08:28:36 +11:00
install_debian_8_deps( ) {
echodebug "install_debian_8_deps"
if [ $_START_DAEMONS -eq $BS_FALSE ] ; then
echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
fi
# No user interaction, libc6 restart services for example
export DEBIAN_FRONTEND = noninteractive
apt-get update
# Make sure wget is available
__apt_get_install_noinput wget
# Install Keys
__apt_get_install_noinput debian-archive-keyring && apt-get update
2015-04-22 10:59:48 +01:00
# Install Debian Archive Automatic Signing Key (8/jessie), see #557
if [ " $( apt-key finger | grep '126C 0D24 BD8A 2942 CC7D F8AC 7638 D044 2B90 D010' ) " = "" ] ; then
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 || return 1
2015-04-09 00:02:00 -05:00
fi
2015-03-16 08:28:36 +11:00
# Debian Backports
if [ " $( grep -R 'jessie-backports' /etc/apt | grep -v "^#" ) " = "" ] ; then
2015-06-03 12:33:50 +02:00
echo "deb http://httpredir.debian.org/debian jessie-backports main" >> \
2015-03-16 08:28:36 +11:00
/etc/apt/sources.list.d/backports.list
fi
# Saltstack's Stable Debian repository
if [ " $( grep -R 'jessie-saltstack' /etc/apt) " = "" ] ; then
echo "deb http://debian.saltstack.com/debian jessie-saltstack main" >> \
/etc/apt/sources.list.d/saltstack.list
fi
# shellcheck disable=SC2086
wget $_WGET_ARGS -q http://debian.saltstack.com/debian-salt-team-joehealy.gpg.key -O - | apt-key add - || return 1
apt-get update || return 1
__apt_get_install_noinput -t jessie-backports libzmq3 libzmq3-dev python-zmq python-requests python-apt || return 1
# Additionally install procps and pciutils which allows for Docker boostraps. See 366#issuecomment-39666813
__PACKAGES = "procps pciutils"
2015-05-07 09:42:36 +01:00
# Also install python-requests
__PACKAGES = " ${ __PACKAGES } python-requests "
2015-03-16 08:28:36 +11:00
# shellcheck disable=SC2086
__apt_get_install_noinput ${ __PACKAGES } || return 1
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
__PACKAGES = "build-essential python-dev python-pip"
# shellcheck disable=SC2086
__apt_get_install_noinput ${ __PACKAGES } || return 1
pip install -U " apache-libcloud>= $_LIBCLOUD_MIN_VERSION "
fi
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
__apt_get_upgrade_noinput || return 1
fi
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
__apt_get_install_noinput ${ _EXTRA_PACKAGES } || return 1
fi
2014-02-25 19:21:39 +00:00
return 0
}
2012-12-11 16:31:54 +00:00
install_debian_git_deps( ) {
2014-02-17 15:26:33 +00:00
if [ $_START_DAEMONS -eq $BS_FALSE ] ; then
echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
fi
2013-02-28 00:06:01 +00:00
# No user interaction, libc6 restart services for example
export DEBIAN_FRONTEND = noninteractive
2012-12-11 16:31:54 +00:00
apt-get update
2014-04-03 07:39:30 +01:00
# Install Keys
2014-04-04 13:23:40 +01:00
__apt_get_install_noinput debian-archive-keyring && apt-get update
2014-04-03 07:39:30 +01:00
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
__apt_get_install_noinput git || return 1
fi
2013-09-25 17:32:59 +01:00
__apt_get_install_noinput lsb-release python python-pkg-resources python-crypto \
2015-04-30 12:12:22 +01:00
python-jinja2 python-m2crypto python-yaml msgpack-python python-pip || return 1
2012-12-11 16:31:54 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-18 02:42:49 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
check_pip_allowed " You need to allow pip based installations (-P) in order to install the python package ' ${ __REQUIRED_TORNADO } ' "
2015-05-07 09:42:36 +01:00
pip install -U " ${ __REQUIRED_TORNADO } " || return 1
2015-05-01 14:30:55 +01:00
fi
fi
2013-01-25 01:20:33 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_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-03-06 22:05:31 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2014-04-04 12:57:08 +01:00
pip install -U " apache-libcloud>= $_LIBCLOUD_MIN_VERSION "
2014-02-16 14:31:33 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput || return 1
2013-08-05 23:48:10 +01:00
fi
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
__apt_get_install_noinput ${ _EXTRA_PACKAGES } || return 1
fi
2013-03-06 22:05:31 +00:00
return 0
2012-12-11 16:31:54 +00:00
}
2013-03-23 11:30:54 +00:00
install_debian_6_git_deps( ) {
2013-05-15 14:36:46 +01:00
install_debian_6_deps || return 1
2014-06-21 18:58:16 +01:00
if [ " $_PIP_ALLOWED " -eq $BS_TRUE ] ; then
2015-05-07 16:31:21 +01:00
__PACKAGES = "build-essential lsb-release python python-dev python-pkg-resources python-crypto"
2015-05-08 11:39:46 +01:00
__PACKAGES = " ${ __PACKAGES } python-m2crypto python-yaml msgpack-python python-pip python-setuptools "
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
2015-05-07 16:31:21 +01:00
__PACKAGES = " ${ __PACKAGES } git "
2015-04-30 12:12:22 +01:00
fi
2015-05-07 16:31:21 +01:00
# shellcheck disable=SC2086
__apt_get_install_noinput ${ __PACKAGES } || return 1
easy_install -U pyzmq Jinja2 || return 1
2013-05-23 04:14:07 +01:00
__git_clone_and_checkout || return 1
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_TEMP_CONFIG_DIR = " ${ __SALT_GIT_CHECKOUT_DIR } /conf/ "
2013-05-23 04:14:07 +01:00
CONFIG_SALT_FUNC = "config_salt"
fi
else
install_debian_git_deps || return 1 # Grab the actual deps
fi
2013-08-05 23:48:10 +01:00
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-09-25 17:35:06 +01:00
__apt_get_upgrade_noinput || return 1
2013-08-05 23:48:10 +01:00
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-18 19:54:05 -07:00
}
2013-03-23 11:37:44 +00:00
install_debian_7_git_deps( ) {
2013-05-15 14:36:46 +01:00
install_debian_7_deps || return 1
2013-03-23 11:55:45 +00:00
install_debian_git_deps || return 1 # Grab the actual deps
return 0
2012-10-18 19:54:05 -07:00
}
2014-02-25 19:21:39 +00:00
install_debian_8_git_deps( ) {
2015-03-16 08:28:36 +11:00
install_debian_8_deps || return 1
install_debian_git_deps || return 1 # Grab the actual deps
2014-02-25 19:21:39 +00:00
return 0
}
2013-03-23 11:30:54 +00:00
__install_debian_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
2013-01-25 20:18:08 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-master "
2013-01-25 20:18:08 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
2013-01-25 20:18:08 +00:00
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-07-06 00:38:13 +01:00
__apt_get_install_noinput ${ __PACKAGES } || return 1
2013-02-22 05:52:53 +00:00
2013-03-23 11:30:54 +00:00
return 0
2013-01-25 02:16:41 +00:00
}
2013-04-23 11:24:57 +01:00
install_debian_6_stable( ) {
2013-03-23 11:55:45 +00:00
__install_debian_stable || return 1
return 0
2013-01-25 02:16:41 +00:00
}
2013-05-15 14:36:46 +01:00
install_debian_7_stable( ) {
__install_debian_stable || return 1
return 0
}
2014-02-25 19:31:19 +00:00
install_debian_8_stable( ) {
2014-02-25 19:21:39 +00:00
__install_debian_stable || return 1
return 0
}
2013-01-25 02:16:41 +00:00
install_debian_git( ) {
2013-02-28 00:06:01 +00:00
2014-08-17 00:58:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /salt/syspaths.py " ] ; then
2015-07-16 21:13:20 +01:00
python setup.py install --install-layout= deb --salt-config-dir= " $_SALT_ETC_DIR " || \
python setup.py --salt-config-dir= " $_SALT_ETC_DIR " install --install-layout= deb || return 1
2014-02-16 22:01:31 +00:00
else
python setup.py install --install-layout= deb || return 1
fi
2012-10-18 19:54:05 -07:00
}
2012-12-20 09:58:17 -08:00
2013-03-23 11:30:54 +00:00
install_debian_6_git( ) {
2013-03-23 11:55:45 +00:00
install_debian_git || return 1
return 0
2013-01-25 02:16:41 +00:00
}
2013-03-23 11:37:44 +00:00
install_debian_7_git( ) {
2013-03-23 11:55:45 +00:00
install_debian_git || return 1
return 0
2013-01-25 02:16:41 +00:00
}
2014-02-25 19:21:39 +00:00
install_debian_8_git( ) {
install_debian_git || return 1
return 0
}
2012-12-20 09:58:17 -08:00
install_debian_git_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2015-03-16 08:30:47 +11:00
if [ -f /bin/systemctl ] ; then
if [ ! -f /etc/systemd/system/salt-${ fname } .service ] || ( [ -f /etc/systemd/system/salt-${ fname } .service ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ] ) ; then
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/salt- ${ fname } .service " /etc/systemd/system
fi
2014-09-09 20:40:49 +01:00
2015-03-16 08:30:47 +11:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
/bin/systemctl enable salt-${ fname } .service
SYSTEMD_RELOAD = $BS_TRUE
elif [ ! -f /etc/init.d/salt-$fname ] || ( [ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ] ) ; then
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /debian/salt- $fname .init " ] ; then
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /debian/salt- $fname .init " " /etc/init.d/salt- $fname "
2015-07-16 19:51:04 +01:00
else
2015-07-16 21:13:20 +01:00
__fetch_url " /etc/init.d/salt- $fname " " http://anonscm.debian.org/cgit/pkg-salt/salt.git/plain/debian/salt- ${ fname } .init "
2015-03-16 08:30:47 +11:00
fi
if [ ! -f " /etc/init.d/salt- $fname " ] ; then
echowarn " The init script for salt- $fname was not found, skipping it... "
continue
fi
chmod +x " /etc/init.d/salt- $fname "
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
update-rc.d " salt- $fname " defaults
fi
2014-09-09 20:40:49 +01:00
2013-02-08 11:59:06 +00:00
done
}
2013-02-16 10:04:25 +00:00
install_debian_restart_daemons( ) {
2014-06-21 18:58:16 +01:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-08 11:59:06 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ ! -f "/etc/init.d/salt-$fname" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2015-03-16 08:30:47 +11:00
if [ -f /bin/systemctl ] ; then
# Debian 8 uses systemd
/bin/systemctl stop salt-$fname > /dev/null 2>& 1
/bin/systemctl start salt-$fname .service
elif [ -f /etc/init.d/salt-$fname ] ; then
# Still in SysV init
/etc/init.d/salt-$fname stop > /dev/null 2>& 1
/etc/init.d/salt-$fname start
fi
2012-12-20 09:58:17 -08:00
done
}
2014-03-10 12:11:20 +00:00
install_debian_check_services( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-03-10 12:11:20 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ ! -f "/etc/init.d/salt-$fname" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2015-03-16 08:30:47 +11:00
if [ -f /bin/systemctl ] ; then
__check_services_systemd salt-$fname || return 1
elif [ -f /etc/init.d/salt-$fname ] ; then
__check_services_debian salt-$fname || return 1
fi
2014-03-10 12:11:20 +00:00
done
return 0
}
2012-10-17 14:02:09 +01:00
#
# Ended Debian Install Functions
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-17 14:02:09 +01:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-19 21:16:00 -07:00
#
# Fedora Install Functions
#
2012-10-27 07:31:14 +01:00
install_fedora_deps( ) {
2014-10-20 20:44:16 +01:00
if [ " $_ENABLE_EXTERNAL_ZMQ_REPOS " -eq $BS_TRUE ] ; then
__install_saltstack_copr_zeromq_repository || return 1
fi
2015-05-01 14:30:55 +01:00
__install_saltstack_copr_salt_repository || return 1
2014-07-06 00:38:13 +01:00
__PACKAGES = "yum-utils PyYAML libyaml m2crypto python-crypto python-jinja2 python-msgpack python-zmq python-requests"
2014-02-16 14:37:27 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-libcloud "
2014-02-16 14:37:27 +00:00
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-07-06 00:38:13 +01:00
yum install -y ${ __PACKAGES } || return 1
2013-08-05 23:55:17 +01:00
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-08-05 23:55:17 +01:00
yum -y update || return 1
fi
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
yum install -y ${ _EXTRA_PACKAGES } || return 1
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-27 07:31:14 +01:00
}
2012-10-19 21:16:00 -07:00
install_fedora_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
2013-01-25 22:19:40 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] || [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-master "
2013-01-25 22:19:40 +00:00
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-07-06 00:38:13 +01:00
yum install -y ${ __PACKAGES } || return 1
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2014-02-01 04:56:47 -07:00
install_fedora_stable_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-02-01 04:56:47 -07:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2014-02-01 04:56:47 -07:00
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-01 04:56:47 -07:00
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
sleep 0.1
systemctl daemon-reload
done
}
2012-10-27 07:31:14 +01:00
install_fedora_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_fedora_deps || return 1
2013-01-18 02:42:49 +00:00
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
yum install -y git || return 1
fi
yum install -y systemd-python || return 1
2014-02-18 19:44:35 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-18 02:42:49 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
yum install -y python-tornado
fi
fi
2013-01-25 01:20:33 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_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
2013-03-06 22:05:31 +00:00
return 0
2012-10-27 07:31:14 +01:00
}
install_fedora_git( ) {
2014-08-17 00:58:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /salt/syspaths.py " ] ; then
2015-07-16 21:13:20 +01:00
python setup.py install --salt-config-dir= " $_SALT_ETC_DIR " || \
python setup.py --salt-config-dir= " $_SALT_ETC_DIR " install || return 1
2014-02-16 22:01:31 +00:00
else
python setup.py install || return 1
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-27 07:31:14 +01:00
}
install_fedora_git_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2014-08-17 00:58:55 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
2012-10-27 07:31:14 +01:00
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
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-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-08 12:01:50 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $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
}
2014-02-20 11:00:12 +00:00
install_fedora_check_services( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-20 11:44:34 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2014-02-20 11:52:21 +00:00
__check_services_systemd salt-$fname || return 1
2014-02-20 11:44:34 +00:00
done
return 0
2014-02-20 11:00:12 +00:00
}
2012-10-19 21:16:00 -07:00
#
# Ended Fedora Install Functions
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-19 21:16:00 -07:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-17 16:07:33 +01:00
#
# CentOS Install Functions
#
2014-06-16 09:39:30 +01:00
__install_epel_repository( ) {
2014-06-17 19:32:30 +01:00
if [ ${ __EPEL_REPOS_INSTALLED } -eq $BS_TRUE ] ; then
2014-06-16 09:39:30 +01:00
return 0
2012-10-21 16:05:29 +01:00
fi
2014-07-20 18:32:50 +01:00
2015-04-10 15:39:05 -04:00
# Check if epel repo is already enabled and flag it accordingly
yum repolist | grep -i "epel" > /dev/null 2>& 1
if [ $? -eq 0 ] ; then
__EPEL_REPOS_INSTALLED = ${ BS_TRUE }
return 0
fi
2014-07-20 18:32:50 +01:00
# Check if epel-release is already installed and flag it accordingly
rpm --nodigest --nosignature -q epel-release > /dev/null 2>& 1
if [ $? -eq 0 ] ; then
2014-06-28 22:42:44 -04:00
__EPEL_REPOS_INSTALLED = ${ BS_TRUE }
return 0
fi
2014-07-20 18:32:50 +01:00
2014-06-21 18:58:16 +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
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -eq 5 ] ; then
2014-07-29 18:29:26 +01:00
# Use dl.fedoraproject.org to avoid redirect breakage:
# https://lists.fedoraproject.org/pipermail/users/2012-February/414558.html
2014-08-01 00:26:48 +01:00
rpm -Uvh --force " http://dl.fedoraproject.org/pub/epel/5/ ${ EPEL_ARCH } /epel-release-5-4.noarch.rpm " || return 1
2014-06-21 18:58:16 +01:00
elif [ " $DISTRO_MAJOR_VERSION " -eq 6 ] ; then
2014-07-21 22:28:04 +01:00
rpm -Uvh --force " http://download.fedoraproject.org/pub/epel/6/ ${ EPEL_ARCH } /epel-release-6-8.noarch.rpm " || return 1
2014-06-21 18:58:16 +01:00
elif [ " $DISTRO_MAJOR_VERSION " -eq 7 ] ; then
2014-12-11 09:07:39 -07:00
rpm -Uvh --force " http://download.fedoraproject.org/pub/epel/7/ ${ EPEL_ARCH } /e/epel-release-7-5.noarch.rpm " || return 1
2013-02-12 20:23:58 +00:00
else
echoerror "Failed add EPEL repository support."
2013-03-23 11:55:45 +00:00
return 1
2013-01-27 18:11:30 +00:00
fi
2014-06-16 09:39:30 +01:00
__EPEL_REPOS_INSTALLED = ${ BS_TRUE }
return 0
}
2014-10-20 20:44:16 +01:00
__install_saltstack_copr_zeromq_repository( ) {
2014-10-21 01:57:28 +01:00
echoinfo "Installing Zeromq >=4 and PyZMQ>=14 from SaltStack's COPR repository"
2015-01-27 16:32:44 +01:00
if [ ! -s /etc/yum.repos.d/saltstack-zeromq4.repo ] ; then
2014-10-20 20:44:16 +01:00
if [ " ${ DISTRO_NAME_L } " = "fedora" ] ; then
__REPOTYPE = " ${ DISTRO_NAME_L } "
else
__REPOTYPE = "epel"
fi
2015-01-27 16:29:01 +01:00
__fetch_url /etc/yum.repos.d/saltstack-zeromq4.repo \
2015-05-01 14:30:55 +01:00
" http://copr.fedoraproject.org/coprs/saltstack/zeromq4/repo/ ${ __REPOTYPE } - ${ DISTRO_MAJOR_VERSION } /saltstack-zeromq4- ${ __REPOTYPE } - ${ DISTRO_MAJOR_VERSION } .repo " || return 1
2014-10-20 20:44:16 +01:00
fi
2014-10-21 23:01:58 +01:00
return 0
2014-10-20 20:44:16 +01:00
}
2015-02-27 01:07:10 +00:00
__install_saltstack_copr_salt_el5_repository( ) {
if [ ! -s /etc/yum.repos.d/saltstack-salt-el5-epel-5.repo ] ; then
__fetch_url /etc/yum.repos.d/saltstack-salt-el5-epel-5.repo \
"http://copr.fedoraproject.org/coprs/saltstack/salt-el5/repo/epel-5/saltstack-salt-el5-epel-5.repo" || return 1
fi
return 0
}
2014-10-20 20:44:16 +01:00
2015-05-01 14:30:55 +01:00
__install_saltstack_copr_salt_repository( ) {
echoinfo "Adding SaltStack's COPR repository"
if [ " ${ DISTRO_NAME_L } " = "fedora" ] ; then
__REPOTYPE = " ${ DISTRO_NAME_L } "
else
__REPOTYPE = "epel"
fi
__REPO_FILENAME = " saltstack-salt- ${ __REPOTYPE } - ${ DISTRO_MAJOR_VERSION } .repo "
if [ ! -s " /etc/yum.repos.d/ ${ __REPO_FILENAME } " ] ; then
2015-05-01 21:46:58 +01:00
__fetch_url " /etc/yum.repos.d/ ${ __REPO_FILENAME } " \
2015-05-01 14:30:55 +01:00
" http://copr.fedoraproject.org/coprs/saltstack/salt/repo/ ${ __REPOTYPE } - ${ DISTRO_MAJOR_VERSION } / ${ __REPO_FILENAME } " || return 1
fi
return 0
}
2014-06-16 09:39:30 +01:00
install_centos_stable_deps( ) {
2015-02-27 01:33:10 +00:00
__install_epel_repository || return 1
2015-02-27 01:07:10 +00:00
if [ " $DISTRO_MAJOR_VERSION " -eq 5 ] ; then
__install_saltstack_copr_salt_el5_repository || return 1
fi
2013-03-02 12:14:56 +00:00
2015-05-01 14:30:55 +01:00
__install_saltstack_copr_salt_repository || return 1
2015-02-27 01:07:10 +00:00
if [ " $_ENABLE_EXTERNAL_ZMQ_REPOS " -eq $BS_TRUE ] && [ " $DISTRO_MAJOR_VERSION " -gt 5 ] ; then
2015-01-06 12:05:10 -07:00
yum -y install python-hashlib || return 1
2014-10-20 20:44:16 +01:00
__install_saltstack_copr_zeromq_repository || return 1
fi
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
yum install -y python-tornado
fi
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-08-05 23:36:18 +01:00
yum -y update || return 1
fi
2013-03-02 12:14:56 +00:00
2014-07-06 00:38:13 +01:00
__PACKAGES = "yum-utils chkconfig"
2014-02-16 21:42:49 +00:00
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -eq 5 ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python26-PyYAML python26-m2crypto m2crypto python26 python26-requests "
__PACKAGES = " ${ __PACKAGES } python26-crypto python26-msgpack python26-zmq python26-jinja2 "
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python26-setuptools "
2014-02-16 17:08:09 +00:00
fi
2013-03-02 12:14:56 +00:00
else
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } PyYAML m2crypto python-crypto python-msgpack python-zmq python-jinja2 python-requests "
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-pip "
2014-02-16 17:08:09 +00:00
fi
fi
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_NAME_L " = "oracle_linux" ] ; then
2014-06-21 13:21:35 +01:00
# We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!!
2014-07-06 00:38:13 +01:00
for package in ${ __PACKAGES } ; do
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 13:21:35 +01:00
yum -y install ${ package } || yum -y install ${ package } --enablerepo= ${ _EPEL_REPO } || return 1
done
else
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-07-06 00:38:13 +01:00
yum -y install ${ __PACKAGES } --enablerepo= ${ _EPEL_REPO } || return 1
2014-06-21 13:21:35 +01:00
fi
2014-02-16 17:08:09 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -eq 5 ] ; then
2014-04-04 12:57:08 +01:00
easy_install-2.6 " apache-libcloud>= $_LIBCLOUD_MIN_VERSION "
2014-02-16 17:08:09 +00:00
else
2015-02-06 14:47:10 +01:00
pip install " apache-libcloud>= $_LIBCLOUD_MIN_VERSION "
2014-02-16 17:08:09 +00:00
fi
2013-03-02 12:14:56 +00:00
fi
2014-02-16 21:38:15 +00:00
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_NAME_L " = "oracle_linux" ] ; then
2014-06-21 13:21:35 +01:00
# We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!!
for package in ${ _EXTRA_PACKAGES } ; do
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 13:21:35 +01:00
yum -y install ${ package } || yum -y install ${ package } --enablerepo= ${ _EPEL_REPO } || return 1
done
else
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 13:21:35 +01:00
yum install -y ${ _EXTRA_PACKAGES } --enablerepo= ${ _EPEL_REPO } || return 1
fi
2013-03-02 12:14:56 +00:00
fi
2014-02-16 21:38:15 +00:00
2013-03-23 11:55:45 +00:00
return 0
2012-10-17 16:07:33 +01:00
}
2013-01-27 18:11:30 +00:00
install_centos_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
2013-01-26 12:01:46 +00:00
fi
2015-02-06 15:00:52 +01:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-master "
2015-03-12 04:00:24 -07:00
fi
2015-02-06 15:00:52 +01:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
__PACKAGES = " ${ __PACKAGES } salt-syndic "
2013-01-26 12:01:46 +00:00
fi
2015-03-12 04:00:24 -07:00
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_NAME_L " = "oracle_linux" ] ; then
2014-06-21 13:21:35 +01:00
# We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!!
2014-07-06 00:38:13 +01:00
for package in ${ __PACKAGES } ; do
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 13:21:35 +01:00
yum -y install ${ package } || yum -y install ${ package } --enablerepo= ${ _EPEL_REPO } || return 1
done
else
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-07-06 00:38:13 +01:00
yum -y install ${ __PACKAGES } --enablerepo= ${ _EPEL_REPO } || return 1
2014-06-21 13:21:35 +01:00
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-17 16:07:33 +01:00
}
2013-01-27 18:11:30 +00:00
install_centos_stable_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-02-08 12:07:11 +00:00
# Skip if not meant to be installed
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-08 12:07:11 +00:00
2014-03-10 12:13:17 +00:00
if [ -f /etc/init.d/salt-$fname ] ; then
2013-02-08 12:07:11 +00:00
# Still in SysV init!?
/sbin/chkconfig salt-$fname on
2014-07-20 19:17:15 +01:00
elif [ -f /usr/bin/systemctl ] ; then
# Using systemd
/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
)
sleep 0.1
/usr/bin/systemctl daemon-reload
2013-02-08 12:07:11 +00:00
fi
done
}
2013-01-27 18:11:30 +00:00
install_centos_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_centos_stable_deps || return 1
2015-04-30 12:05:57 +01:00
if [ " $( which git) " = "" ] ; then
2015-03-25 11:35:25 -04:00
# git not installed - need to install it
if [ " $DISTRO_NAME_L " = "oracle_linux" ] ; then
# try both ways --enablerepo=X disables ALL OTHER REPOS!!!!
2015-04-30 12:05:57 +01:00
yum install -y git || yum install -y git --enablerepo= ${ _EPEL_REPO } || return 1
2015-03-25 11:35:25 -04:00
else
2015-04-30 12:05:57 +01:00
yum install -y git --enablerepo= ${ _EPEL_REPO } || return 1
2015-03-25 11:35:25 -04:00
fi
2014-06-21 13:21:35 +01:00
fi
2015-05-01 16:42:55 +01:00
if [ " $DISTRO_MAJOR_VERSION " -gt 6 ] ; then
if [ " $DISTRO_NAME_L " != "oracle_linux" ] ; then
yum install -y systemd-python || yum install -y systemd-python --enablerepo= ${ _EPEL_REPO } || return 1
else
yum install -y systemd-python --enablerepo= ${ _EPEL_REPO } || return 1
fi
2015-04-30 12:05:57 +01:00
fi
2013-01-18 02:42:49 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-18 02:42:49 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
yum install -y python-tornado
fi
fi
2013-01-25 01:20:33 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_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
2013-03-06 22:05:31 +00:00
return 0
2012-10-22 03:39:33 +01:00
}
2013-01-27 18:11:30 +00:00
install_centos_git( ) {
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -eq 5 ] ; then
2014-02-16 22:01:31 +00:00
_PYEXE = python2.6
2013-02-12 22:44:12 +00:00
else
2014-02-16 22:01:31 +00:00
_PYEXE = python2
fi
2014-08-17 00:58:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /salt/syspaths.py " ] ; then
2015-07-16 21:13:20 +01:00
$_PYEXE setup.py install --salt-config-dir= " $_SALT_ETC_DIR " || \
$_PYEXE setup.py --salt-config-dir= " $_SALT_ETC_DIR " install || return 1
2014-02-16 22:01:31 +00:00
else
$_PYEXE setup.py install || return 1
2013-02-12 22:44:12 +00:00
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-22 03:39:33 +01:00
}
2013-01-27 18:11:30 +00:00
install_centos_git_post( ) {
2014-11-18 11:26:51 -08:00
SYSTEMD_RELOAD = $BS_FALSE
2014-10-17 15:36:28 +11:00
for fname in minion master syndic api; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:23:29 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2014-12-16 14:34:03 +00:00
if [ -f /bin/systemctl ] ; then
if [ ! -f /usr/lib/systemd/system/salt-${ fname } .service ] || ( [ -f /usr/lib/systemd/system/salt-${ fname } .service ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ] ) ; then
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- ${ fname } .service " /usr/lib/systemd/system/
2014-12-16 14:39:56 +00:00
fi
2014-11-18 11:26:51 -08:00
2014-12-16 14:39:56 +00:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-12-16 14:34:03 +00:00
2014-12-16 14:39:56 +00:00
/bin/systemctl enable salt-${ fname } .service
SYSTEMD_RELOAD = $BS_TRUE
2014-11-18 11:26:51 -08:00
2014-12-16 14:34:03 +00:00
elif [ ! -f /etc/init.d/salt-$fname ] || ( [ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ] ) ; then
2014-08-17 00:58:55 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- ${ fname } " /etc/init.d/
2013-02-08 12:09:37 +00:00
chmod +x /etc/init.d/salt-${ fname }
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-22 04:32:33 +00:00
/sbin/chkconfig salt-${ fname } on
2013-02-08 12:09:37 +00:00
fi
2014-02-26 23:02:56 +00:00
#if [ -f /sbin/initctl ]; then
# # We have upstart support
# /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
2014-08-17 00:58:55 +01:00
# copyfile ${__SALT_GIT_CHECKOUT_DIR}/pkg/salt-$fname.upstart /etc/init/salt-$fname.conf
2014-02-26 23:02:56 +00:00
# fi
## Still in SysV init?!
#elif [ ! -f /etc/init.d/salt-$fname ] || ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then
2014-08-17 00:58:55 +01:00
# copyfile ${__SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname} /etc/init.d/
2014-02-26 23:02:56 +00:00
# chmod +x /etc/init.d/salt-${fname}
# /sbin/chkconfig salt-${fname} on
#fi
2013-02-08 12:09:37 +00:00
done
2014-11-18 11:26:51 -08:00
if [ " $SYSTEMD_RELOAD " -eq $BS_TRUE ] ; then
/bin/systemctl daemon-reload
fi
2013-02-08 12:09:37 +00:00
}
2013-02-16 10:04:25 +00:00
install_centos_restart_daemons( ) {
2013-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-02-08 12:09:37 +00:00
# Skip if not meant to be installed
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-08 12:09:37 +00:00
2014-03-10 13:13:29 +00:00
if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${ fname } .conf ] ; then
2014-03-10 11:36:32 +00:00
# We have upstart support and upstart knows about our service
2013-01-26 18:00:10 +00:00
/sbin/initctl status salt-$fname > /dev/null 2>& 1
2014-03-10 11:36:32 +00:00
if [ $? -ne 0 ] ; then
# Everything is in place and upstart gave us an error code? Fail!
return 1
2013-01-26 17:38:48 +00:00
fi
2013-01-26 18:00:10 +00:00
2014-03-10 11:36:32 +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
/sbin/initctl start salt-$fname > /dev/null 2>& 1
# Restart service
if [ $? -ne 0 ] ; then
# Failed the restart?!
return 1
2013-01-26 17:38:48 +00:00
fi
2014-03-05 17:34:08 -03:00
elif [ -f /etc/init.d/salt-$fname ] ; then
2013-02-13 12:28:00 +00:00
# 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
2014-07-20 01:43:30 -04:00
elif [ -f /usr/bin/systemctl ] ; then
# CentOS 7 uses systemd
/usr/bin/systemctl stop salt-$fname > /dev/null 2>& 1
/usr/bin/systemctl start salt-$fname .service
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
}
2013-08-29 16:46:44 -04:00
install_centos_testing_deps( ) {
install_centos_stable_deps || return 1
return 0
}
install_centos_testing( ) {
install_centos_stable || return 1
return 0
}
install_centos_testing_post( ) {
install_centos_stable_post || return 1
return 0
}
2014-02-20 13:02:10 +00:00
install_centos_check_services( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-20 13:02:10 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2014-03-10 13:09:25 +00:00
if [ -f /sbin/initctl ] && [ -f /etc/init/salt-${ fname } .conf ] ; then
2014-03-10 11:46:14 +00:00
__check_services_upstart salt-$fname || return 1
2014-03-05 17:34:08 -03:00
elif [ -f /etc/init.d/salt-$fname ] ; then
2014-03-10 11:46:14 +00:00
__check_services_sysvinit salt-$fname || return 1
2014-07-20 01:43:30 -04:00
elif [ -f /usr/bin/systemctl ] ; then
__check_services_systemd salt-$fname || return 1
2014-03-10 11:46:14 +00:00
fi
2014-02-20 13:02:10 +00:00
done
return 0
}
2012-10-17 16:07:33 +01:00
#
# Ended CentOS Install Functions
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-17 14:02:09 +01:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-01-27 17:46:55 +00:00
#
# RedHat Install Functions
#
2014-06-24 11:39:08 +01:00
__test_rhel_optionals_packages( ) {
2014-07-21 22:21:10 +01:00
__install_epel_repository || return 1
2014-06-16 09:39:30 +01:00
2015-07-14 14:48:12 +01:00
# Make sure yum-utils is installed
yum list installed yum-utils > /dev/null 2>& 1 || yum -y install yum-utils --enablerepo= ${ _EPEL_REPO } || return 1
2015-02-16 01:55:00 +00:00
if [ " $DISTRO_MAJOR_VERSION " -ge 7 ] ; then
yum-config-manager --enable \* server-optional || return 1
fi
2014-07-22 14:01:26 +01:00
if [ " $DISTRO_MAJOR_VERSION " -ge 6 ] ; then
2015-07-11 14:14:00 +00:00
#python-jinja2 is in repo server-releases-optional in EC2/RHEL6
yum-config-manager --enable rhui-\* -server-releases-optional || return 1
2014-06-16 09:39:30 +01:00
# Let's enable package installation testing, kind of, --dry-run
2014-07-23 01:12:02 +01:00
echoinfo "Testing if packages usually on the optionals repository are available:"
__YUM_CONF_DIR = " $( mktemp -d) "
__YUM_CONF_FILE = " ${ __YUM_CONF_DIR } /yum.conf "
cp /etc/yum.conf " ${ __YUM_CONF_FILE } "
echo 'tsflags=test' >> " ${ __YUM_CONF_FILE } "
2014-06-16 09:39:30 +01:00
# Let's try installing the packages that usually require the optional repository
2014-06-22 12:19:42 +01:00
# shellcheck disable=SC2043
2014-06-16 09:39:30 +01:00
for package in python-jinja2; do
2014-07-23 01:12:02 +01:00
echoinfo " - ${ package } "
2014-06-21 18:16:23 +01:00
if [ " $DISTRO_NAME_L " = "oracle_linux" ] ; then
2014-07-23 01:12:02 +01:00
yum --config " ${ __YUM_CONF_FILE } " install -y ${ package } >/dev/null 2>& 1 || \
yum --config " ${ __YUM_CONF_FILE } " install -y ${ package } --enablerepo= ${ _EPEL_REPO } >/dev/null 2>& 1
2014-06-21 18:16:23 +01:00
else
2014-07-23 01:12:02 +01:00
yum --config " ${ __YUM_CONF_FILE } " install -y ${ package } --enablerepo= ${ _EPEL_REPO } >/dev/null 2>& 1
2014-06-21 18:16:23 +01:00
fi
2014-06-16 09:39:30 +01:00
if [ $? -ne 0 ] ; then
2014-08-29 14:38:39 -04:00
echoerror " Failed to find an installable ' ${ package } ' package. The optional repository or its subscription might be missing. "
2014-07-23 01:12:02 +01:00
rm -rf " ${ __YUM_CONF_DIR } "
2014-06-16 09:39:30 +01:00
return 1
fi
done
2014-07-23 01:12:02 +01:00
rm -rf " ${ __YUM_CONF_DIR } "
2013-08-19 10:10:07 -07:00
fi
2014-06-24 11:39:08 +01:00
return 0
}
2014-06-16 09:39:30 +01:00
2014-06-24 11:39:08 +01:00
install_red_hat_linux_stable_deps( ) {
2014-07-25 17:05:32 +01:00
if [ " ${ DISTRO_MAJOR_VERSION } " -ge 6 ] ; then
# Wait at most 60 seconds for the repository subscriptions to register
__ATTEMPTS = 6
while [ " ${ __ATTEMPTS } " -gt 0 ] ; do
__test_rhel_optionals_packages
if [ $? -eq 1 ] ; then
__ATTEMPTS = $(( __ATTEMPTS - 1 ))
if [ ${ __ATTEMPTS } -lt 1 ] ; then
return 1
fi
echoinfo "Sleeping 10 seconds while waiting for the optional repository subscription to be externally configured"
sleep 10
continue
2014-07-28 18:29:11 -07:00
else
break
2014-07-25 17:05:32 +01:00
fi
done
else
__test_rhel_optionals_packages || return 1
fi
2013-03-23 11:55:45 +00:00
install_centos_stable_deps || return 1
return 0
2013-01-27 18:11:30 +00:00
}
install_red_hat_linux_git_deps( ) {
2014-07-25 17:05:32 +01:00
if [ " ${ DISTRO_MAJOR_VERSION } " -ge 6 ] ; then
# Wait at most 60 seconds for the repository subscriptions to register
__ATTEMPTS = 6
while [ " ${ __ATTEMPTS } " -gt 0 ] ; do
__test_rhel_optionals_packages
if [ $? -eq 1 ] ; then
__ATTEMPTS = $(( __ATTEMPTS - 1 ))
if [ ${ __ATTEMPTS } -lt 1 ] ; then
return 1
fi
echoinfo "Sleeping 10 seconds while waiting for the optional repository subscription to be externally configured"
sleep 10
continue
2014-07-28 18:29:11 -07:00
else
break
2014-07-25 17:05:32 +01:00
fi
done
else
__test_rhel_optionals_packages || return 1
fi
2013-03-23 11:55:45 +00:00
install_centos_git_deps || return 1
return 0
2013-01-27 18:11:30 +00:00
}
install_red_hat_enterprise_linux_stable_deps( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_stable_deps || return 1
return 0
2013-01-27 18:11:30 +00:00
}
install_red_hat_enterprise_linux_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_git_deps || return 1
return 0
2013-01-27 18:11:30 +00:00
}
2013-02-23 18:30:51 +00:00
install_red_hat_enterprise_server_stable_deps( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_stable_deps || return 1
return 0
2013-02-23 18:30:51 +00:00
}
install_red_hat_enterprise_server_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_git_deps || return 1
return 0
2013-02-23 18:30:51 +00:00
}
2014-02-14 20:52:16 +00:00
install_red_hat_enterprise_workstation_stable_deps( ) {
install_red_hat_linux_stable_deps || return 1
return 0
}
install_red_hat_enterprise_workstation_git_deps( ) {
install_red_hat_linux_git_deps || return 1
return 0
}
2013-01-27 18:11:30 +00:00
install_red_hat_linux_stable( ) {
2013-03-23 11:55:45 +00:00
install_centos_stable || return 1
return 0
2013-01-27 18:11:30 +00:00
}
install_red_hat_linux_git( ) {
2013-03-23 11:55:45 +00:00
install_centos_git || return 1
return 0
2013-01-27 18:11:30 +00:00
}
install_red_hat_enterprise_linux_stable( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_stable || return 1
return 0
2013-01-27 17:46:55 +00:00
}
2013-01-27 18:11:30 +00:00
install_red_hat_enterprise_linux_git( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_git || return 1
return 0
2013-01-27 17:46:55 +00:00
}
2013-02-23 18:30:51 +00:00
install_red_hat_enterprise_server_stable( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_stable || return 1
return 0
2013-02-23 18:30:51 +00:00
}
install_red_hat_enterprise_server_git( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_git || return 1
return 0
2013-02-23 18:30:51 +00:00
}
2014-02-14 20:52:16 +00:00
install_red_hat_enterprise_workstation_stable( ) {
install_red_hat_linux_stable || return 1
return 0
}
install_red_hat_enterprise_workstation_git( ) {
install_red_hat_linux_git || return 1
return 0
}
2013-01-27 18:11:30 +00:00
install_red_hat_linux_stable_post( ) {
2013-03-23 11:55:45 +00:00
install_centos_stable_post || return 1
return 0
2013-01-27 17:46:55 +00:00
}
2013-02-16 10:04:25 +00:00
install_red_hat_linux_restart_daemons( ) {
2013-03-23 11:55:45 +00:00
install_centos_restart_daemons || return 1
return 0
2013-02-08 12:12:08 +00:00
}
2013-01-27 18:11:30 +00:00
install_red_hat_linux_git_post( ) {
2013-03-23 11:55:45 +00:00
install_centos_git_post || return 1
return 0
2013-01-27 17:46:55 +00:00
}
2013-01-27 18:11:30 +00:00
install_red_hat_enterprise_linux_stable_post( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_stable_post || return 1
return 0
2013-01-27 17:46:55 +00:00
}
2013-02-16 10:04:25 +00:00
install_red_hat_enterprise_linux_restart_daemons( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_restart_daemons || return 1
return 0
2013-02-08 12:12:08 +00:00
}
2013-01-27 18:11:30 +00:00
install_red_hat_enterprise_linux_git_post( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_git_post || return 1
return 0
2013-01-27 17:46:55 +00:00
}
2013-02-23 18:30:51 +00:00
install_red_hat_enterprise_server_stable_post( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_stable_post || return 1
return 0
2013-02-23 18:30:51 +00:00
}
install_red_hat_enterprise_server_restart_daemons( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_restart_daemons || return 1
return 0
2013-02-23 18:30:51 +00:00
}
install_red_hat_enterprise_server_git_post( ) {
2013-03-23 11:55:45 +00:00
install_red_hat_linux_git_post || return 1
return 0
2013-02-23 18:30:51 +00:00
}
2013-08-29 16:46:44 -04:00
2014-02-14 20:52:16 +00:00
install_red_hat_enterprise_workstation_stable_post( ) {
install_red_hat_linux_stable_post || return 1
return 0
}
install_red_hat_enterprise_workstation_restart_daemons( ) {
install_red_hat_linux_restart_daemons || return 1
return 0
}
install_red_hat_enterprise_workstation_git_post( ) {
install_red_hat_linux_git_post || return 1
return 0
}
2013-08-29 16:46:44 -04:00
install_red_hat_linux_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
install_red_hat_linux_testing( ) {
install_centos_testing || return 1
return 0
}
install_red_hat_linux_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
install_red_hat_enterprise_server_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
install_red_hat_enterprise_server_testing( ) {
install_centos_testing || return 1
return 0
}
install_red_hat_enterprise_server_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
2014-02-14 20:52:16 +00:00
install_red_hat_enterprise_workstation_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
2013-08-29 16:46:44 -04:00
2014-02-14 20:52:16 +00:00
install_red_hat_enterprise_workstation_testing( ) {
install_centos_testing || return 1
return 0
}
2013-08-29 16:46:44 -04:00
2014-02-14 20:52:16 +00:00
install_red_hat_enterprise_workstation_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
2013-01-27 17:46:55 +00:00
#
# Ended RedHat Install Functions
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-01-31 18:52:58 +00:00
2014-03-19 19:11:18 +00:00
2014-03-07 00:33:16 -06:00
#######################################################################################################################
#
2014-03-15 16:35:31 +00:00
# Oracle Linux Install Functions
2014-03-07 00:33:16 -06:00
#
2014-03-15 16:35:31 +00:00
install_oracle_linux_stable_deps( ) {
2014-06-25 10:23:13 +01:00
__test_rhel_optionals_packages || return 1
2014-03-07 00:33:16 -06:00
install_centos_stable_deps || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_git_deps( ) {
2014-06-25 10:23:13 +01:00
__test_rhel_optionals_packages || return 1
2014-03-07 00:33:16 -06:00
install_centos_git_deps || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_testing_deps( ) {
2014-03-07 00:33:16 -06:00
install_centos_testing_deps || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_stable( ) {
2014-03-07 00:33:16 -06:00
install_centos_stable || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_git( ) {
2014-03-07 00:33:16 -06:00
install_centos_git || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_testing( ) {
2014-03-07 00:33:16 -06:00
install_centos_testing || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_stable_post( ) {
2014-03-07 00:33:16 -06:00
install_centos_stable_post || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_git_post( ) {
2014-03-07 00:33:16 -06:00
install_centos_git_post || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_testing_post( ) {
2014-03-07 00:33:16 -06:00
install_centos_testing_post || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_restart_daemons( ) {
2014-03-07 00:33:16 -06:00
install_centos_restart_daemons || return 1
return 0
}
2014-03-15 16:35:31 +00:00
install_oracle_linux_check_services( ) {
2014-03-07 00:33:16 -06:00
install_centos_check_services || return 1
return 0
}
#
2014-03-15 16:35:31 +00:00
# Ended Oracle Linux Install Functions
2014-03-07 00:33:16 -06:00
#
#######################################################################################################################
2014-03-19 19:11:18 +00:00
#######################################################################################################################
#
# Scientific Linux Install Functions
#
install_scientific_linux_stable_deps( ) {
install_centos_stable_deps || return 1
return 0
}
install_scientific_linux_git_deps( ) {
install_centos_git_deps || return 1
return 0
}
install_scientific_linux_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
install_scientific_linux_stable( ) {
install_centos_stable || return 1
return 0
}
install_scientific_linux_git( ) {
install_centos_git || return 1
return 0
}
install_scientific_linux_testing( ) {
install_centos_testing || return 1
return 0
}
install_scientific_linux_stable_post( ) {
install_centos_stable_post || return 1
return 0
}
install_scientific_linux_git_post( ) {
install_centos_git_post || return 1
return 0
}
install_scientific_linux_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
install_scientific_linux_restart_daemons( ) {
install_centos_restart_daemons || return 1
return 0
}
install_scientific_linux_check_services( ) {
install_centos_check_services || return 1
return 0
}
#
# Ended Scientific Linux Install Functions
#
#######################################################################################################################
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-01-31 18:52:58 +00:00
#
# Amazon Linux AMI Install Functions
#
2014-07-19 19:54:12 +01:00
install_amazon_linux_ami_2010_deps( ) {
# Linux Amazon AMI 2010.xx seems to use EPEL5 but the system is based on CentOS6.
# Supporting this would be quite troublesome and we need to workaround some serious package conflicts
echoerror "Amazon Linux AMI 2010 is not supported. Please use a more recent image (Amazon Linux AMI >= 2011.xx)"
exit 1
}
install_amazon_linux_ami_2010_git_deps( ) {
# Linux Amazon AMI 2010.xx seems to use EPEL5 but the system is based on CentOS6.
# Supporting this would be quite troublesome and we need to workaround some serious package conflicts
echoerror "Amazon Linux AMI 2010 is not supported. Please use a more recent image (Amazon Linux AMI >= 2011.xx)"
exit 1
}
2013-01-31 18:52:58 +00:00
install_amazon_linux_ami_deps( ) {
2014-01-27 17:14:49 +00:00
# According to http://aws.amazon.com/amazon-linux-ami/faqs/#epel we should
2015-05-01 14:30:55 +01:00
2013-01-31 18:52:58 +00:00
# enable the EPEL 6 repo
2014-06-21 18:58:16 +01:00
if [ " $CPU_ARCH_L " = "i686" ] ; then
2013-01-31 18:52:58 +00:00
EPEL_ARCH = "i386"
else
EPEL_ARCH = $CPU_ARCH_L
fi
2014-06-21 19:19:54 +01:00
rpm -Uvh --force " http://mirrors.kernel.org/fedora-epel/6/ ${ EPEL_ARCH } /epel-release-6-8.noarch.rpm " || return 1
2013-08-05 23:36:18 +01:00
2015-05-01 14:30:55 +01:00
__REPO_FILENAME = "saltstack-salt-epel-6.repo"
if [ ! -s " /etc/yum.repos.d/ ${ __REPO_FILENAME } " ] ; then
echoinfo "Adding SaltStack's COPR repository"
__fetch_url /etc/yum.repos.d/${ __REPO_FILENAME } \
" http://copr.fedoraproject.org/coprs/saltstack/salt/repo/epel-6/ ${ __REPO_FILENAME } " || return 1
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2013-08-05 23:36:18 +01:00
yum -y update || return 1
fi
2014-07-06 00:38:13 +01:00
__PACKAGES = "PyYAML m2crypto python-crypto python-msgpack python-zmq python-ordereddict python-jinja2 python-requests"
2014-02-16 17:25:07 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-pip "
2014-02-16 17:25:07 +00:00
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-07-06 00:38:13 +01:00
yum -y install ${ __PACKAGES } --enablerepo= ${ _EPEL_REPO } "" || return 1
2014-02-16 17:25:07 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2014-04-04 15:52:43 +08:00
pip-python install " apache-libcloud>= $_LIBCLOUD_MIN_VERSION "
2014-02-16 17:25:07 +00:00
fi
2014-02-16 21:38:15 +00:00
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
yum install -y ${ _EXTRA_PACKAGES } --enablerepo= ${ _EPEL_REPO } || return 1
fi
2013-01-31 18:52:58 +00:00
}
install_amazon_linux_ami_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_amazon_linux_ami_deps || return 1
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
yum -y install git --enablerepo= ${ _EPEL_REPO } || return 1
fi
2013-01-31 18:52:58 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-31 18:52:58 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
yum install -y python-tornado
fi
fi
2013-01-31 18:52:58 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_TEMP_CONFIG_DIR = " ${ __SALT_GIT_CHECKOUT_DIR } /conf/ "
2013-01-31 18:52:58 +00:00
CONFIG_SALT_FUNC = "config_salt"
fi
2013-03-06 22:05:31 +00:00
return 0
2013-01-31 18:52:58 +00:00
}
install_amazon_linux_ami_stable( ) {
2013-03-23 11:55:45 +00:00
install_centos_stable || return 1
return 0
2013-01-31 18:52:58 +00:00
}
2013-02-08 12:15:11 +00:00
install_amazon_linux_ami_stable_post( ) {
2013-03-23 11:55:45 +00:00
install_centos_stable_post || return 1
return 0
2013-02-08 12:15:11 +00:00
}
2013-02-16 10:04:25 +00:00
install_amazon_linux_ami_restart_daemons( ) {
2013-03-23 11:55:45 +00:00
install_centos_restart_daemons || return 1
return 0
2013-02-08 12:15:11 +00:00
}
2013-01-31 18:52:58 +00:00
install_amazon_linux_ami_git( ) {
2013-03-23 11:55:45 +00:00
install_centos_git || return 1
return 0
2013-01-31 18:52:58 +00:00
}
install_amazon_linux_ami_git_post( ) {
2013-03-23 11:55:45 +00:00
install_centos_git_post || return 1
return 0
2013-01-31 18:52:58 +00:00
}
2013-08-29 16:46:44 -04:00
install_amazon_linux_ami_testing( ) {
install_centos_testing || return 1
return 0
}
install_amazon_linux_ami_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
2013-01-31 18:52:58 +00:00
#
# Ended Amazon Linux AMI Install Functions
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-01-27 17:46:55 +00:00
2014-02-20 10:36:34 +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( ) {
2014-02-16 17:28:52 +00:00
2014-09-27 14:23:48 +01:00
if [ ! -f /etc/pacman.d/gnupg ] ; then
pacman-key --init && pacman-key --populate archlinux || return 1
fi
2015-01-07 03:01:23 +00:00
pacman -Sy --noconfirm --needed pacman || return 1
2015-01-07 01:28:32 +00:00
if [ " $( which pacman-db-upgrade) " != "" ] ; then
pacman-db-upgrade || return 1
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2014-02-16 17:28:52 +00:00
pacman -Syyu --noconfirm --needed || return 1
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-02-16 17:28:52 +00:00
pacman -Sy --noconfirm --needed apache-libcloud || return 1
fi
2014-02-16 21:38:15 +00:00
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
pacman -Sy --noconfirm --needed ${ _EXTRA_PACKAGES } || return 1
fi
2012-10-19 21:16:00 -07:00
}
2013-02-23 02:13:26 +00:00
install_arch_linux_git_deps( ) {
2013-05-22 09:29:04 +01:00
install_arch_linux_stable_deps
2013-01-23 14:33:06 +00:00
2013-09-28 11:29:00 +01:00
# Don't fail if un-installing python2-distribute threw an error
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
pacman -Sy --noconfirm --needed git || return 1
fi
2015-01-07 02:36:36 +00:00
pacman -R --noconfirm python2-distribute
2015-04-30 12:12:22 +01:00
pacman -Sy --noconfirm --needed python2-crypto python2-setuptools python2-jinja \
2014-04-07 19:28:54 +01:00
python2-m2crypto python2-markupsafe python2-msgpack python2-psutil python2-yaml \
2014-10-26 18:54:12 +00:00
python2-pyzmq zeromq python2-requests python2-systemd || return 1
2013-01-18 02:42:49 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-18 02:42:49 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
pacman -Sy --noconfirm --needed python2-tornado
fi
fi
2013-01-25 01:20:33 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_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
2013-03-06 22:05:31 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2013-02-23 02:13:26 +00:00
install_arch_linux_stable( ) {
2014-02-08 03:45:08 +00:00
pacman -Sy --noconfirm --needed pacman || return 1
2013-06-04 13:04:36 +01:00
# See https://mailman.archlinux.org/pipermail/arch-dev-public/2013-June/025043.html
# to know why we're ignoring below.
pacman -Syu --noconfirm --ignore filesystem,bash || return 1
2014-02-08 03:45:08 +00:00
pacman -S --noconfirm --needed bash || return 1
2013-06-04 13:04:36 +01:00
pacman -Su --noconfirm || return 1
# We can now resume regular salt update
2015-03-04 15:52:19 +00:00
pacman -Syu --noconfirm salt-zmq || return 1
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2013-02-23 02:13:26 +00:00
install_arch_linux_git( ) {
2014-08-17 00:58:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /salt/syspaths.py " ] ; then
2015-07-16 21:13:20 +01:00
python2 setup.py install --salt-config-dir= " $_SALT_ETC_DIR " || \
python2 setup.py --salt-config-dir= " $_SALT_ETC_DIR " install || return 1
2014-02-16 22:01:31 +00:00
else
python2 setup.py install || return 1
fi
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2013-02-23 02:13:26 +00:00
install_arch_linux_post( ) {
2013-06-19 15:42:08 +01:00
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-01-26 18:43:48 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-26 18:43:48 +00:00
2013-06-19 15:42:08 +01:00
# Since Arch's pacman renames configuration files
2014-06-21 18:58:16 +01:00
if [ " $_TEMP_CONFIG_DIR " != "null" ] && [ -f " $_SALT_ETC_DIR / $fname .pacorig " ] ; then
2013-06-19 15:42:08 +01:00
# Since a configuration directory was provided, it also means that any
# configuration file copied was renamed by Arch, see:
# https://wiki.archlinux.org/index.php/Pacnew_and_Pacsave_Files#.pacorig
2014-06-21 18:58:16 +01:00
copyfile " $_SALT_ETC_DIR / $fname .pacorig " " $_SALT_ETC_DIR / $fname " $BS_TRUE
2013-06-19 15:42:08 +01:00
fi
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && 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( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
if [ -f /usr/bin/systemctl ] ; then
2014-08-17 00:58:55 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
2013-01-22 21:19:58 +00:00
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-08-14 06:11:59 +01: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!?
2014-08-17 00:58:55 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- $fname " " /etc/rc.d/init.d/salt- $fname "
2013-01-26 18:43:48 +00:00
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-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-08 12:33:47 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $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-03-06 20:15:36 +00:00
/etc/rc.d/salt-$fname start
2013-02-08 12:33:47 +00:00
done
}
2014-02-20 12:03:23 +00:00
install_arch_check_services( ) {
if [ ! -f /usr/bin/systemctl ] ; then
# Not running systemd!? Don't check!
return 0
fi
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-20 12:03:23 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2014-02-20 12:03:23 +00:00
__check_services_systemd salt-$fname || return 1
done
return 0
}
2012-10-19 21:16:00 -07:00
#
# Ended Arch Install Functions
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-19 21:16:00 -07:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-19 21:16:00 -07:00
#
# FreeBSD Install Functions
#
2013-02-12 00:20:58 +00:00
__freebsd_get_packagesite( ) {
2014-06-21 18:58:16 +01:00
if [ " $CPU_ARCH_L " = "amd64" ] ; then
2013-01-21 13:41:56 +00:00
BSD_ARCH = "x86:64"
2014-06-21 18:58:16 +01:00
elif [ " $CPU_ARCH_L " = "x86_64" ] ; then
2013-01-21 13:41:56 +00:00
BSD_ARCH = "x86:64"
2014-06-21 18:58:16 +01:00
elif [ " $CPU_ARCH_L " = "i386" ] ; then
2013-01-21 13:41:56 +00:00
BSD_ARCH = "x86:32"
2014-06-21 18:58:16 +01: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-12-19 23:21:19 +00:00
# Since the variable might not be set, don't, momentarily treat it as a
# failure
2013-04-12 12:36:52 +01:00
set +o nounset
2014-01-09 19:31:42 +00:00
# ABI is a std format for identifying release / architecture combos
2013-12-19 23:21:19 +00:00
ABI = " freebsd: ${ DISTRO_MAJOR_VERSION } : ${ BSD_ARCH } "
_PACKAGESITE = " http://pkg.freebsd.org/ ${ ABI } /latest "
2014-01-09 19:31:42 +00:00
# Awkwardly, we want the `${ABI}` to be in conf file without escaping
2013-12-19 23:21:19 +00:00
PKGCONFURL = "pkg+http://pkg.freebsd.org/\${ABI}/latest"
2013-04-12 12:36:52 +01:00
# Treat unset variables as errors once more
set -o nounset
2013-02-12 00:20:58 +00:00
}
2014-01-27 17:14:49 +00:00
# Using a separate conf step to head for idempotent install...
2014-01-09 19:31:42 +00:00
__configure_freebsd_pkg_details( ) {
2013-12-19 23:21:19 +00:00
2015-03-12 04:00:24 -07:00
## pkg.conf is deprecated.
2013-12-19 23:21:19 +00:00
## We use conf files in /usr/local or /etc instead
mkdir -p /usr/local/etc/pkg/repos/
mkdir -p /etc/pkg/
## Use new JSON-like format for pkg repo configs
conf_file = /usr/local/etc/pkg/repos/freebsd.conf
2014-06-22 11:34:16 +01:00
{
echo "FreeBSD:{"
echo " url: \" ${ PKGCONFURL } \", "
echo " mirror_type: \"SRV\","
echo " enabled: true"
echo "}"
} > $conf_file
2014-01-09 19:31:42 +00:00
copyfile $conf_file /etc/pkg/FreeBSD.conf
2013-12-19 23:21:19 +00:00
SALT_PKG_FLAGS = "-r FreeBSD"
## ensure future ports builds use pkgng
2015-04-01 02:18:08 +02:00
echo "WITH_PKGNG= yes" >> /etc/make.conf
2013-12-19 23:21:19 +00:00
}
2013-02-12 21:18:57 +00:00
install_freebsd_9_stable_deps( ) {
2013-12-19 23:21:19 +00:00
#make variables available even if pkg already installed
__freebsd_get_packagesite
2013-05-31 12:57:01 +01:00
if [ ! -x /usr/local/sbin/pkg ] ; then
2013-02-12 00:20:58 +00:00
2013-12-19 23:21:19 +00:00
# install new `pkg` code from its own tarball.
2013-08-22 19:58:41 +01:00
fetch " ${ _PACKAGESITE } /Latest/pkg.txz " || return 1
2013-05-31 12:57:01 +01:00
tar xf ./pkg.txz -s ",/.*/,,g" "*/pkg-static" || return 1
./pkg-static add ./pkg.txz || return 1
/usr/local/sbin/pkg2ng || return 1
fi
2013-08-22 19:51:19 +01:00
2014-01-09 19:31:42 +00:00
# Configure the pkg repository using new approach
__configure_freebsd_pkg_details || return 1
2013-08-21 15:09:47 -06:00
2014-01-09 19:31:42 +00:00
# Now install swig
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2013-11-21 10:15:59 -05:00
/usr/local/sbin/pkg install ${ SALT_PKG_FLAGS } -y swig || return 1
2012-12-03 14:34:38 -07:00
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
/usr/local/sbin/pkg install ${ SALT_PKG_FLAGS } -y ${ _EXTRA_PACKAGES } || return 1
fi
2014-12-14 10:36:56 -08:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
pkg upgrade -y || return 1
fi
2013-12-03 12:33:09 -05:00
return 0
}
2013-05-15 13:23:38 +01:00
2014-01-30 20:16:01 -08:00
install_freebsd_10_stable_deps( ) {
install_freebsd_9_stable_deps
}
2013-12-03 12:33:09 -05:00
config_freebsd_salt( ) {
# Set _SALT_ETC_DIR to ports default
2013-08-22 20:50:48 +01:00
_SALT_ETC_DIR = ${ BS_SALT_ETC_DIR :- /usr/local/etc/salt }
2013-07-07 21:57:46 +01:00
# We also need to redefine the PKI directory
2013-08-22 20:50:48 +01:00
_PKI_DIR = ${ _SALT_ETC_DIR } /pki
2013-05-15 13:23:38 +01:00
2013-12-03 12:33:09 -05:00
config_salt || return 1
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
install_freebsd_git_deps( ) {
2013-08-20 18:00:03 +01:00
install_freebsd_9_stable_deps || return 1
2012-10-23 08:09:12 +01:00
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
/usr/local/sbin/pkg install -y git || return 1
fi
/usr/local/sbin/pkg install -y www/py-requests || return 1
2013-01-18 02:42:49 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-08-20 18:00:03 +01:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
/usr/local/sbin/pkg install -y www/py-tornado || return 1
fi
fi
2013-09-04 08:06:00 +01:00
echodebug "Adapting paths to FreeBSD"
2013-08-20 18:00:03 +01:00
# The list of files was taken from Salt's BSD port Makefile
2013-09-04 08:06:00 +01:00
for file in doc/man/salt-key.1 doc/man/salt-cp.1 doc/man/salt-minion.1 \
doc/man/salt-syndic.1 doc/man/salt-master.1 doc/man/salt-run.1 \
doc/man/salt.7 doc/man/salt.1 doc/man/salt-call.1; do
2013-08-20 20:38:31 +01:00
[ ! -f $file ] && continue
2013-08-20 18:00:03 +01:00
echodebug " Patching ${ file } "
2015-04-01 02:18:08 +02:00
sed -in -e " s|/etc/salt| ${ _SALT_ETC_DIR } | " \
-e " s|/srv/salt| ${ _SALT_ETC_DIR } /states| " \
-e " s|/srv/pillar| ${ _SALT_ETC_DIR } /pillar| " ${ file }
2013-08-20 18:00:03 +01:00
done
2013-09-04 08:06:00 +01:00
if [ ! -f salt/syspaths.py ] ; then
# We still can't provide the system paths, salt 0.16.x
# Let's patch salt's source and adapt paths to what's expected on FreeBSD
2015-04-01 02:18:08 +02:00
echodebug " Replacing occurrences of '/etc/salt' with \' ${ _SALT_ETC_DIR } \' "
2013-09-04 08:06:00 +01:00
# The list of files was taken from Salt's BSD port Makefile
for file in conf/minion conf/master salt/config.py salt/client.py \
salt/modules/mysql.py salt/utils/parsers.py salt/modules/tls.py \
salt/modules/postgres.py salt/utils/migrations.py; do
[ ! -f $file ] && continue
echodebug " Patching ${ file } "
2015-04-01 02:18:08 +02:00
sed -in -e " s|/etc/salt| ${ _SALT_ETC_DIR } | " \
-e " s|/srv/salt| ${ _SALT_ETC_DIR } /states| " \
-e " s|/srv/pillar| ${ _SALT_ETC_DIR } /pillar| " ${ file }
2013-09-04 08:06:00 +01:00
done
fi
2013-08-20 18:00:03 +01:00
echodebug "Finished patching"
2013-01-25 01:20:33 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_TEMP_CONFIG_DIR = " ${ __SALT_GIT_CHECKOUT_DIR } /conf/ "
2015-04-01 02:18:08 +02:00
CONFIG_SALT_FUNC = "config_freebsd_salt"
2013-01-18 02:42:49 +00:00
fi
2013-03-06 22:05:31 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2013-02-12 21:18:57 +00:00
install_freebsd_9_stable( ) {
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2013-11-21 10:15:59 -05:00
/usr/local/sbin/pkg install ${ SALT_PKG_FLAGS } -y sysutils/py-salt || return 1
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2014-01-30 20:16:01 -08:00
install_freebsd_10_stable( ) {
install_freebsd_9_stable
}
2012-10-19 21:16:00 -07:00
install_freebsd_git( ) {
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2013-11-21 10:15:59 -05:00
/usr/local/sbin/pkg install ${ SALT_PKG_FLAGS } -y sysutils/py-salt || return 1
2013-06-09 02:33:12 +01:00
2013-07-18 16:34:24 +01:00
# Let's keep the rc.d files before deleting the package
2013-06-09 02:35:19 +01:00
mkdir /tmp/rc-scripts || return 1
cp /usr/local/etc/rc.d/salt* /tmp/rc-scripts || return 1
2013-06-09 02:33:12 +01:00
# Let's delete the package
2013-03-23 11:55:45 +00:00
/usr/local/sbin/pkg delete -y sysutils/py-salt || return 1
2012-10-27 07:31:14 +01:00
2013-06-09 02:33:12 +01:00
# Install from git
2013-09-04 08:06:00 +01:00
if [ ! -f salt/syspaths.py ] ; then
# We still can't provide the system paths, salt 0.16.x
2014-10-16 18:50:50 -07:00
/usr/local/bin/python2 setup.py install || return 1
2013-09-04 08:06:00 +01:00
else
2014-10-16 18:50:50 -07:00
/usr/local/bin/python2 setup.py install \
2013-09-04 08:06:00 +01:00
--salt-root-dir= /usr/local \
2014-06-21 18:58:16 +01:00
--salt-config-dir= " ${ _SALT_ETC_DIR } " \
2013-09-04 08:06:00 +01:00
--salt-cache-dir= /var/cache/salt \
--salt-sock-dir= /var/run/salt \
--salt-srv-root-dir= /srv \
2015-04-01 09:49:11 +01:00
--salt-base-file-roots-dir= " ${ _SALT_ETC_DIR } /states " \
--salt-base-pillar-roots-dir= " ${ _SALT_ETC_DIR } /pillar " \
--salt-base-master-roots-dir= " ${ _SALT_ETC_DIR } /salt-master " \
2013-09-04 08:06:00 +01:00
--salt-logs-dir= /var/log/salt \
--salt-pidfile-dir= /var/run \
2015-07-16 21:13:20 +01:00
|| /usr/local/bin/python2 setup.py \
--salt-root-dir= /usr/local \
--salt-config-dir= " ${ _SALT_ETC_DIR } " \
--salt-cache-dir= /var/cache/salt \
--salt-sock-dir= /var/run/salt \
--salt-srv-root-dir= /srv \
--salt-base-file-roots-dir= " ${ _SALT_ETC_DIR } /states " \
--salt-base-pillar-roots-dir= " ${ _SALT_ETC_DIR } /pillar " \
--salt-base-master-roots-dir= " ${ _SALT_ETC_DIR } /salt-master " \
--salt-logs-dir= /var/log/salt \
--salt-pidfile-dir= /var/run install \
2013-09-04 08:06:00 +01:00
|| return 1
fi
2013-06-09 02:33:12 +01:00
# Restore the rc.d scripts
2013-06-09 02:35:19 +01:00
cp /tmp/rc-scripts/salt* /usr/local/etc/rc.d/ || return 1
2013-06-09 02:33:12 +01:00
# Delete our temporary scripts directory
2013-06-09 02:35:19 +01:00
rm -rf /tmp/rc-scripts || return 1
2013-06-09 02:33:12 +01:00
# And we're good to go
2013-03-23 11:55:45 +00:00
return 0
2012-10-19 21:16:00 -07:00
}
2013-02-12 21:18:57 +00:00
install_freebsd_9_stable_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-02-08 12:38:00 +00:00
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-08 12:38:00 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $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
2015-04-01 09:49:11 +01:00
[ -f " ${ _SALT_ETC_DIR } / ${ fname } .sample " ] && copyfile " ${ _SALT_ETC_DIR } / ${ fname } .sample " " ${ _SALT_ETC_DIR } / ${ 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
}
2014-01-30 20:16:01 -08:00
install_freebsd_10_stable_post( ) {
install_freebsd_9_stable_post
}
2013-02-07 08:46:01 +00:00
install_freebsd_git_post( ) {
2013-03-23 11:55:45 +00:00
install_freebsd_9_stable_post || return 1
return 0
2013-02-08 12:38:00 +00:00
}
2013-02-16 10:04:25 +00:00
install_freebsd_restart_daemons( ) {
2013-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-08 12:38:00 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $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-03-06 20:15:36 +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
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-19 21:16:00 -07:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-01-27 23:12:58 +00:00
#
# SmartOS Install Functions
#
install_smartos_deps( ) {
2014-07-20 20:59:56 +01:00
pkgin -y install zeromq py27-m2crypto py27-crypto py27-msgpack py27-yaml py27-jinja2 py27-zmq py27-requests || return 1
2013-01-27 23:12:58 +00:00
2015-07-15 22:09:06 -04:00
# Set _SALT_ETC_DIR to SmartOS default if they didn't specify
_SALT_ETC_DIR = ${ BS_SALT_ETC_DIR :- /opt/local/etc/salt }
# We also need to redefine the PKI directory
_PKI_DIR = ${ _SALT_ETC_DIR } /pki
2013-01-27 23:12:58 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2013-02-24 02:37:41 +00:00
# Let's set the configuration directory to /tmp
2013-08-22 20:50:48 +01:00
_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
2014-06-21 18:58:16 +01:00
if [ ! -f " $_SALT_ETC_DIR /minion " ] && [ ! -f " $_TEMP_CONFIG_DIR /minion " ] ; then
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 18:58:16 +01:00
curl $_CURL_ARGS -s -o " $_TEMP_CONFIG_DIR /minion " -L \
2014-06-20 01:38:29 +01:00
https://raw.githubusercontent.com/saltstack/salt/develop/conf/minion || return 1
2013-02-24 02:37:41 +00:00
fi
2014-06-21 19:19:54 +01:00
if [ ! -f " $_SALT_ETC_DIR /master " ] && [ ! -f $_TEMP_CONFIG_DIR /master ] ; then
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 18:58:16 +01:00
curl $_CURL_ARGS -s -o " $_TEMP_CONFIG_DIR /master " -L \
2014-06-20 01:38:29 +01:00
https://raw.githubusercontent.com/saltstack/salt/develop/conf/master || return 1
2013-02-24 02:37:41 +00:00
fi
2013-01-27 23:12:58 +00:00
fi
2015-06-23 18:59:35 -04:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
pkgin -y install py27-apache-libcloud || return 1
fi
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
pkgin -y install ${ _EXTRA_PACKAGES } || return 1
fi
2013-03-23 11:55:45 +00:00
return 0
2013-01-27 23:12:58 +00:00
}
2013-01-27 23:31:26 +00:00
install_smartos_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_smartos_deps || return 1
2015-04-30 12:12:22 +01:00
2015-07-17 11:32:03 +01:00
which git > /dev/null 2>& 1
if [ $? -eq 1 ] ; then
2015-06-23 18:31:08 -04:00
pkgin -y install git || return 1
2015-04-30 12:12:22 +01:00
fi
2013-01-27 23:31:26 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
check_pip_allowed " You need to allow pip based installations (-P) in order to install the python package ' ${ __REQUIRED_TORNADO } ' "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
if [ " $( which pip) " = "" ] ; then
pkgin -y install py27-pip
fi
2015-07-19 19:49:57 +01:00
pip install -U " ${ __REQUIRED_TORNADO } "
2015-05-01 14:30:55 +01:00
fi
fi
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-27 23:31:26 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_TEMP_CONFIG_DIR = " ${ __SALT_GIT_CHECKOUT_DIR } /conf/ "
2013-01-27 23:31:26 +00:00
CONFIG_SALT_FUNC = "config_salt"
fi
2013-03-06 22:05:31 +00:00
return 0
2013-01-27 23:31:26 +00:00
}
2013-01-27 23:12:58 +00:00
install_smartos_stable( ) {
2014-02-16 21:38:15 +00:00
pkgin -y install salt || return 1
2013-03-23 11:55:45 +00:00
return 0
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
2015-07-15 22:09:06 -04:00
# lets force our config path on the setup for now, since salt/syspaths.py only got fixed in 2015.5.0
2015-07-16 21:13:20 +01:00
USE_SETUPTOOLS = 1 /opt/local/bin/python setup.py install --salt-config-dir= " $_SALT_ETC_DIR " || \
USE_SETUPTOOLS = 1 /opt/local/bin/python setup.py --salt-config-dir= " $_SALT_ETC_DIR " install || return 1
2013-03-23 11:55:45 +00:00
return 0
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-05-14 23:42:39 +02:00
smf_dir = "/opt/custom/smf"
2013-02-24 02:02:17 +00:00
# Install manifest files if needed.
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-05-14 23:42:39 +02:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-05-14 23:42:39 +02:00
2013-02-24 02:02:17 +00:00
svcs network/salt-$fname > /dev/null 2>& 1
if [ $? -eq 1 ] ; then
2014-06-21 18:58:16 +01:00
if [ ! -f " $_TEMP_CONFIG_DIR /salt- $fname .xml " ] ; then
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 18:58:16 +01:00
curl $_CURL_ARGS -s -o " $_TEMP_CONFIG_DIR /salt- $fname .xml " -L \
" https://raw.githubusercontent.com/saltstack/salt/develop/pkg/smartos/salt- $fname .xml "
2013-02-24 02:02:17 +00:00
fi
2014-06-21 19:19:54 +01:00
svccfg import " $_TEMP_CONFIG_DIR /salt- $fname .xml "
2013-05-14 23:42:39 +02:00
if [ " ${ VIRTUAL_TYPE } " = "global" ] ; then
2013-07-18 16:34:24 +01:00
if [ ! -d " $smf_dir " ] ; then
mkdir -p " $smf_dir " || return 1
2013-05-14 23:42:39 +02:00
fi
2013-07-18 16:34:24 +01:00
if [ ! -f " $smf_dir /salt- $fname .xml " ] ; then
2013-08-22 20:50:48 +01:00
copyfile " $_TEMP_CONFIG_DIR /salt- $fname .xml " " $smf_dir / " || return 1
2013-05-14 23:42:39 +02:00
fi
fi
2013-02-24 02:02:17 +00:00
fi
done
}
install_smartos_git_post( ) {
2013-05-14 23:42:39 +02:00
smf_dir = "/opt/custom/smf"
2013-01-29 13:17:11 +00:00
# Install manifest files if needed.
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-05-14 23:42:39 +02:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-05-14 23:42:39 +02:00
2014-06-21 18:58:16 +01:00
svcs " network/salt- $fname " > /dev/null 2>& 1
2013-01-29 13:17:11 +00:00
if [ $? -eq 1 ] ; then
2014-08-17 00:58:55 +01:00
svccfg import " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/smartos/salt- $fname .xml "
2013-05-14 23:42:39 +02:00
if [ " ${ VIRTUAL_TYPE } " = "global" ] ; then
if [ ! -d $smf_dir ] ; then
2013-07-18 16:34:24 +01:00
mkdir -p " $smf_dir "
2013-05-14 23:42:39 +02:00
fi
2013-07-18 16:34:24 +01:00
if [ ! -f " $smf_dir /salt- $fname .xml " ] ; then
2014-08-17 00:58:55 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/smartos/salt- $fname .xml " " $smf_dir / "
2013-05-14 23:42:39 +02:00
fi
fi
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-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-01-28 13:16:28 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $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
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-10-23 08:09:12 +01:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-02-25 17:03:46 +00:00
#
# openSUSE Install Functions.
#
2014-11-23 00:59:52 +03:00
2015-04-30 13:06:02 +01:00
__ZYPPER_REQUIRES_REPLACE_FILES = -1
2014-11-23 00:59:52 +03:00
__version_lte( ) {
2015-04-30 13:06:02 +01:00
if [ " $( which python) " = "" ] ; then
zypper zypper --non-interactive install --replacefiles --auto-agree-with-licenses python || \
zypper zypper --non-interactive install --auto-agree-with-licenses python || return 1
fi
2015-05-01 19:12:58 +01:00
if [ " $( python -c 'import sys; V1=tuple([int(i) for i in sys.argv[1].split(".")]); V2=tuple([int(i) for i in sys.argv[2].split(".")]); print V1<=V2' " $1 " " $2 " ) " = "True" ] ; then
2015-04-30 13:06:02 +01:00
__ZYPPER_REQUIRES_REPLACE_FILES = ${ BS_TRUE }
else
__ZYPPER_REQUIRES_REPLACE_FILES = ${ BS_FALSE }
fi
2014-11-23 00:59:52 +03:00
}
2015-04-30 13:06:02 +01:00
__zypper( ) {
zypper --non-interactive " ${ @ } " ; return $?
}
__zypper_install( ) {
if [ " ${ __ZYPPER_REQUIRES_REPLACE_FILES } " = "-1" ] ; then
__version_lte "1.10.4" " $( zypper --version | awk '{ print $2 }' ) "
fi
if [ " ${ __ZYPPER_REQUIRES_REPLACE_FILES } " = " ${ BS_TRUE } " ] ; then
# In case of file conflicts replace old files.
# Option present in zypper 1.10.4 and newer:
# https://github.com/openSUSE/zypper/blob/95655728d26d6d5aef7796b675f4cc69bc0c05c0/package/zypper.changes#L253
__zypper install --auto-agree-with-licenses --replacefiles " ${ @ } " ; return $?
else
__zypper install --auto-agree-with-licenses " ${ @ } " ; return $?
fi
2014-11-23 00:59:52 +03:00
}
2013-02-25 17:03:46 +00:00
install_opensuse_stable_deps( ) {
DISTRO_REPO = " openSUSE_ ${ DISTRO_MAJOR_VERSION } . ${ DISTRO_MINOR_VERSION } "
2013-04-10 17:25:09 +01:00
# Is the repository already known
2015-04-30 13:06:02 +01:00
__zypper repos | grep devel_languages_python >/dev/null 2>& 1
2013-04-10 17:25:09 +01:00
if [ $? -eq 1 ] ; then
# zypper does not yet know nothing about devel_languages_python
2015-04-30 13:06:02 +01:00
__zypper addrepo --refresh \
2014-06-21 18:58:16 +01:00
" http://download.opensuse.org/repositories/devel:/languages:/python/ ${ DISTRO_REPO } /devel:languages:python.repo " || return 1
2013-04-10 17:25:09 +01:00
fi
2015-04-30 13:06:02 +01:00
__zypper --gpg-auto-import-keys refresh
2013-05-21 01:58:52 +01:00
if [ $? -ne 0 ] && [ $? -ne 4 ] ; then
2014-08-29 14:38:39 -04:00
# If the exit code is not 0, and it's not 4 (failed to update a
2013-05-21 01:58:52 +01:00
# repository) return a failure. Otherwise continue.
return 1
fi
2013-08-22 19:44:47 +01:00
2014-06-21 18:58:16 +01:00
if [ " $DISTRO_MAJOR_VERSION " -eq 12 ] && [ " $DISTRO_MINOR_VERSION " -eq 3 ] ; then
2013-08-22 19:44:47 +01:00
# Because patterns-openSUSE-minimal_base-conflicts conflicts with python, lets remove the first one
2015-04-30 13:06:02 +01:00
__zypper remove patterns-openSUSE-minimal_base-conflicts
2013-08-22 19:44:47 +01:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2015-04-30 13:06:02 +01:00
__zypper --gpg-auto-import-keys update || return 1
2014-02-16 17:42:07 +00:00
fi
2014-07-19 18:02:42 +01:00
# Salt needs python-zypp installed in order to use the zypper module
__PACKAGES = "python-zypp"
__PACKAGES = " ${ __PACKAGES } libzmq3 python python-Jinja2 python-M2Crypto python-PyYAML python-requests "
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-msgpack-python python-pycrypto python-pyzmq python-xml "
2014-02-16 17:48:21 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-apache-libcloud "
2014-02-16 17:48:21 +00:00
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2015-04-30 13:06:02 +01:00
__zypper_install ${ __PACKAGES } || return 1
2014-02-16 17:48:21 +00:00
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2015-04-30 13:06:02 +01:00
__zypper_install ${ _EXTRA_PACKAGES } || return 1
2014-02-16 21:38:15 +00:00
fi
2013-03-23 11:55:45 +00:00
return 0
2013-02-25 17:03:46 +00:00
}
install_opensuse_git_deps( ) {
2013-03-23 11:55:45 +00:00
install_opensuse_stable_deps || return 1
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
2015-04-30 13:06:02 +01:00
__zypper_install git || return 1
2015-04-30 12:12:22 +01:00
fi
2015-04-30 13:06:02 +01:00
__zypper_install patch || return 1
2013-02-25 17:03:46 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-02-25 17:03:46 +00:00
2014-10-30 01:16:07 +00:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/suse/use-forking-daemon.patch " ] ; then
cd " ${ __SALT_GIT_CHECKOUT_DIR } "
echowarn "Applying patch to systemd service unit file"
patch -p1 < pkg/suse/use-forking-daemon.patch || return 1
fi
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
__zypper_install python-tornado
fi
fi
2013-02-25 17:03:46 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_TEMP_CONFIG_DIR = " ${ __SALT_GIT_CHECKOUT_DIR } /conf/ "
2013-02-25 17:03:46 +00:00
CONFIG_SALT_FUNC = "config_salt"
fi
2013-03-06 22:05:31 +00:00
return 0
2013-02-25 17:03:46 +00:00
}
install_opensuse_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
2013-02-25 17:03:46 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-master "
2013-02-25 17:03:46 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
2013-02-25 17:52:39 +00:00
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2015-04-30 13:06:02 +01:00
__zypper_install $__PACKAGES || return 1
2013-03-23 11:55:45 +00:00
return 0
2013-02-25 17:03:46 +00:00
}
install_opensuse_git( ) {
2013-03-23 11:55:45 +00:00
python setup.py install --prefix= /usr || return 1
return 0
2013-02-25 17:03:46 +00:00
}
install_opensuse_stable_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-25 17:03:46 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-25 17:03:46 +00:00
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( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-02-25 17:03:46 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-25 17:03:46 +00:00
2013-02-26 18:16:26 +00:00
if [ -f /bin/systemctl ] ; then
2015-05-01 19:15:00 +01:00
if [ " ${ DISTRO_MAJOR_VERSION } " -gt 13 ] || ( [ " ${ DISTRO_MAJOR_VERSION } " -eq 13 ] && [ " ${ DISTRO_MINOR_VERSION } " -ge 2 ] ) ; then
2015-05-01 19:12:31 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/salt- ${ fname } .service " " /usr/lib/systemd/system/salt- ${ fname } .service "
else
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
fi
2013-02-26 18:16:26 +00:00
continue
fi
2014-08-17 00:58:55 +01:00
copyfile " ${ __SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- $fname " " /etc/init.d/salt- $fname "
2013-02-26 18:16:26 +00:00
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( ) {
2013-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-02-25 17:03:46 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-25 17:03:46 +00:00
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
2013-03-06 20:15:36 +00:00
service salt-$fname start
2013-02-26 18:16:26 +00:00
2013-02-25 17:03:46 +00:00
done
}
2014-02-20 12:04:42 +00:00
install_opensuse_check_services( ) {
if [ ! -f /bin/systemctl ] ; then
# Not running systemd!? Don't check!
return 0
fi
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-20 12:04:42 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2014-07-21 16:34:06 +01:00
__check_services_systemd salt-$fname > /dev/null 2>& 1 || __check_services_systemd salt-$fname .service > /dev/null 2>& 1 || return 1
2014-02-20 12:04:42 +00:00
done
return 0
}
2013-02-25 17:03:46 +00:00
#
# End of openSUSE Install Functions.
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-02-25 17:03:46 +00:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
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-03-21 03:02:51 -07:00
SUSE_PATCHLEVEL = $( awk '/PATCHLEVEL/ {print $3}' /etc/SuSE-release )
2014-06-22 10:52:10 +01:00
if [ " ${ SUSE_PATCHLEVEL } " != "" ] ; then
2013-02-26 20:16:56 +00:00
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 } "
2013-04-10 17:25:09 +01:00
# Is the repository already known
2015-04-30 13:06:02 +01:00
__zypper repos | grep devel_languages_python >/dev/null 2>& 1
2013-04-10 17:25:09 +01:00
if [ $? -eq 1 ] ; then
# zypper does not yet know nothing about devel_languages_python
2015-04-30 13:06:02 +01:00
__zypper addrepo --refresh \
2014-06-21 18:58:16 +01:00
" http://download.opensuse.org/repositories/devel:/languages:/python/ ${ DISTRO_REPO } /devel:languages:python.repo " || return 1
2013-04-10 17:25:09 +01:00
fi
2015-04-30 13:06:02 +01:00
__zypper --gpg-auto-import-keys refresh || return 1
2014-02-16 17:49:37 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2015-04-30 13:06:02 +01:00
__zypper --gpg-auto-import-keys update || return 1
2014-02-16 17:49:37 +00:00
fi
2014-07-19 18:02:42 +01:00
# Salt needs python-zypp installed in order to use the zypper module
__PACKAGES = "python-zypp"
2014-06-22 11:29:16 +01:00
# shellcheck disable=SC2089
2014-07-24 15:06:28 +01:00
__PACKAGES = " ${ __PACKAGES } libzmq3 python python-Jinja2 python-msgpack-python "
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-pycrypto python-pyzmq python-pip python-xml python-requests "
2014-02-16 17:57:49 +00:00
2014-06-21 18:58:16 +01:00
if [ " $SUSE_PATCHLEVEL " -eq 1 ] ; then
2013-04-23 10:38:42 +01:00
check_pip_allowed
2013-02-27 17:16:28 +00:00
echowarn "PyYaml will be installed using pip"
2014-02-16 17:57:49 +00:00
else
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-PyYAML "
2014-02-16 17:57:49 +00:00
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-07-06 00:38:13 +01:00
__PACKAGES = " ${ __PACKAGES } python-apache-libcloud "
2014-02-16 17:57:49 +00:00
fi
2014-07-24 15:06:28 +01:00
# SLES 11 SP3 ships with both python-M2Crypto-0.22.* and python-m2crypto-0.21 and we will be asked which
# we want to install, even with --non-interactive.
# Let's try to install the higher version first and then the lower one in case of failure
2015-04-30 13:06:02 +01:00
__zypper_install 'python-M2Crypto>=0.22' || __zypper_install 'python-M2Crypto>=0.21' || return 1
2014-06-22 11:30:43 +01:00
# shellcheck disable=SC2086,SC2090
2015-04-30 13:06:02 +01:00
__zypper_install ${ __PACKAGES } || return 1
2014-02-16 17:57:49 +00:00
2014-06-21 18:58:16 +01:00
if [ " $SUSE_PATCHLEVEL " -eq 1 ] ; then
2013-02-26 19:12:13 +00:00
# There's no python-PyYaml in SP1, let's install it using pip
2013-03-23 11:55:45 +00:00
pip install PyYaml || return 1
2013-02-26 19:12:13 +00:00
fi
2013-02-26 20:51:17 +00:00
2013-04-10 18:00:13 +01:00
# PIP based installs need to copy configuration files "by hand".
2014-06-21 18:58:16 +01:00
if [ " $SUSE_PATCHLEVEL " -eq 1 ] ; then
2013-04-10 17:50:31 +01:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2013-04-10 17:50:31 +01:00
# Let's set the configuration directory to /tmp
2013-08-22 20:50:48 +01:00
_TEMP_CONFIG_DIR = "/tmp"
2013-04-10 17:50:31 +01:00
CONFIG_SALT_FUNC = "config_salt"
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-04-10 17:50:31 +01:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-04-10 17:50:31 +01:00
# Syndic uses the same configuration file as the master
[ $fname = "syndic" ] && fname = master
# Let's download, since they were not provided, the default configuration files
2014-06-21 18:58:16 +01:00
if [ ! -f " $_SALT_ETC_DIR / $fname " ] && [ ! -f " $_TEMP_CONFIG_DIR / $fname " ] ; then
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 18:58:16 +01:00
curl $_CURL_ARGS -s -o " $_TEMP_CONFIG_DIR / $fname " -L \
" https://raw.githubusercontent.com/saltstack/salt/develop/conf/ $fname " || return 1
2013-04-10 17:50:31 +01:00
fi
done
fi
2013-04-10 18:00:13 +01:00
fi
2014-02-16 21:38:15 +00:00
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2015-04-30 13:06:02 +01:00
__zypper_install ${ _EXTRA_PACKAGES } || return 1
2014-02-16 21:38:15 +00:00
fi
2013-04-10 18:00:13 +01:00
return 0
2013-02-19 21:30:51 +00:00
}
2013-02-26 14:01:02 +00:00
install_suse_11_git_deps( ) {
2013-04-10 18:00:13 +01:00
install_suse_11_stable_deps || return 1
2015-04-30 12:12:22 +01:00
if [ " $( which git) " = "" ] ; then
2015-04-30 13:06:02 +01:00
__zypper_install git || return 1
2015-04-30 12:12:22 +01:00
fi
2013-02-26 20:51:17 +00:00
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-02-26 20:51:17 +00:00
2015-05-01 14:30:55 +01:00
if [ -f " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ] ; then
# We're on the develop branch, install whichever tornado is on the requirements file
__REQUIRED_TORNADO = " $( grep tornado " ${ __SALT_GIT_CHECKOUT_DIR } /requirements/base.txt " ) "
if [ " ${ __REQUIRED_TORNADO } " != "" ] ; then
__zypper_install python-tornado
fi
fi
2013-02-26 20:51:17 +00:00
# Let's trigger config_salt()
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
2014-08-17 00:58:55 +01:00
_TEMP_CONFIG_DIR = " ${ __SALT_GIT_CHECKOUT_DIR } /conf/ "
2013-02-26 20:51:17 +00:00
CONFIG_SALT_FUNC = "config_salt"
fi
2013-03-06 22:05:31 +00:00
return 0
2013-02-19 21:30:51 +00:00
}
2013-02-26 14:01:02 +00:00
install_suse_11_stable( ) {
2014-06-21 18:58:16 +01:00
if [ " $SUSE_PATCHLEVEL " -gt 1 ] ; then
2013-04-10 18:00:13 +01:00
install_opensuse_stable || return 1
2013-02-26 20:16:56 +00:00
else
2013-02-26 20:42:08 +00:00
# USE_SETUPTOOLS=1 To work around
# error: option --single-version-externally-managed not recognized
2013-03-23 11:55:45 +00:00
USE_SETUPTOOLS = 1 pip install salt || return 1
2013-02-26 20:16:56 +00:00
fi
2013-03-23 11:55:45 +00:00
return 0
2013-02-19 21:30:51 +00:00
}
2013-02-26 14:01:02 +00:00
install_suse_11_git( ) {
2013-03-23 11:55:45 +00:00
install_opensuse_git || return 1
return 0
2013-02-26 14:01:02 +00:00
}
2013-02-19 21:30:51 +00:00
2013-02-26 14:01:02 +00:00
install_suse_11_stable_post( ) {
2014-06-21 18:58:16 +01:00
if [ " $SUSE_PATCHLEVEL " -gt 1 ] ; then
2013-03-23 11:55:45 +00:00
install_opensuse_stable_post || return 1
2013-02-26 20:16:56 +00:00
else
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2013-02-26 20:16:56 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-07-29 12:13:52 +01:00
[ $fname = "api" ] && ( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || [ " $( which salt-${ fname } 2>/dev/null) " = "" ] ) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-26 20:16:56 +00:00
if [ -f /bin/systemctl ] ; then
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 18:58:16 +01:00
curl $_CURL_ARGS -L " https://github.com/saltstack/salt/raw/develop/pkg/salt- $fname .service " \
-o " /lib/systemd/system/salt- $fname .service " || return 1
2013-02-26 20:16:56 +00:00
continue
fi
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-06-21 18:58:16 +01:00
curl $_CURL_ARGS -L " https://github.com/saltstack/salt/raw/develop/pkg/rpm/salt- $fname " \
-o " /etc/init.d/salt- $fname " || return 1
chmod +x " /etc/init.d/salt- $fname "
2013-02-26 20:16:56 +00:00
done
fi
2013-03-23 11:55:45 +00:00
return 0
2013-02-19 21:30:51 +00:00
}
2013-02-26 14:01:02 +00:00
install_suse_11_git_post( ) {
2013-03-23 11:55:45 +00:00
install_opensuse_git_post || return 1
return 0
2013-02-19 21:30:51 +00:00
}
2013-02-26 14:01:02 +00:00
install_suse_11_restart_daemons( ) {
2013-03-23 11:55:45 +00:00
install_opensuse_restart_daemons || return 1
return 0
2013-02-19 21:30:51 +00:00
}
2014-02-20 12:05:43 +00:00
install_suse_check_services( ) {
if [ ! -f /bin/systemctl ] ; then
# Not running systemd!? Don't check!
return 0
fi
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-20 12:05:43 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2014-02-20 12:05:43 +00:00
__check_services_systemd salt-$fname || return 1
done
return 0
}
2013-02-19 21:30:51 +00:00
#
# End of SuSE Install Functions.
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-02-19 21:30:51 +00:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-05-29 19:27:02 +01:00
#
# Gentoo Install Functions.
#
2013-08-09 00:04:06 +01:00
__emerge( ) {
2014-06-21 18:58:16 +01:00
if [ " $_GENTOO_USE_BINHOST " -eq $BS_TRUE ] ; then
2014-04-04 13:28:27 +01:00
emerge --autounmask-write --getbinpkg " ${ @ } " ; return $?
2013-06-21 15:41:19 +01:00
fi
2014-04-04 13:28:27 +01:00
emerge --autounmask-write " ${ @ } " ; return $?
2013-06-21 15:41:19 +01:00
}
2013-05-29 19:27:02 +01:00
2013-09-24 01:23:23 +02:00
__gentoo_config_protection( ) {
2013-09-24 01:46:25 +02:00
# usually it's a good thing to have config files protected by portage, but
# in this case this would require to interrupt the bootstrapping script at
# this point, manually merge the changes using etc-update/dispatch-conf/
# cfg-update and then restart the bootstrapping script, so instead we allow
# at this point to modify certain config files directly
2015-07-17 11:21:46 +01:00
export CONFIG_PROTECT_MASK = " ${ CONFIG_PROTECT_MASK :- } /etc/portage/package.keywords /etc/portage/package.unmask /etc/portage/package.use /etc/portage/package.license "
2013-06-21 15:41:19 +01:00
}
2013-05-29 19:27:02 +01:00
__gentoo_pre_dep( ) {
2014-06-21 18:58:16 +01:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
2014-06-22 10:52:10 +01:00
if [ " $( which eix) " != "" ] ; then
2013-09-20 01:41:31 +02:00
eix-sync
else
emerge --sync
fi
2013-05-29 19:27:02 +01:00
else
2014-06-22 10:52:10 +01:00
if [ " $( which eix) " != "" ] ; then
2013-09-20 01:41:31 +02:00
eix-sync -q
2013-05-29 19:27:02 +01:00
else
2013-09-20 01:41:31 +02:00
emerge --sync --quiet
2013-05-29 19:27:02 +01:00
fi
fi
if [ ! -d /etc/portage ] ; then
mkdir /etc/portage
fi
}
__gentoo_post_dep( ) {
2013-08-15 09:37:33 -05:00
# ensures dev-lib/crypto++ compiles happily
2013-09-20 01:35:14 +02:00
__emerge --oneshot 'sys-devel/libtool'
2013-05-29 19:27:02 +01:00
# the -o option asks it to emerge the deps but not the package.
2013-09-24 01:23:23 +02:00
__gentoo_config_protection
2014-02-16 18:09:20 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2014-04-09 13:10:08 +01:00
check_pip_allowed "You need to allow pip based installations (-P) in order to install apache-libcloud"
2014-02-16 18:09:20 +00:00
__emerge -v 'dev-python/pip'
2014-04-04 12:57:08 +01:00
pip install -U " apache-libcloud>= $_LIBCLOUD_MIN_VERSION "
2014-02-16 18:09:20 +00:00
fi
2014-04-07 19:52:53 +01:00
__emerge -vo 'dev-python/requests'
2013-09-20 01:27:55 +02:00
__emerge -vo 'app-admin/salt'
2014-02-16 21:38:15 +00:00
2014-06-22 10:52:10 +01:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
2014-02-16 21:38:15 +00:00
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2014-02-16 21:38:15 +00:00
__emerge -v ${ _EXTRA_PACKAGES } || return 1
fi
2013-05-29 19:27:02 +01:00
}
install_gentoo_deps( ) {
__gentoo_pre_dep || return 1
2015-05-01 14:30:55 +01:00
__gentoo_post_dep || return 1
2013-05-29 19:27:02 +01:00
}
install_gentoo_git_deps( ) {
__gentoo_pre_dep || return 1
2015-05-01 14:30:55 +01:00
__gentoo_post_dep || return 1
2013-05-29 19:27:02 +01:00
}
install_gentoo_stable( ) {
2013-09-24 02:17:10 +02:00
__gentoo_config_protection
2013-09-20 01:27:55 +02:00
__emerge -v 'app-admin/salt' || return 1
2013-05-29 19:27:02 +01:00
}
install_gentoo_git( ) {
2013-09-24 02:17:10 +02:00
__gentoo_config_protection
2013-09-20 01:25:44 +02:00
__emerge -v '=app-admin/salt-9999' || return 1
2013-05-29 19:27:02 +01:00
}
install_gentoo_post( ) {
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-05-29 19:27:02 +01:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-05-29 19:27:02 +01:00
2013-09-24 02:17:10 +02:00
if [ -d "/run/systemd/system" ] ; then
systemctl enable salt-$fname .service
systemctl start salt-$fname .service
else
rc-update add salt-$fname default
/etc/init.d/salt-$fname start
fi
2013-05-29 19:27:02 +01:00
done
}
install_gentoo_restart_daemons( ) {
2013-10-24 16:49:04 +02:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-05-29 19:27:02 +01:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-05-29 19:27:02 +01:00
2013-09-24 02:01:48 +02:00
if [ -d "/run/systemd/system" ] ; then
systemctl stop salt-$fname > /dev/null 2>& 1
systemctl start salt-$fname .service
else
/etc/init.d/salt-$fname stop > /dev/null 2>& 1
/etc/init.d/salt-$fname start
fi
2013-05-29 19:27:02 +01:00
done
}
2014-02-20 12:07:05 +00:00
install_gentoo_check_services( ) {
if [ ! -d "/run/systemd/system" ] ; then
# Not running systemd!? Don't check!
return 0
fi
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-08-23 23:28:09 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2014-02-20 12:07:05 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-08-23 23:28:09 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2014-02-20 12:07:05 +00:00
__check_services_systemd salt-$fname || return 1
done
return 0
}
2013-05-29 19:27:02 +01:00
#
# End of Gentoo Install Functions.
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-05-29 19:27:02 +01:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
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
2013-08-22 20:50:48 +01: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
# Let's create the necessary directories
2014-06-21 18:58:16 +01:00
[ -d " $_SALT_ETC_DIR " ] || mkdir " $_SALT_ETC_DIR " || return 1
2014-06-21 19:10:17 +01:00
[ -d " $_PKI_DIR " ] || ( mkdir -p " $_PKI_DIR " && chmod 700 " $_PKI_DIR " ) || return 1
2012-11-28 04:29:33 +00:00
2013-07-02 16:33:30 +01:00
# Copy the grains file if found
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /grains " ] ; then
echodebug " Moving provided grains file from $_TEMP_CONFIG_DIR /grains to $_SALT_ETC_DIR /grains "
movefile " $_TEMP_CONFIG_DIR /grains " " $_SALT_ETC_DIR /grains " || return 1
2013-07-02 16:33:30 +01:00
CONFIGURED_ANYTHING = $BS_TRUE
fi
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2013-01-25 02:01:00 +00:00
# Create the PKI directory
2014-06-21 19:10:17 +01:00
[ -d " $_PKI_DIR /minion " ] || ( mkdir -p " $_PKI_DIR /minion " && chmod 700 " $_PKI_DIR /minion " ) || return 1
2012-11-28 04:29:33 +00:00
2013-01-25 02:01:00 +00:00
# Copy the minions configuration if found
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /minion " ] ; then
2014-06-21 18:58:16 +01:00
movefile " $_TEMP_CONFIG_DIR /minion " " $_SALT_ETC_DIR " || return 1
2013-03-24 08:19:28 +00:00
CONFIGURED_ANYTHING = $BS_TRUE
fi
2013-01-07 19:20:10 -08:00
2013-01-25 02:01:00 +00:00
# Copy the minion's keys if found
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /minion.pem " ] ; then
2014-06-21 18:58:16 +01:00
movefile " $_TEMP_CONFIG_DIR /minion.pem " " $_PKI_DIR /minion/ " || return 1
chmod 400 " $_PKI_DIR /minion/minion.pem " || return 1
2013-02-11 21:58:59 +00:00
CONFIGURED_ANYTHING = $BS_TRUE
2013-01-25 02:01:00 +00:00
fi
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /minion.pub " ] ; then
2014-06-21 18:58:16 +01:00
movefile " $_TEMP_CONFIG_DIR /minion.pub " " $_PKI_DIR /minion/ " || return 1
chmod 664 " $_PKI_DIR /minion/minion.pub " || return 1
2013-02-11 21:58:59 +00:00
CONFIGURED_ANYTHING = $BS_TRUE
2013-01-25 02:01:00 +00:00
fi
2015-03-10 22:28:20 -04:00
# For multi-master-pki, copy the master_sign public key if found
if [ -f " $_TEMP_CONFIG_DIR /master_sign.pub " ] ; then
movefile " $_TEMP_CONFIG_DIR /master_sign.pub " " $_PKI_DIR /minion/ " || return 1
chmod 664 " $_PKI_DIR /minion/master_sign.pub " || return 1
CONFIGURED_ANYTHING = $BS_TRUE
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
2014-06-21 18:58:16 +01: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
2014-06-21 18:58:16 +01:00
[ -d " $_PKI_DIR /master " ] || ( mkdir -p " $_PKI_DIR /master " && chmod 700 " $_PKI_DIR /master " ) || return 1
2013-01-25 02:01:00 +00:00
# Copy the masters configuration if found
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /master " ] ; then
2014-06-21 18:58:16 +01:00
movefile " $_TEMP_CONFIG_DIR /master " " $_SALT_ETC_DIR " || return 1
2013-03-24 08:19:28 +00:00
CONFIGURED_ANYTHING = $BS_TRUE
fi
2013-01-25 02:01:00 +00:00
# Copy the master's keys if found
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /master.pem " ] ; then
2014-06-21 18:58:16 +01:00
movefile " $_TEMP_CONFIG_DIR /master.pem " " $_PKI_DIR /master/ " || return 1
chmod 400 " $_PKI_DIR /master/master.pem " || return 1
2013-02-11 21:58:59 +00:00
CONFIGURED_ANYTHING = $BS_TRUE
2013-01-25 02:01:00 +00:00
fi
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /master.pub " ] ; then
2014-06-21 18:58:16 +01:00
movefile " $_TEMP_CONFIG_DIR /master.pub " " $_PKI_DIR /master/ " || return 1
chmod 664 " $_PKI_DIR /master/master.pub " || return 1
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
2014-06-21 18:58:16 +01:00
if [ " $_CONFIG_ONLY " -eq $BS_TRUE ] && [ $CONFIGURED_ANYTHING -eq $BS_FALSE ] ; then
2013-03-06 23:10:51 +00:00
echowarn "No configuration or keys were copied over. No configuration was done!"
exit 0
2013-02-11 21:58:59 +00:00
fi
2013-03-23 11:55:45 +00:00
return 0
2012-11-28 04:29:33 +00:00
}
#
# Ended Default Configuration function
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2012-11-28 04:29:33 +00:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-04-23 11:15:54 +01:00
#
# Default salt master minion keys pre-seed function. Matches ANY distribution
# as long as the -k option is passed.
#
preseed_master( ) {
# Create the PKI directory
2013-05-01 23:49:07 +01:00
2014-06-22 11:06:31 +01:00
if [ " $( find " $_TEMP_KEYS_DIR " -maxdepth 1 -type f | wc -l) " -lt 1 ] ; then
2013-05-01 23:49:07 +01:00
echoerror "No minion keys were uploaded. Unable to pre-seed master"
return 1
fi
2013-08-22 20:50:48 +01:00
SEED_DEST = " $_PKI_DIR /master/minions "
2014-06-21 19:10:17 +01:00
[ -d " $SEED_DEST " ] || ( mkdir -p " $SEED_DEST " && chmod 700 " $SEED_DEST " ) || return 1
2013-04-23 11:15:54 +01:00
2014-04-03 05:40:01 +01:00
for keyfile in $_TEMP_KEYS_DIR /*; do
2014-04-21 00:09:09 +10:00
keyfile = $( basename " ${ keyfile } " )
2013-08-22 20:50:48 +01:00
src_keyfile = " ${ _TEMP_KEYS_DIR } / ${ keyfile } "
2013-05-01 23:49:07 +01:00
dst_keyfile = " ${ SEED_DEST } / ${ keyfile } "
2013-04-23 11:15:54 +01:00
# If it's not a file, skip to the next
2014-06-21 18:58:16 +01:00
[ ! -f " $src_keyfile " ] && continue
2013-04-23 11:15:54 +01:00
movefile " $src_keyfile " " $dst_keyfile " || return 1
2014-06-21 18:58:16 +01:00
chmod 664 " $dst_keyfile " || return 1
2013-04-23 11:15:54 +01:00
done
return 0
}
#
# Ended Default Salt Master Pre-Seed minion keys function
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-04-23 11:15:54 +01:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-03-06 21:15:14 +00:00
#
# This function checks if all of the installed daemons are running or not.
#
daemons_running( ) {
2014-06-21 19:19:54 +01:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2013-03-06 21:15:14 +00:00
FAILED_DAEMONS = 0
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-03-06 21:15:14 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-08 16:30:13 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-03-06 21:15:14 +00:00
2014-05-09 19:24:00 +01:00
# shellcheck disable=SC2009
2013-05-15 06:27:02 +02:00
if [ " ${ DISTRO_NAME } " = "SmartOS" ] ; then
2013-05-15 06:39:08 +02:00
if [ " $( svcs -Ho STA salt-$fname ) " != "ON" ] ; then
2013-05-15 00:03:31 +02:00
echoerror " salt- $fname was not found running "
2014-04-03 05:27:51 +01:00
FAILED_DAEMONS = $(( FAILED_DAEMONS + 1 ))
2013-05-15 00:03:31 +02:00
fi
2014-06-22 10:52:10 +01:00
elif [ " $( ps wwwaux | grep -v grep | grep salt-$fname ) " = "" ] ; then
2013-03-06 21:15:14 +00:00
echoerror " salt- $fname was not found running "
2014-04-03 05:27:51 +01:00
FAILED_DAEMONS = $(( FAILED_DAEMONS + 1 ))
2013-03-06 21:15:14 +00:00
fi
done
return $FAILED_DAEMONS
}
#
# Ended daemons running check function
#
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-03-06 21:15:14 +00:00
2014-02-17 15:21:29 +00:00
#======================================================================================================================
2012-10-18 22:18:07 +01:00
# LET'S PROCEED WITH OUR INSTALLATION
2014-02-17 15:21:29 +00:00
#======================================================================================================================
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"
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $DEP_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
DEPS_INSTALL_FUNC = " $FUNC_NAME "
2012-10-18 17:28:00 +01:00
break
fi
done
2013-06-27 12:18:25 +04:00
echodebug " DEPS_INSTALL_FUNC= ${ DEPS_INSTALL_FUNC } "
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"
2013-08-22 20:50:48 +01: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
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $CONFIG_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
CONFIG_SALT_FUNC = " $FUNC_NAME "
2012-11-28 04:29:33 +00:00
break
fi
done
fi
2013-06-27 12:18:25 +04:00
echodebug " CONFIG_SALT_FUNC= ${ CONFIG_SALT_FUNC } "
2012-11-28 04:29:33 +00:00
2013-04-23 11:15:54 +01:00
# Let's get the pre-seed master function
PRESEED_MASTER_FUNC = "null"
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_KEYS_DIR " != "null" ] ; then
2013-04-23 11:15:54 +01:00
PRESEED_FUNC_NAMES = " preseed_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } _ ${ ITYPE } _master "
PRESEED_FUNC_NAMES = " $PRESEED_FUNC_NAMES preseed_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } ${ PREFIXED_DISTRO_MINOR_VERSION } _ ${ ITYPE } _master "
PRESEED_FUNC_NAMES = " $PRESEED_FUNC_NAMES preseed_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } _master "
PRESEED_FUNC_NAMES = " $PRESEED_FUNC_NAMES preseed_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } ${ PREFIXED_DISTRO_MINOR_VERSION } _master "
PRESEED_FUNC_NAMES = " $PRESEED_FUNC_NAMES preseed_ ${ DISTRO_NAME_L } _ ${ ITYPE } _master "
PRESEED_FUNC_NAMES = " $PRESEED_FUNC_NAMES preseed_ ${ DISTRO_NAME_L } _master "
PRESEED_FUNC_NAMES = " $PRESEED_FUNC_NAMES preseed_master "
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $PRESEED_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
PRESEED_MASTER_FUNC = " $FUNC_NAME "
2013-04-23 11:15:54 +01:00
break
fi
done
fi
2013-06-27 12:18:25 +04:00
echodebug " PRESEED_MASTER_FUNC= ${ PRESEED_MASTER_FUNC } "
2013-04-23 11:15:54 +01:00
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"
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $INSTALL_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
INSTALL_FUNC = " $FUNC_NAME "
2013-01-18 02:42:49 +00:00
break
fi
done
2013-06-27 12:18:25 +04:00
echodebug " INSTALL_FUNC= ${ INSTALL_FUNC } "
2013-01-18 02:42:49 +00:00
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
POST_INSTALL_FUNC = "null"
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $POST_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
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-06-27 12:18:25 +04:00
echodebug " POST_INSTALL_FUNC= ${ POST_INSTALL_FUNC } "
2012-10-18 17:28:00 +01:00
2014-02-16 22:32:56 +00:00
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"
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $STARTDAEMONS_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
STARTDAEMONS_INSTALL_FUNC = " $FUNC_NAME "
2013-02-08 11:39:27 +00:00
break
fi
done
2013-06-27 12:18:25 +04:00
echodebug " STARTDAEMONS_INSTALL_FUNC= ${ STARTDAEMONS_INSTALL_FUNC } "
2013-02-08 11:39:27 +00:00
2014-02-16 22:32:56 +00:00
2013-03-06 21:15:14 +00:00
# Let's get the daemons running check function.
DAEMONS_RUNNING_FUNC = "null"
DAEMONS_RUNNING_FUNC_NAMES = " daemons_running_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } _ ${ ITYPE } "
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } ${ PREFIXED_DISTRO_MINOR_VERSION } _ ${ ITYPE } "
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } "
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } ${ PREFIXED_DISTRO_MINOR_VERSION } "
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running_ ${ DISTRO_NAME_L } _ ${ ITYPE } "
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running_ ${ DISTRO_NAME_L } "
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running "
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $DAEMONS_RUNNING_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
DAEMONS_RUNNING_FUNC = " $FUNC_NAME "
2013-03-06 21:15:14 +00:00
break
fi
done
2013-06-27 12:18:25 +04:00
echodebug " DAEMONS_RUNNING_FUNC= ${ DAEMONS_RUNNING_FUNC } "
2013-03-06 21:15:14 +00:00
2014-02-16 22:32:56 +00:00
# Let's get the check services function
2014-09-01 21:21:29 +10:00
if [ ${ _DISABLE_SALT_CHECKS } -eq $BS_FALSE ] ; then
CHECK_SERVICES_FUNC_NAMES = " install_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } _ ${ ITYPE } _check_services "
CHECK_SERVICES_FUNC_NAMES = " $CHECK_SERVICES_FUNC_NAMES install_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } ${ PREFIXED_DISTRO_MINOR_VERSION } _ ${ ITYPE } _check_services "
CHECK_SERVICES_FUNC_NAMES = " $CHECK_SERVICES_FUNC_NAMES install_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } _check_services "
CHECK_SERVICES_FUNC_NAMES = " $CHECK_SERVICES_FUNC_NAMES install_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } ${ PREFIXED_DISTRO_MINOR_VERSION } _check_services "
CHECK_SERVICES_FUNC_NAMES = " $CHECK_SERVICES_FUNC_NAMES install_ ${ DISTRO_NAME_L } _ ${ ITYPE } _check_services "
CHECK_SERVICES_FUNC_NAMES = " $CHECK_SERVICES_FUNC_NAMES install_ ${ DISTRO_NAME_L } _check_services "
else
CHECK_SERVICES_FUNC_NAMES = False
echowarn "DISABLE_SALT_CHECKS set, not setting \$CHECK_SERVICES_FUNC_NAMES"
fi
2014-02-16 22:32:56 +00:00
CHECK_SERVICES_FUNC = "null"
2014-06-22 10:40:05 +01:00
for FUNC_NAME in $( __strip_duplicates " $CHECK_SERVICES_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
CHECK_SERVICES_FUNC = " $FUNC_NAME "
2014-02-16 22:32:56 +00:00
break
fi
done
echodebug " CHECK_SERVICES_FUNC= ${ CHECK_SERVICES_FUNC } "
2013-03-06 21:15:14 +00:00
2014-06-21 18:58:16 +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
2014-06-21 18:58:16 +01: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
2014-06-21 18:58:16 +01: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-08-22 20:50:48 +01: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-04-23 11:15:54 +01:00
# Pre-Seed master keys
2013-08-22 20:50:48 +01:00
if [ " $_TEMP_KEYS_DIR " != "null" ] && [ " $PRESEED_MASTER_FUNC " != "null" ] ; then
2013-04-23 11:15:54 +01:00
echoinfo " Running ${ PRESEED_MASTER_FUNC } () "
$PRESEED_MASTER_FUNC
if [ $? -ne 0 ] ; then
echoerror " Failed to run ${ PRESEED_MASTER_FUNC } ()!!! "
exit 1
fi
fi
2013-01-08 18:51:54 -08:00
# Install Salt
2014-06-21 18:58:16 +01: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-08-02 17:40:10 -05:00
# Ensure that the cachedir exists
# (Workaround for https://github.com/saltstack/salt/issues/6502)
2014-06-21 18:58:16 +01:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2013-08-02 17:40:10 -05:00
if [ ! -d /var/cache/salt/minion/proc ] ; then
2013-08-03 19:49:49 +01:00
echodebug "Creating salt's cachedir"
2013-08-02 17:40:10 -05:00
mkdir -p /var/cache/salt/minion/proc
2013-08-03 19:49:49 +01:00
fi
2013-08-02 17:40:10 -05:00
fi
2013-01-18 02:42:49 +00:00
2014-02-15 23:29:10 +00:00
# Drop the master address if passed
2014-06-21 18:58:16 +01:00
if [ " $_SALT_MASTER_ADDRESS " != "null" ] ; then
[ ! -d " $_SALT_ETC_DIR /minion.d " ] && mkdir -p " $_SALT_ETC_DIR /minion.d "
2014-02-18 12:29:33 +00:00
cat <<_eof > $_ SALT_ETC_DIR/minion.d/99-master-address.conf
2014-02-15 23:29:10 +00:00
master: $_SALT_MASTER_ADDRESS
_eof
fi
2014-03-21 13:52:54 +01:00
# Drop the minion id if passed
2014-06-21 18:58:16 +01:00
if [ " $_SALT_MINION_ID " != "null" ] ; then
[ ! -d " $_SALT_ETC_DIR " ] && mkdir -p " $_SALT_ETC_DIR "
echo " $_SALT_MINION_ID " > " $_SALT_ETC_DIR /minion_id "
2014-03-21 13:52:54 +01:00
fi
2014-02-16 22:32:56 +00:00
# Run any post install function. Only execute function if not in config mode only
2014-06-21 18:58:16 +01: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
2014-02-16 22:32:56 +00:00
# Run any check services function, Only execute function if not in config mode only
2014-06-21 18:58:16 +01:00
if [ " $_CONFIG_ONLY " -eq $BS_FALSE ] && [ " $CHECK_SERVICES_FUNC " != "null" ] ; then
2014-02-16 22:32:56 +00:00
echoinfo " Running ${ CHECK_SERVICES_FUNC } () "
$CHECK_SERVICES_FUNC
if [ $? -ne 0 ] ; then
echoerror " Failed to run ${ CHECK_SERVICES_FUNC } ()!!! "
exit 1
fi
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 } () "
2014-07-20 22:51:56 +01:00
echodebug " Waiting ${ __DEFAULT_SLEEP } seconds for processes to settle before checking for them "
sleep ${ __DEFAULT_SLEEP }
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
2013-03-06 21:15:14 +00:00
# Check if the installed daemons are running or not
2013-10-24 16:49:04 +02:00
if [ " $DAEMONS_RUNNING_FUNC " != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ] ; then
2013-03-06 21:15:14 +00:00
echoinfo " Running ${ DAEMONS_RUNNING_FUNC } () "
2014-07-20 22:51:56 +01:00
echodebug " Waiting ${ __DEFAULT_SLEEP } seconds for processes to settle before checking for them "
sleep ${ __DEFAULT_SLEEP } # Sleep a little bit to let daemons start
2013-03-06 21:15:14 +00:00
$DAEMONS_RUNNING_FUNC
if [ $? -ne 0 ] ; then
echoerror " Failed to run ${ DAEMONS_RUNNING_FUNC } ()!!! "
2013-03-16 18:38:12 +00:00
2014-07-20 20:59:56 +01:00
for fname in minion master syndic api; do
2014-09-09 20:40:49 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
2013-03-16 18:38:12 +00:00
# Skip if not meant to be installed
2014-06-21 18:58:16 +01:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
2014-09-09 20:40:49 +01:00
#[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
2014-06-21 18:58:16 +01:00
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-03-16 18:38:12 +00:00
2014-06-21 18:58:16 +01:00
if [ " $_ECHO_DEBUG " -eq $BS_FALSE ] ; then
2014-02-08 00:25:30 +00:00
echoerror " salt- $fname was not found running. Pass '-D' to $__ScriptName when bootstrapping for additional debugging information... "
2013-03-23 12:45:56 +00:00
continue
fi
2014-06-21 18:58:16 +01:00
[ ! " $_SALT_ETC_DIR / $fname " ] && [ $fname != "syndic" ] && echodebug " $_SALT_ETC_DIR / $fname does not exist "
2013-03-16 18:38:12 +00:00
2013-03-23 12:45:56 +00:00
echodebug " Running salt- $fname by hand outputs: $( nohup salt-$fname -l debug) "
2013-03-17 12:40:41 +00:00
2013-03-17 11:54:55 +00:00
[ ! -f /var/log/salt/$fname ] && echodebug " /var/log/salt/ $fname does not exist. Can't cat its contents! " && continue
2014-08-11 10:53:32 -07:00
echodebug " DAEMON LOGS for $fname : "
2013-03-17 16:10:19 +00:00
echodebug " $( cat /var/log/salt/$fname ) "
2013-03-17 11:54:55 +00:00
echo
2013-03-16 18:38:12 +00:00
done
2013-03-23 12:45:56 +00:00
echodebug "Running Processes:"
echodebug " $( ps auxwww) "
2013-03-06 21:15:14 +00:00
exit 1
fi
fi
2012-10-17 14:02:09 +01:00
# Done!
2014-06-21 18:58:16 +01: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