2024-06-26 14:14:24 -06:00
#!/bin/sh -x
2018-11-08 15:38:57 -05:00
# WARNING: Changes to this file in the salt repo will be overwritten!
# Please submit pull requests against the salt-bootstrap repo:
# https://github.com/saltstack/salt-bootstrap
2024-02-02 15:32:40 -07:00
# shellcheck disable=SC2317
2018-11-08 15:38:57 -05:00
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
#
2016-02-08 12:30:23 +02: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
#
2024-02-02 17:57:31 -07:00
# COPYRIGHT: (c) 2012-2024 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
2021-01-21 22:44:46 +00:00
# ORGANIZATION: SaltStack (saltproject.io)
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
2016-03-09 12:23:01 +02:00
2024-07-01 13:45:45 -06:00
__ScriptVersion = "2024.07.01"
2016-06-27 17:26:14 +03:00
__ScriptName = "bootstrap-salt.sh"
2016-06-29 11:23:58 +03:00
__ScriptFullName = " $0 "
__ScriptArgs = " $* "
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)
2016-04-11 15:27:04 -07:00
# * BS_PIP_ALL: If 1 enable all python packages to be installed via pip instead of apt, requires setting virtualenv
# * BS_VIRTUALENV_DIR: The virtualenv to install salt into (shouldn't exist yet)
2014-04-16 19:27:40 +01:00
# * 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)
2016-02-17 11:22:44 -06:00
# * BS_SALT_CACHE_DIR: Defaults to /var/cache/salt (Only tweak'able on git based installations)
2014-04-16 19:27:40 +01:00
# * 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
#======================================================================================================================
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
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( ) {
2018-07-09 12:49:11 -04:00
# shellcheck disable=SC2181
2013-08-22 20:50:48 +01:00
if [ $? -eq 0 ] && [ " $_COLORS " -gt 2 ] ; then
2018-06-04 11:51:53 -04:00
RC = '\033[1;31m'
GC = '\033[1;32m'
BC = '\033[1;34m'
YC = '\033[1;33m'
EC = '\033[0m'
2013-02-11 20:22:33 +00:00
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( ) {
2018-05-31 13:28:18 -04: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( ) {
2018-05-31 13:28:18 -04: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
2018-01-29 08:55:27 -05:00
# DESCRIPTION: Echo warning information to stdout.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2013-02-20 12:09:35 +00:00
echowarn( ) {
2018-05-31 13:28:18 -04: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
2018-05-31 13:28:18 -04:00
printf " ${ BC } * DEBUG ${ EC } : %s\\n " " $@ " ;
2013-02-11 20:44:46 +00:00
fi
2013-02-11 19:17:21 +00:00
}
2016-01-25 09:00:32 -05:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_command_exists
# DESCRIPTION: Check if a command exists.
#----------------------------------------------------------------------------------------------------------------------
__check_command_exists( ) {
command -v " $1 " > /dev/null 2>& 1
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2016-03-06 11:50:44 +02:00
# NAME: __check_pip_allowed
2017-06-06 13:06:39 +03:00
# DESCRIPTION: Simple function to let the users know that -P needs to be used.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2016-03-06 11:50:44 +02:00
__check_pip_allowed( ) {
2024-07-01 11:48:29 -06:00
## DGM __install_tornado_pip supplied an error msg, but no longer used, now shellcheck complains about unused parameter
## DGM if [ $# -eq 1 ]; then
## DGM _PIP_ALLOWED_ERROR_MSG=$1
## DGM else
## DGM _PIP_ALLOWED_ERROR_MSG="pip based installations were not allowed. Retry using '-P'"
## DGM fi
_PIP_ALLOWED_ERROR_MSG = "pip based installations were not allowed. Retry using '-P'"
2014-02-17 15:22:28 +00:00
2024-06-28 17:04:56 -06:00
if [ " $_PIP_ALLOWED " -eq $BS_FALSE ] ; then
2014-02-19 11:06:42 +00:00
echoerror " $_PIP_ALLOWED_ERROR_MSG "
2016-03-08 13:28:42 +02:00
__usage
2013-04-23 10:38:42 +01:00
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 } "
; ;
2017-06-06 13:06:39 +03:00
*://*)
echoerror " Unsupported URI scheme for $CC_DIR_NAME "
echo "null"
return
; ;
2014-01-24 23:42:45 +00:00
*)
if [ ! -e " ${ CC_DIR_NAME } " ] ; then
2017-06-06 13:06:39 +03:00
echoerror " The configuration directory or archive $CC_DIR_NAME does not exist. "
2014-01-24 23:42:45 +00:00
echo "null"
2017-06-06 13:06:39 +03:00
return
2014-01-24 23:42:45 +00:00
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 } "
}
2017-06-06 13:06:39 +03:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_unparsed_options
# DESCRIPTION: Checks the placed after the install arguments
#----------------------------------------------------------------------------------------------------------------------
__check_unparsed_options( ) {
shellopts = " $1 "
# grep alternative for SunOS
if [ -f /usr/xpg4/bin/grep ] ; then
grep = '/usr/xpg4/bin/grep'
else
grep = 'grep'
fi
unparsed_options = $( echo " $shellopts " | ${ grep } -E '(^|[[:space:]])[-]+[[:alnum:]]' )
if [ " $unparsed_options " != "" ] ; then
__usage
echo
echoerror "options are only allowed before install arguments"
echo
exit 1
fi
}
2014-01-24 23:42:45 +00:00
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"
2016-08-27 23:40:56 +03:00
_SALTSTACK_REPO_URL = "https://github.com/saltstack/salt.git"
2014-08-21 00:52:23 +01:00
_SALT_REPO_URL = ${ _SALTSTACK_REPO_URL }
_TEMP_KEYS_DIR = "null"
2016-03-09 12:23:01 +02:00
_SLEEP = " ${ __DEFAULT_SLEEP } "
2014-08-21 00:52:23 +01:00
_INSTALL_MASTER = $BS_FALSE
_INSTALL_SYNDIC = $BS_FALSE
_INSTALL_MINION = $BS_TRUE
_INSTALL_CLOUD = $BS_FALSE
2016-04-11 15:27:04 -07:00
_VIRTUALENV_DIR = ${ BS_VIRTUALENV_DIR :- "null" }
2014-08-21 00:52:23 +01:00
_START_DAEMONS = $BS_TRUE
2016-06-24 10:45:35 +03:00
_DISABLE_SALT_CHECKS = $BS_FALSE
2014-08-21 00:52:23 +01:00
_ECHO_DEBUG = ${ BS_ECHO_DEBUG :- $BS_FALSE }
_CONFIG_ONLY = $BS_FALSE
_PIP_ALLOWED = ${ BS_PIP_ALLOWED :- $BS_FALSE }
2016-04-11 15:27:04 -07:00
_PIP_ALL = ${ BS_PIP_ALL :- $BS_FALSE }
2019-11-18 09:47:01 -07:00
_SALT_ETC_DIR = ${ BS_SALT_ETC_DIR :- /etc/salt }
2016-02-17 11:22:44 -06:00
_SALT_CACHE_DIR = ${ BS_SALT_CACHE_DIR :- /var/cache/salt }
2014-08-21 00:52:23 +01:00
_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 }
2016-03-07 11:38:28 +02:00
_EPEL_REPOS_INSTALLED = $BS_FALSE
2014-08-21 00:52:23 +01:00
_UPGRADE_SYS = ${ BS_UPGRADE_SYS :- $BS_FALSE }
_INSECURE_DL = ${ BS_INSECURE_DL :- $BS_FALSE }
_CURL_ARGS = ${ BS_CURL_ARGS :- }
_FETCH_ARGS = ${ BS_FETCH_ARGS :- }
2016-08-18 17:39:11 +03:00
_GPG_ARGS = ${ BS_GPG_ARGS :- }
_WGET_ARGS = ${ BS_WGET_ARGS :- }
2014-08-21 00:52:23 +01:00
_SALT_MASTER_ADDRESS = ${ BS_SALT_MASTER_ADDRESS :- null }
_SALT_MINION_ID = "null"
2016-03-07 11:38:28 +02:00
# _SIMPLIFY_VERSION is mostly used in Solaris based distributions
_SIMPLIFY_VERSION = $BS_TRUE
2014-08-21 00:52:23 +01:00
_LIBCLOUD_MIN_VERSION = "0.14.0"
_EXTRA_PACKAGES = ""
_HTTP_PROXY = ""
2016-03-07 11:38:28 +02:00
_SALT_GIT_CHECKOUT_DIR = ${ BS_SALT_GIT_CHECKOUT_DIR :- /tmp/git/salt }
2015-09-17 17:12:16 +02:00
_NO_DEPS = $BS_FALSE
2015-09-22 13:30:42 +02:00
_FORCE_SHALLOW_CLONE = $BS_FALSE
2016-04-11 11:43:42 -06:00
_DISABLE_SSL = $BS_FALSE
2016-04-18 11:57:24 -06:00
_DISABLE_REPOS = $BS_FALSE
2016-06-09 11:18:30 -06:00
_CUSTOM_REPO_URL = "null"
2016-05-06 12:53:11 -06:00
_CUSTOM_MASTER_CONFIG = "null"
_CUSTOM_MINION_CONFIG = "null"
2016-05-30 13:48:48 +02:00
_QUIET_GIT_INSTALLATION = $BS_FALSE
2021-01-21 22:44:46 +00:00
_REPO_URL = "repo.saltproject.io"
2022-07-27 13:25:02 -07:00
_ONEDIR_DIR = "salt"
2022-12-05 08:06:03 +00:00
_ONEDIR_NIGHTLY_DIR = " salt-dev/ ${ _ONEDIR_DIR } "
2021-07-21 21:44:13 +00:00
_PY_EXE = "python3"
2024-06-27 14:18:42 -06:00
## DGM _INSTALL_PY="$BS_FALSE"
2024-02-08 09:28:56 -07:00
## DGM _TORNADO_MAX_PY3_VERSION="5.0"
2021-01-22 16:18:35 +00:00
_MINIMUM_PIP_VERSION = "9.0.1"
2020-01-30 12:36:56 +00:00
_MINIMUM_SETUPTOOLS_VERSION = "9.1"
_POST_NEON_PIP_INSTALL_ARGS = "--prefix=/usr"
2023-02-03 16:39:35 -08:00
_PIP_DOWNLOAD_ARGS = ""
2023-07-13 10:36:49 -07:00
_QUICK_START = " $BS_FALSE "
_AUTO_ACCEPT_MINION_KEYS = " $BS_FALSE "
2014-08-21 00:52:23 +01:00
2017-06-06 13:06:39 +03:00
# Defaults for install arguments
ITYPE = "stable"
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2016-03-08 13:28:42 +02:00
# NAME: __usage
2012-10-17 16:07:33 +01:00
# DESCRIPTION: Display usage information.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2016-03-08 13:28:42 +02:00
__usage( ) {
2012-10-17 16:07:33 +01:00
cat << EOT
2016-03-08 13:28:42 +02:00
Usage : ${ __ScriptName } [ options] <install-type> [ install-type-args]
2012-10-17 16:07:33 +01:00
Installation types:
2022-04-11 16:47:01 -07:00
- stable Install latest stable release. This is the default
install type
- stable [ branch] Install latest version on a branch. Only supported
for packages available at repo.saltproject.io
- stable [ version] Install a specific version. Only supported for
packages available at repo.saltproject.io
To pin a 3xxx minor version, specify it as 3xxx.0
- testing RHEL-family specific: configure EPEL testing repo
- git Install from the head of the master branch
- git [ ref] Install from any git ref ( such as a branch, tag, or
commit)
2022-07-27 13:25:02 -07:00
- onedir Install latest onedir release.
- onedir [ version] Install a specific version. Only supported for
onedir packages available at repo.saltproject.io
2012-10-17 16:07:33 +01:00
2022-07-27 13:25:02 -07:00
- onedir_rc Install latest onedir RC release.
- onedir_rc [ version] Install a specific version. Only supported for
onedir RC packages available at repo.saltproject.io
2022-07-21 15:43:17 -07:00
2012-10-19 12:22:59 +01:00
Examples:
2014-04-03 07:46:32 +01:00
- ${ __ScriptName }
- ${ __ScriptName } stable
2023-06-25 11:07:38 -07:00
- ${ __ScriptName } stable 3006
- ${ __ScriptName } stable 3006.1
2015-03-12 03:56:11 -07:00
- ${ __ScriptName } testing
2014-04-03 07:46:32 +01:00
- ${ __ScriptName } git
2024-06-28 17:04:56 -06:00
- ${ __ScriptName } git 3006.7
- ${ __ScriptName } git v3006.8
- ${ __ScriptName } git 3007.1
- ${ __ScriptName } git v3007.1
2016-07-11 14:16:48 +03:00
- ${ __ScriptName } git 06f249901a2e2f1ed310d58ea3921a129f214358
2022-07-27 13:25:02 -07:00
- ${ __ScriptName } onedir
2023-06-25 11:07:38 -07:00
- ${ __ScriptName } onedir 3006
2022-07-27 13:25:02 -07:00
- ${ __ScriptName } onedir_rc
2024-06-28 17:04:56 -06:00
- ${ __ScriptName } onedir_rc 3008
2023-06-25 11:07:38 -07:00
2012-10-19 12:22:59 +01:00
2012-10-17 16:07:33 +01:00
Options:
2021-09-23 08:32:01 +02:00
-a Pip install all Python pkg dependencies for Salt. Requires -V to install
all pip pkgs into the virtualenv.
( Only available for Ubuntu based distributions)
-A Pass the salt-master DNS name or IP. This will be stored under
\$ { BS_SALT_ETC_DIR} /minion.d/99-master-address.conf
-b Assume that dependencies are already installed and software sources are
set up. If git is selected, git tree is still checked out as dependency
step.
2016-02-08 12:16:02 +02:00
-c Temporary configuration directory
2021-09-23 08:32:01 +02:00
-C Only run the configuration function . Implies -F ( forced overwrite) .
To overwrite Master or Syndic configs, -M or -S, respectively, must
also be specified. Salt installation will be ommitted, but some of the
dependencies could be installed to write configuration with -j or -J.
2016-06-24 10:45:35 +03:00
-d Disables checking if Salt services are enabled to start on system boot.
You can also do this by touching /tmp/disable_salt_checks on the target
host. Default: \$ { BS_FALSE}
2021-09-23 08:32:01 +02:00
-D Show debug output
-f Force shallow cloning for git installations.
This may result in an "n/a" in the version number.
-F Allow copied files to overwrite existing ( config, init.d, etc)
-g Salt Git repository URL. Default: ${ _SALTSTACK_REPO_URL }
-h Display this message
-H Use the specified HTTP proxy for all download URLs ( including https://) .
For example: http://myproxy.example.com:3128
-i Pass the salt-minion id. This will be stored under
\$ { BS_SALT_ETC_DIR} /minion_id
2016-02-08 12:16:02 +02:00
-I If set, allow insecure connections while downloading any files. For
example, pass '--no-check-certificate' to 'wget' or '--insecure' to
2018-01-29 08:55:27 -05:00
'curl' . On Debian and Ubuntu, using this option with -U allows obtaining
2016-08-19 11:14:58 +03:00
GnuPG archive keys insecurely if distro has changed release signatures.
2021-09-23 08:32:01 +02:00
-j Replace the Minion config file with data passed in as a JSON string. If
a Minion config file is found, a reasonable effort will be made to save
the file with a ".bak" extension. If used in conjunction with -C or -F,
no ".bak" file will be created as either of those options will force
a complete overwrite of the file.
-J Replace the Master config file with data passed in as a JSON string. If
a Master config file is found, a reasonable effort will be made to save
the file with a ".bak" extension. If used in conjunction with -C or -F,
no ".bak" file will be created as either of those options will force
a complete overwrite of the file.
-k Temporary directory holding the minion keys which will pre-seed
the master.
2016-08-19 11:14:58 +03:00
-K If set, keep the temporary files in the temporary directories specified
with -c and -k
2016-04-11 11:43:42 -06:00
-l Disable ssl checks. When passed, switches "https" calls to "http" where
possible.
2021-09-23 08:32:01 +02:00
-L Also install salt-cloud and required python-libcloud package
-M Also install salt-master
-n No colours
-N Do not install salt-minion
-p Extra-package to install while installing Salt dependencies. One package
per -p flag. You are responsible for providing the proper package name.
-P Allow pip based installations. On some distributions the required salt
packages or its dependencies are not available as a package for that
distribution. Using this flag allows the script to use pip as a last
resort method. NOTE: This only works for functions which actually
implement pip based installations.
-q Quiet salt installation from git ( setup.py install -q)
2023-07-12 20:44:43 -07:00
-Q Quickstart, install the Salt master and the Salt minion.
And automatically accept the minion key.
2016-06-06 11:24:22 +03:00
-R Specify a custom repository URL. Assumes the custom repository URL
points to a repository that mirrors Salt packages located at
2021-01-21 22:44:46 +00:00
repo.saltproject.io. The option passed with -R replaces the
"repo.saltproject.io" . If -R is passed, -r is also set. Currently only
2022-09-20 19:32:59 +00:00
works on CentOS/RHEL and Debian based distributions and macOS.
2021-09-23 08:32:01 +02:00
-s Sleep time used when waiting for daemons to start, restart and when
checking for the services running. Default: ${ __DEFAULT_SLEEP }
-S Also install salt-syndic
-r Disable all repository configuration performed by this script. This
option assumes all necessary repository configuration is already present
on the system.
-U If set, fully upgrade the system prior to bootstrapping Salt
-v Display script version
-V Install Salt into virtualenv
( only available for Ubuntu based distributions)
2018-08-09 21:12:57 +02:00
-x Changes the Python version used to install Salt.
2024-02-02 17:57:31 -07:00
Python 2.7 is no longer supported.
2024-02-08 09:28:56 -07:00
Fedora git installation, CentOS 8, Ubuntu 20.04 support python3.
2021-09-23 08:32:01 +02:00
-X Do not start daemons after installation
2013-02-10 19:46:56 +00:00
2012-10-17 16:07:33 +01:00
EOT
2016-03-08 13:28:42 +02:00
} # ---------- end of function __usage ----------
2012-10-17 16:07:33 +01:00
2024-06-27 14:18:42 -06:00
## DGM -y Installs a different python version on host. Currently this has only been
## DGM tested with CentOS 7 and is considered experimental. This will install the
## DGM ius repo on the box if disable repo is false. This must be used in conjunction
## DGM with -x <pythonversion>. For example:
## DGM sh bootstrap.sh -P -y -x python3.8 git v3006.3
## DGM The above will install python38 and install the git version of salt using the
## DGM python3.8 executable. This only works for git and pip installations.
2013-05-15 10:44:07 +01:00
2024-06-27 14:18:42 -06:00
## DGM while getopts ':hvnDc:g:Gyx:k:s:MSNXCPFUKIA:i:Lp:dH:bflV:J:j:rR:aqQ' opt
while getopts ':hvnDc:g:Gx:k:s:MSNXCPFUKIA:i:Lp:dH:bflV:J:j:rR:aqQ' opt
2012-10-17 16:07:33 +01:00
do
2013-01-25 17:57:12 +00:00
case " ${ opt } " in
2016-03-09 12:27:10 +02:00
h ) __usage; exit 0 ; ;
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 ; ;
2017-06-06 13:06:39 +03:00
c ) _TEMP_CONFIG_DIR = " $OPTARG " ; ;
2016-04-05 15:00:13 -06:00
g ) _SALT_REPO_URL = $OPTARG ; ;
2016-03-09 12:27:10 +02:00
2016-09-13 14:38:21 +03:00
G ) echowarn "The '-G' option is DEPRECATED and will be removed in the future stable release!"
echowarn "Bootstrap will always use 'https' protocol to clone from SaltStack GitHub repo."
echowarn "No need to provide this option anymore, now it is a default behavior."
; ;
2017-06-06 13:06:39 +03:00
k ) _TEMP_KEYS_DIR = " $OPTARG " ; ;
2016-03-10 10:53:52 +02:00
s ) _SLEEP = $OPTARG ; ;
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 " ; ;
2015-09-17 17:12:16 +02:00
b ) _NO_DEPS = $BS_TRUE ; ;
2015-09-22 13:30:42 +02:00
f ) _FORCE_SHALLOW_CLONE = $BS_TRUE ; ;
2016-04-11 11:43:42 -06:00
l ) _DISABLE_SSL = $BS_TRUE ; ;
2016-04-11 15:27:04 -07:00
V ) _VIRTUALENV_DIR = " $OPTARG " ; ;
a ) _PIP_ALL = $BS_TRUE ; ;
2016-04-18 11:57:24 -06:00
r ) _DISABLE_REPOS = $BS_TRUE ; ;
2016-06-09 11:18:30 -06:00
R ) _CUSTOM_REPO_URL = $OPTARG ; ;
2016-05-06 12:53:11 -06:00
J ) _CUSTOM_MASTER_CONFIG = $OPTARG ; ;
j ) _CUSTOM_MINION_CONFIG = $OPTARG ; ;
2016-05-30 13:48:48 +02:00
q ) _QUIET_GIT_INSTALLATION = $BS_TRUE ; ;
2023-07-12 20:44:43 -07:00
Q ) _QUICK_START = $BS_TRUE ; ;
2017-04-17 17:37:38 -04:00
x ) _PY_EXE = " $OPTARG " ; ;
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 "
2016-03-08 13:28:42 +02:00
__usage
2013-01-25 17:57:12 +00:00
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
2024-06-27 14:18:42 -06:00
## DGM y ) _INSTALL_PY="$BS_TRUE" ;;
2013-02-07 20:48:50 +00:00
2017-06-06 13:06:39 +03:00
# Define our logging file and pipe paths
LOGFILE = " /tmp/ $( echo " $__ScriptName " | sed s/.sh/.log/g ) "
LOGPIPE = " /tmp/ $( echo " $__ScriptName " | sed s/.sh/.logpipe/g ) "
2018-07-11 00:07:01 +01:00
# Ensure no residual pipe exists
rm " $LOGPIPE " 2>/dev/null
2013-01-25 02:01:00 +00:00
2017-06-06 13:06:39 +03:00
# Create our logging pipe
# On FreeBSD we have to use mkfifo instead of mknod
2018-07-09 12:49:11 -04:00
if ! ( mknod " $LOGPIPE " p >/dev/null 2>& 1 || mkfifo " $LOGPIPE " >/dev/null 2>& 1) ; then
2017-06-06 13:06:39 +03:00
echoerror "Failed to create the named pipe required to log"
2014-02-15 23:29:10 +00:00
exit 1
fi
2017-06-06 13:06:39 +03:00
# What ever is written to the logpipe gets written to the logfile
tee < " $LOGPIPE " " $LOGFILE " &
2014-02-15 23:29:10 +00:00
2017-06-06 13:06:39 +03:00
# Close STDOUT, reopen it directing it to the logpipe
exec 1>& -
exec 1>" $LOGPIPE "
# Close STDERR, reopen it directing it to the logpipe
exec 2>& -
exec 2>" $LOGPIPE "
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __exit_cleanup
# DESCRIPTION: Cleanup any leftovers after script has ended
#
#
# 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
#----------------------------------------------------------------------------------------------------------------------
2019-09-18 21:04:29 +08:00
APT_ERR = $( mktemp /tmp/apt_error.XXXXXX)
2017-06-06 13:06:39 +03:00
__exit_cleanup( ) {
EXIT_CODE = $?
if [ " $ITYPE " = "git" ] && [ -d " ${ _SALT_GIT_CHECKOUT_DIR } " ] ; then
2024-06-28 17:04:56 -06:00
if [ $_KEEP_TEMP_FILES -eq $BS_FALSE ] ; then
2017-06-06 13:06:39 +03:00
# Clean up the checked out repository
echodebug "Cleaning up the Salt Temporary Git Repository"
# shellcheck disable=SC2164
cd " ${ __SALT_GIT_CHECKOUT_PARENT_DIR } "
rm -rf " ${ _SALT_GIT_CHECKOUT_DIR } "
2020-01-30 12:36:56 +00:00
#rm -rf "${_SALT_GIT_CHECKOUT_DIR}/deps"
2017-06-06 13:06:39 +03:00
else
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"
fi
2016-05-06 12:53:11 -06:00
fi
2017-06-06 13:06:39 +03:00
# Remove the logging pipe when the script exits
if [ -p " $LOGPIPE " ] ; then
echodebug " Removing the logging pipe $LOGPIPE "
rm -f " $LOGPIPE "
2016-05-06 12:53:11 -06:00
fi
2017-06-06 13:06:39 +03:00
2019-03-20 14:36:28 -04:00
# Remove the temporary apt error file when the script exits
if [ -f " $APT_ERR " ] ; then
echodebug " Removing the temporary apt error file $APT_ERR "
rm -f " $APT_ERR "
fi
2017-06-06 13:06:39 +03:00
# Kill tee when exiting, CentOS, at least requires this
# shellcheck disable=SC2009
2019-04-16 19:56:21 -06:00
TEE_PID = $( ps ax | grep tee | grep " $LOGFILE " | awk '{print $1}' )
2017-06-06 13:06:39 +03:00
2024-06-28 17:04:56 -06:00
[ " $TEE_PID " = "" ] && exit $EXIT_CODE
2017-06-06 13:06:39 +03:00
echodebug " Killing logging pipe tee's with pid(s): $TEE_PID "
# 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( ) {
echoinfo " Errors Trapped: $EXIT_CODE "
# Exit with the "original" exit code, not the trapped code
2024-06-28 17:04:56 -06:00
exit $EXIT_CODE
2017-06-06 13:06:39 +03:00
}
trap "__trap_errors" INT ABRT QUIT TERM
# Now we're "good" to kill tee
kill -s TERM " $TEE_PID "
# In case the 127 errno is not triggered, exit with the "original" exit code
2024-06-28 17:04:56 -06:00
exit $EXIT_CODE
2017-06-06 13:06:39 +03:00
}
trap "__exit_cleanup" EXIT INT
# Let's discover how we're being called
# shellcheck disable=SC2009
2019-04-16 19:56:21 -06:00
CALLER = $( ps -a -o pid,args | grep $$ | grep -v grep | tr -s ' ' | cut -d ' ' -f 3)
2017-06-06 13:06:39 +03:00
if [ " ${ CALLER } x " = " ${ 0 } x " ] ; then
CALLER = "shell pipe"
2016-05-06 12:53:11 -06:00
fi
2014-02-15 23:29:10 +00:00
2017-06-06 13:06:39 +03:00
echoinfo " Running version: ${ __ScriptVersion } "
echoinfo " Executed by: ${ CALLER } "
echoinfo " Command line: ' ${ __ScriptFullName } ${ __ScriptArgs } ' "
echowarn " Running the unstable version of ${ __ScriptName } "
2012-10-17 14:02:09 +01:00
# Define installation type
2017-06-06 13:06:39 +03:00
if [ " $# " -gt 0 ] ; then
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
2024-02-08 09:28:56 -07:00
if [ " $( echo " $ITYPE " | grep -E '(stable|testing|git|onedir|onedir_rc)' ) " = "" ] ; 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
2020-01-28 17:38:43 +00:00
GIT_REV = "master"
2012-10-19 12:22:59 +01:00
else
2012-11-28 18:47:20 +00:00
GIT_REV = " $1 "
2012-10-19 12:22:59 +01:00
shift
fi
2016-04-29 17:03:48 +03:00
# Disable shell warning about unbound variable during git install
2016-07-11 14:16:48 +03:00
STABLE_REV = "latest"
2016-04-29 17:03:48 +03:00
2015-03-12 03:52:31 -07:00
# If doing stable install, check if version specified
elif [ " $ITYPE " = "stable" ] ; then
if [ " $# " -eq 0 ] ; then
2023-03-29 15:52:05 -07:00
ONEDIR_REV = "latest"
2023-04-26 10:30:40 -07:00
_ONEDIR_REV = "latest"
2023-03-29 14:57:31 -07:00
ITYPE = "onedir"
2015-03-12 03:52:31 -07:00
else
2024-06-26 16:10:43 -06:00
if [ " $( echo " $1 " | grep -E '^(nightly|latest|3006|3007)$' ) " != "" ] ; then
2023-03-29 14:57:31 -07:00
ONEDIR_REV = " $1 "
2023-04-14 05:18:17 -07:00
_ONEDIR_REV = " $1 "
2023-03-29 14:57:31 -07:00
ITYPE = "onedir"
shift
2024-06-25 15:56:18 -06:00
elif [ " $( echo " $1 " | grep -E '^([3-9][0-5]{2}[5-9](\.[0-9]*)?)' ) " != "" ] ; then
2023-03-29 14:57:31 -07:00
ONEDIR_REV = " minor/ $1 "
2023-03-31 12:57:37 -07:00
_ONEDIR_REV = " $1 "
2023-03-29 14:57:31 -07:00
ITYPE = "onedir"
shift
2023-06-25 11:07:38 -07:00
else
2024-06-26 16:10:43 -06:00
echo " Unknown stable version: $1 (valid: 3006, 3007, latest) "
2016-04-29 17:03:48 +03:00
exit 1
2015-03-12 03:52:31 -07:00
fi
fi
2022-04-11 16:47:01 -07:00
2022-07-27 13:25:02 -07:00
elif [ " $ITYPE " = "onedir" ] ; then
2022-07-21 12:34:33 -07:00
if [ " $# " -eq 0 ] ; then
2022-07-27 13:25:02 -07:00
ONEDIR_REV = "latest"
2022-07-21 12:34:33 -07:00
else
2024-06-26 16:10:43 -06:00
if [ " $( echo " $1 " | grep -E '^(nightly|latest|3006|3007)$' ) " != "" ] ; then
2022-07-27 13:25:02 -07:00
ONEDIR_REV = " $1 "
2022-07-21 12:34:33 -07:00
shift
2024-06-25 15:56:18 -06:00
elif [ " $( echo " $1 " | grep -E '^([3-9][0-9]{3}(\.[0-9]*)?)' ) " != "" ] ; then
2022-11-02 09:24:50 -07:00
ONEDIR_REV = " minor/ $1 "
shift
2022-07-21 12:34:33 -07:00
else
2024-06-26 16:10:43 -06:00
echo " Unknown onedir version: $1 (valid: 3006, 3007, latest, nightly.) "
2022-07-21 12:34:33 -07:00
exit 1
fi
fi
2022-07-27 13:25:02 -07:00
elif [ " $ITYPE " = "onedir_rc" ] ; then
# Change the _ONEDIR_DIR to be the location for the RC packages
_ONEDIR_DIR = "salt_rc/salt"
2022-07-21 15:43:17 -07:00
2022-07-27 13:25:02 -07:00
# Change ITYPE to onedir so we use the regular onedir functions
ITYPE = "onedir"
2022-07-21 15:43:17 -07:00
if [ " $# " -eq 0 ] ; then
2022-07-27 13:25:02 -07:00
ONEDIR_REV = "latest"
2022-07-21 15:43:17 -07:00
else
if [ " $( echo " $1 " | grep -E '^(latest)$' ) " != "" ] ; then
2022-07-27 13:25:02 -07:00
ONEDIR_REV = " $1 "
2022-07-21 15:43:17 -07:00
shift
2024-06-25 15:56:18 -06:00
elif [ " $( echo " $1 " | grep -E '^([3-9][0-9]{3}?rc[0-9]-[0-9]$)' ) " != "" ] ; then
2022-07-21 15:43:17 -07:00
# Handle the 3xxx.0 version as 3xxx archive (pin to minor) and strip the fake ".0" suffix
2022-07-27 13:25:02 -07:00
#ONEDIR_REV=$(echo "$1" | sed -E 's/^([3-9][0-9]{3})\.0$/\1/')
ONEDIR_REV = " minor/ $1 "
2022-07-21 15:43:17 -07:00
shift
2024-06-25 15:56:18 -06:00
elif [ " $( echo " $1 " | grep -E '^([3-9][0-9]{3}\.[0-9]?rc[0-9]$)' ) " != "" ] ; then
2023-03-02 18:56:39 -08:00
# Handle the 3xxx.0 version as 3xxx archive (pin to minor) and strip the fake ".0" suffix
#ONEDIR_REV=$(echo "$1" | sed -E 's/^([3-9][0-9]{3})\.0$/\1/')
ONEDIR_REV = " minor/ $1 "
shift
2022-07-21 15:43:17 -07:00
else
2024-06-26 16:10:43 -06:00
echo " Unknown onedir_rc version: $1 (valid: 3006-8, 3007-1, latest) "
2022-07-21 15:43:17 -07:00
exit 1
fi
fi
2012-10-19 12:22:59 +01:00
fi
2023-07-13 10:17:33 -07:00
# Doing a quick start, so install master
# set master address to 127.0.0.1
if [ " $_QUICK_START " -eq " $BS_TRUE " ] ; then
# make install type is stable
ITYPE = "stable"
# make sure the revision is latest
STABLE_REV = "latest"
ONEDIR_REV = "latest"
# make sure we're installing the master
_INSTALL_MASTER = $BS_TRUE
# override incase install minion
# is set to false
_INSTALL_MINION = $BS_TRUE
# Set master address to loopback IP
_SALT_MASTER_ADDRESS = "127.0.0.1"
# Auto accept the minion key
# when the install is done.
_AUTO_ACCEPT_MINION_KEYS = $BS_TRUE
fi
2017-06-06 13:06:39 +03:00
# Check for any unparsed arguments. Should be an error.
if [ " $# " -gt 0 ] ; then
__usage
echo
echoerror "Too many arguments."
exit 1
fi
# whoami alternative for SunOS
if [ -f /usr/xpg4/bin/id ] ; then
whoami = '/usr/xpg4/bin/id -un'
else
whoami = 'whoami'
fi
# Root permissions are required to run this script
if [ " $( $whoami ) " != "root" ] ; then
echoerror "Salt requires root privileges to install. Please re-run this script as root."
exit 1
fi
# Check that we're actually installing one of minion/master/syndic
if [ " $_INSTALL_MINION " -eq $BS_FALSE ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
echowarn "Nothing to install or configure"
exit 1
fi
# Check that we're installing a minion if we're being passed a master address
if [ " $_INSTALL_MINION " -eq $BS_FALSE ] && [ " $_SALT_MASTER_ADDRESS " != "null" ] ; then
echoerror "Don't pass a master address (-A) if no minion is going to be bootstrapped."
exit 1
fi
# Check that we're installing a minion if we're being passed a minion id
if [ " $_INSTALL_MINION " -eq $BS_FALSE ] && [ " $_SALT_MINION_ID " != "null" ] ; then
echoerror "Don't pass a minion id (-i) if no minion is going to be bootstrapped."
exit 1
fi
# Check that we're installing or configuring a master if we're being passed a master config json dict
if [ " $_CUSTOM_MASTER_CONFIG " != "null" ] ; then
if [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
echoerror "Don't pass a master config JSON dict (-J) if no master is going to be bootstrapped or configured."
exit 1
fi
fi
# Check that we're installing or configuring a minion if we're being passed a minion config json dict
if [ " $_CUSTOM_MINION_CONFIG " != "null" ] ; then
if [ " $_INSTALL_MINION " -eq $BS_FALSE ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
echoerror "Don't pass a minion config JSON dict (-j) if no minion is going to be bootstrapped or configured."
exit 1
fi
fi
2024-06-25 15:56:18 -06:00
# Default to Python 3, no longer support for Python 2
2024-06-26 12:00:17 -06:00
PY_PKG_VER = 3
_PY_PKG_VER = "python3"
2024-06-25 15:56:18 -06:00
_PY_MAJOR_VERSION = "3"
2024-06-28 17:04:56 -06:00
__PY_VERSION_REPO = "py3"
2024-06-25 15:56:18 -06:00
2018-05-31 10:13:12 -04:00
# Check if we're installing via a different Python executable and set major version variables
if [ -n " $_PY_EXE " ] ; then
2019-08-28 13:15:23 -07:00
if [ " $( uname) " = "Darwin" ] ; then
_PY_PKG_VER = $( echo " $_PY_EXE " | sed "s/\\.//g" )
else
2019-11-06 22:27:16 +00:00
_PY_PKG_VER = $( echo " $_PY_EXE " | sed -E "s/\\.//g" )
2019-08-28 13:15:23 -07:00
fi
2018-05-31 10:13:12 -04:00
2024-06-25 15:56:18 -06:00
TEST_PY_MAJOR_VERSION = $( echo " $_PY_PKG_VER " | cut -c 7)
if [ " $TEST_PY_MAJOR_VERSION " -eq 2 ] ; then
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
fi
2024-06-26 12:00:17 -06:00
if [ " $TEST_PY_MAJOR_VERSION " != 3 ] ; then
2024-02-02 17:57:31 -07:00
echoerror "Detected -x option, but Python major version is not 3."
echoerror "The -x option must be passed as python3, python38, or python3.8 (use the Python '3' versions of examples)."
2018-05-31 10:13:12 -04:00
exit 1
fi
2021-08-24 20:54:46 +00:00
if [ " $_PY_EXE " != "python3" ] ; then
echoinfo " Detected -x option. Using $_PY_EXE to install Salt. "
fi
2018-05-31 10:13:12 -04:00
fi
2017-06-06 13:06:39 +03:00
# If the configuration directory or archive does not exist, error out
if [ " $_TEMP_CONFIG_DIR " != "null" ] ; then
_TEMP_CONFIG_DIR = " $( __check_config_dir " $_TEMP_CONFIG_DIR " ) "
[ " $_TEMP_CONFIG_DIR " = "null" ] && exit 1
fi
# If the pre-seed keys directory does not exist, error out
if [ " $_TEMP_KEYS_DIR " != "null" ] && [ ! -d " $_TEMP_KEYS_DIR " ] ; then
echoerror " The pre-seed keys directory ${ _TEMP_KEYS_DIR } does not exist. "
exit 1
fi
2016-04-11 15:27:04 -07:00
# -a and -V only work from git
if [ " $ITYPE " != "git" ] ; then
2024-06-28 17:04:56 -06:00
if [ " $_PIP_ALL " -eq $BS_TRUE ] ; then
2016-08-18 17:39:11 +03:00
echoerror "Pip installing all python packages with -a is only possible when installing Salt via git"
2016-04-11 15:27:04 -07:00
exit 1
fi
2016-04-13 02:52:10 -06:00
if [ " $_VIRTUALENV_DIR " != "null" ] ; then
2016-08-18 17:39:11 +03:00
echoerror "Virtualenv installs via -V is only possible when installing Salt via git"
2016-04-11 15:27:04 -07:00
exit 1
fi
fi
2021-01-21 22:44:46 +00:00
# Set the _REPO_URL value based on if -R was passed or not. Defaults to repo.saltproject.io.
2017-03-21 17:13:10 -06:00
if [ " $_CUSTOM_REPO_URL " != "null" ] ; then
_REPO_URL = " $_CUSTOM_REPO_URL "
# Check for -r since -R is being passed. Set -r with a warning.
2024-06-28 17:04:56 -06:00
if [ " $_DISABLE_REPOS " -eq $BS_FALSE ] ; then
2017-03-21 17:13:10 -06:00
echowarn "Detected -R option. No other repositories will be configured when -R is used. Setting -r option to True."
2024-06-28 17:04:56 -06:00
_DISABLE_REPOS = $BS_TRUE
2017-04-13 14:18:47 -06:00
fi
2016-06-09 11:18:30 -06:00
fi
2016-04-11 11:43:42 -06:00
# Check the _DISABLE_SSL value and set HTTP or HTTPS.
2024-06-28 17:04:56 -06:00
if [ " $_DISABLE_SSL " -eq $BS_TRUE ] ; then
2016-04-11 11:43:42 -06:00
HTTP_VAL = "http"
else
HTTP_VAL = "https"
fi
2016-05-30 13:48:48 +02:00
# Check the _QUIET_GIT_INSTALLATION value and set SETUP_PY_INSTALL_ARGS.
2016-08-18 17:39:11 +03:00
if [ " $_QUIET_GIT_INSTALLATION " -eq $BS_TRUE ] ; then
2016-05-30 13:48:48 +02:00
SETUP_PY_INSTALL_ARGS = "-q"
else
SETUP_PY_INSTALL_ARGS = ""
fi
2017-08-29 15:46:17 +03:00
# Handle the insecure flags
if [ " $_INSECURE_DL " -eq $BS_TRUE ] ; then
_CURL_ARGS = " ${ _CURL_ARGS } --insecure "
_FETCH_ARGS = " ${ _FETCH_ARGS } --no-verify-peer "
_GPG_ARGS = " ${ _GPG_ARGS } --keyserver-options no-check-cert "
_WGET_ARGS = " ${ _WGET_ARGS } --no-check-certificate "
else
_GPG_ARGS = " ${ _GPG_ARGS } --keyserver-options ca-cert-file=/etc/ssl/certs/ca-certificates.crt "
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
2017-08-29 15:46:17 +03:00
export http_proxy = " ${ _HTTP_PROXY } "
export https_proxy = " ${ _HTTP_PROXY } "
# Using "deprecated" option here, but that appears the only way to make it work.
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=818802
# and https://bugs.launchpad.net/ubuntu/+source/gnupg2/+bug/1625848
_GPG_ARGS = " ${ _GPG_ARGS } ,http-proxy= ${ _HTTP_PROXY } "
2014-06-19 15:09:31 +02:00
fi
2014-09-01 21:21:29 +10:00
# Work around for 'Docker + salt-bootstrap failure' https://github.com/saltstack/salt-bootstrap/issues/394
2016-09-01 17:45:15 +03:00
if [ " ${ _DISABLE_SALT_CHECKS } " -eq $BS_FALSE ] && [ -f /tmp/disable_salt_checks ] ; then
2016-06-24 10:45:35 +03:00
# shellcheck disable=SC2016
echowarn 'Found file: /tmp/disable_salt_checks, setting _DISABLE_SALT_CHECKS=$BS_TRUE'
_DISABLE_SALT_CHECKS = $BS_TRUE
2014-09-01 21:21:29 +10:00
fi
2016-04-11 15:27:04 -07:00
# Because -a can only be installed into virtualenv
2016-09-01 17:45:15 +03:00
if [ " ${ _PIP_ALL } " -eq $BS_TRUE ] && [ " ${ _VIRTUALENV_DIR } " = "null" ] ; then
2016-04-11 15:27:04 -07:00
usage
# Could possibly set up a default virtualenv location when -a flag is passed
echoerror "Using -a requires -V because pip pkgs should be siloed from python system pkgs"
exit 1
fi
# Make sure virtualenv directory does not already exist
2016-09-01 17:45:15 +03:00
if [ -d " ${ _VIRTUALENV_DIR } " ] ; then
2016-04-11 15:27:04 -07:00
echoerror " The directory ${ _VIRTUALENV_DIR } for virtualenv already exists "
exit 1
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
2020-06-17 16:01:08 -06:00
curl $_CURL_ARGS -L -s -f -o " $1 " " $2 " >/dev/null 2>& 1 ||
2016-08-18 17:39:11 +03:00
wget $_WGET_ARGS -q -O " $1 " " $2 " >/dev/null 2>& 1 ||
fetch $_FETCH_ARGS -q -o " $1 " " $2 " >/dev/null 2>& 1 || # FreeBSD
fetch -q -o " $1 " " $2 " >/dev/null 2>& 1 || # Pre FreeBSD 10
2020-06-17 16:01:08 -06:00
ftp -o " $1 " " $2 " >/dev/null 2>& 1 || # OpenBSD
( echoerror " $2 failed to download to $1 " ; exit 1)
2014-01-22 23:14:38 +00:00
}
2016-03-30 19:32:48 +02:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __fetch_verify
# DESCRIPTION: Retrieves a URL, verifies its content and writes it to standard output
#----------------------------------------------------------------------------------------------------------------------
__fetch_verify( ) {
2016-04-11 20:24:36 -06:00
fetch_verify_url = " $1 "
fetch_verify_sum = " $2 "
fetch_verify_size = " $3 "
fetch_verify_tmpf = $( mktemp) && \
__fetch_url " $fetch_verify_tmpf " " $fetch_verify_url " && \
test " $( stat --format= %s " $fetch_verify_tmpf " ) " -eq " $fetch_verify_size " && \
test " $( md5sum " $fetch_verify_tmpf " | awk '{ print $1 }' ) " = " $fetch_verify_sum " && \
cat " $fetch_verify_tmpf " && \
2018-07-09 12:49:11 -04:00
if rm -f " $fetch_verify_tmpf " ; then
2016-04-11 20:24:36 -06:00
return 0
fi
echo " Failed verification of $fetch_verify_url "
return 1
2016-03-30 19:32:48 +02:00
}
2014-01-22 23:14:38 +00:00
2023-03-30 15:29:56 -07:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_url_exists
# DESCRIPTION: Checks if a URL exists
#----------------------------------------------------------------------------------------------------------------------
__check_url_exists( ) {
_URL = " $1 "
if curl --output /dev/null --silent --fail " ${ _URL } " ; then
return 0
else
return 1
fi
}
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 "
2015-10-28 15:39:12 +00:00
elif [ -z " $INPUT_VERSION " ] && [ -f "/etc/debian_version" ] ; then
2014-12-06 14:51:07 -08:00
INPUT_VERSION = " $( cat /etc/debian_version) "
fi
if [ -z " $NUMERIC_VERSION " ] ; then
2024-06-28 17:04:56 -06:00
if [ " $INPUT_VERSION " = "bullseye/sid" ] ; then
2020-12-04 17:15:02 -05:00
NUMERIC_VERSION = $( __parse_version_string "11.0" )
2024-02-08 09:28:56 -07:00
elif [ " $INPUT_VERSION " = "bookworm/sid" ] ; then
NUMERIC_VERSION = $( __parse_version_string "12.0" )
elif [ " $INPUT_VERSION " = "trixie/sid" ] ; then
NUMERIC_VERSION = $( __parse_version_string "13.0" )
2014-12-06 14:51:07 -08:00
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( ) {
2018-05-31 13:28:18 -04:00
# shellcheck disable=SC1117
2016-11-22 12:10:02 +02:00
echo " $* " | sed -e "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
2016-08-15 16:46:18 +03:00
# 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( ) {
2016-08-17 10:28:48 +03:00
echo " $* " | sed -e 's/\([^[:upper:][:punct:]]\)\([[:upper:]]\)/\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( ) {
2016-08-15 16:46:18 +03: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( ) {
2017-01-08 15:18:51 +01:00
KNOWN_RELEASE_FILES = $( echo " (arch|alpine|centos|debian|ubuntu|fedora|redhat|suse|\
2017-02-06 14:32:30 -05:00
mandrake| mandriva| gentoo| slackware| turbolinux| unitedlinux| void| lsb| system| \
2022-02-26 09:14:00 +00:00
oracle| os| almalinux| rocky) ( -| _) ( release| version) " | sed -E '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
2019-11-06 22:27:16 +00:00
for release_file in $( echo " ${ @ } " | sed -E 's:[[:space:]]:\n:g' | sort -f | uniq) ; do
2018-05-31 13:07:35 -04:00
match = $( echo " $release_file " | grep -E -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
2022-02-26 09:14:00 +00:00
max_prio = "redhat-release centos-release oracle-release fedora-release almalinux-release rocky-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
2018-05-31 13:28:18 -04: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
2018-05-31 13:28:18 -04: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
2019-11-06 22:27:16 +00:00
echo " ${ primary_release_files } ${ secondary_release_files } " | sed -E '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)
2018-07-09 12:49:11 -04:00
# shellcheck disable=SC2181
2013-02-20 12:46:02 +00:00
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"
2016-11-14 15:24:04 -07:00
elif [ " $( echo " $DISTRO_NAME " | grep ^CloudLinux) " != "" ] ; then
DISTRO_NAME = "Cloud Linux"
2016-08-15 16:46:18 +03:00
elif [ " $( echo " $DISTRO_NAME " | grep ^RedHat) " != "" ] ; then
# Let's convert 'CamelCased' to 'Camel Cased'
n = $( __camelcase_split " $DISTRO_NAME " )
# Skip setting DISTRO_NAME this time, splitting CamelCase has failed.
# See https://github.com/saltstack/salt-bootstrap/issues/918
[ " $n " = " $DISTRO_NAME " ] && DISTRO_NAME = "" || DISTRO_NAME = " $n "
2020-03-26 23:32:34 +00:00
elif [ " $( echo " ${ DISTRO_NAME } " | grep openSUSE ) " != "" ] ; then
# lsb_release -si returns "openSUSE Tumbleweed" on openSUSE tumbleweed
2013-04-23 10:38:02 +01:00
# lsb_release -si returns "openSUSE project" on openSUSE 12.3
2018-06-22 10:19:41 +07:00
# lsb_release -si returns "openSUSE" on openSUSE 15.n
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"
2019-08-14 10:28:53 -06:00
elif [ " ${ DISTRO_NAME } " = "AmazonAMI" ] || [ " ${ DISTRO_NAME } " = "Amazon" ] ; then
2014-06-29 00:31:15 +01:00
DISTRO_NAME = "Amazon Linux AMI"
2017-05-02 12:53:11 -07:00
elif [ " ${ DISTRO_NAME } " = "ManjaroLinux" ] ; then
DISTRO_NAME = "Arch Linux"
2014-08-29 20:24:40 +01:00
elif [ " ${ DISTRO_NAME } " = "Arch" ] ; then
DISTRO_NAME = "Arch Linux"
return
2022-02-26 09:14:00 +00:00
elif [ " ${ DISTRO_NAME } " = "Rocky" ] ; then
DISTRO_NAME = "Rocky Linux"
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
2024-02-02 15:32:40 -07:00
# shellcheck disable=SC2035,SC2086,SC2269
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
[ ! -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 )
2018-05-31 13:07:35 -04:00
if [ " $( grep -E 'CentOS' /etc/${ rsource } ) " != "" ] ; then
2013-02-12 22:36:05 +00:00
n = "CentOS"
2018-05-31 13:07:35 -04:00
elif [ " $( grep -E 'Scientific' /etc/${ rsource } ) " != "" ] ; then
2014-03-19 19:10:27 +00:00
n = "Scientific Linux"
2018-05-31 13:07:35 -04:00
elif [ " $( grep -E '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" ; ;
2017-01-08 15:18:51 +01:00
alpine ) n = "Alpine Linux" ; ;
2012-10-18 22:27:38 +01:00
centos ) n = "CentOS" ; ;
debian ) n = "Debian" ; ;
ubuntu ) n = "Ubuntu" ; ;
fedora ) n = "Fedora" ; ;
2018-06-08 16:42:15 +01:00
suse| opensuse ) n = "SUSE" ; ;
2012-10-18 22:27:38 +01:00
mandrake*| mandriva ) n = "Mandriva" ; ;
gentoo ) n = "Gentoo" ; ;
slackware ) n = "Slackware" ; ;
turbolinux ) n = "TurboLinux" ; ;
unitedlinux ) n = "UnitedLinux" ; ;
2017-02-06 14:32:30 -05:00
void ) n = "VoidLinux" ; ;
2014-03-15 08:57:54 +00:00
oracle ) n = "Oracle Linux" ; ;
2022-02-26 09:11:49 +00:00
almalinux ) n = "AlmaLinux" ; ;
2022-02-26 09:14:00 +00:00
rocky ) n = "Rocky 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
2017-01-08 15:18:51 +01:00
alpine )
n = "Alpine Linux"
v = " ${ rv } "
; ;
2014-09-25 16:35:39 +01:00
amzn )
2016-03-30 11:34:23 +03:00
# Amazon AMI's after 2014.09 match here
2014-09-25 16:35:39 +01:00
n = "Amazon Linux AMI"
; ;
2013-03-23 10:58:19 +00:00
arch )
n = "Arch Linux"
v = "" # Arch Linux does not provide a version.
; ;
2016-11-15 16:27:48 -07:00
cloudlinux )
n = "Cloud Linux"
; ;
2013-03-23 10:58:19 +00:00
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
; ;
2018-07-10 17:03:27 +01:00
sles )
2016-02-04 01:35:47 -07:00
n = "SUSE"
v = " ${ rv } "
; ;
2020-03-26 23:32:34 +00:00
opensuse-* )
2018-07-10 17:03:27 +01:00
n = "opensuse"
v = " ${ rv } "
; ;
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
2017-04-28 12:34:58 +03:00
2017-04-17 17:37:38 -04:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2017-08-08 12:50:14 -04:00
# NAME: __install_python()
# DESCRIPTION: Install a different version of python on a host. Currently this has only been tested on CentOS 6 and
# is considered experimental.
2017-04-17 17:37:38 -04:00
#----------------------------------------------------------------------------------------------------------------------
2017-08-08 12:50:14 -04:00
__install_python( ) {
2017-04-19 13:40:25 -04:00
if [ " $_PY_EXE " = "" ] ; then
2017-04-17 17:37:38 -04:00
echoerror "Must specify -x <pythonversion> with -y to install a specific python version"
exit 1
fi
2018-05-31 10:13:12 -04:00
__PACKAGES = " $_PY_PKG_VER "
2017-04-17 17:37:38 -04:00
2024-06-28 17:04:56 -06:00
if [ ${ _DISABLE_REPOS } -eq ${ BS_FALSE } ] ; then
2017-04-19 14:38:37 -04:00
echoinfo "Attempting to install a repo to help provide a separate python package"
echoinfo " $DISTRO_NAME_L "
case " $DISTRO_NAME_L " in
"red_hat" | "centos" )
2020-05-25 17:36:16 -03:00
__PYTHON_REPO_URL = " https://repo.ius.io/ius-release-el ${ DISTRO_MAJOR_VERSION } .rpm "
2017-04-19 14:38:37 -04:00
; ;
*)
echoerror " Installing a repo to provide a python package is only supported on Redhat/CentOS.
2017-08-08 12:50:14 -04:00
If a repo is already available, please try running script with -r."
2017-04-19 14:38:37 -04:00
exit 1
; ;
esac
2017-04-18 10:53:18 -04:00
echoinfo "Installing IUS repo"
2017-04-19 13:55:09 -04:00
__yum_install_noinput " ${ __PYTHON_REPO_URL } " || return 1
2017-04-17 17:37:38 -04:00
fi
2017-04-19 13:40:25 -04:00
echoinfo " Installing ${ __PACKAGES } "
2017-04-19 13:55:09 -04:00
__yum_install_noinput " ${ __PACKAGES } " || return 1
2017-04-17 17:37:38 -04:00
}
2012-10-18 22:18:07 +01:00
2012-10-17 14:02:09 +01:00
2019-08-28 13:15:23 -07:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __gather_osx_system_info
# DESCRIPTION: Discover MacOS X
#----------------------------------------------------------------------------------------------------------------------
__gather_osx_system_info( ) {
DISTRO_NAME = "MacOSX"
DISTRO_VERSION = $( sw_vers -productVersion)
}
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
; ;
2019-08-28 13:15:23 -07:00
darwin )
__gather_osx_system_info
; ;
2012-10-18 22:18:07 +01:00
* )
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
2017-04-28 12:34:58 +03: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( ) {
2024-02-08 09:28:56 -07:00
UBUNTU_DERIVATIVES = "(trisquel|linuxmint|elementary_os|pop)"
2013-07-26 21:24:09 -04:00
# Mappings
2024-02-08 09:28:56 -07:00
trisquel_10_ubuntu_base = "20.04"
trisquel_11_ubuntu_base = "22.04"
2024-06-04 17:06:07 -06:00
trisquel_12_ubuntu_base = "24.04"
2020-05-05 09:42:11 -06:00
neon_20_ubuntu_base = "20.04"
2023-01-16 09:05:15 +01:00
neon_22_ubuntu_base = "22.04"
2024-06-04 17:06:07 -06:00
neon_24_ubuntu_base = "24.04"
2024-02-08 09:28:56 -07:00
linuxmint_20_ubuntu_base = "20.04"
2024-06-04 17:06:07 -06:00
linuxmint_21_ubuntu_base = "22.04"
linuxmint_22_ubuntu_base = "24.04"
2024-02-08 09:28:56 -07:00
elementary_os_06_ubuntu_base = "20.04"
2024-06-04 17:06:07 -06:00
elementary_os_07_ubuntu_base = "22.04"
elementary_os_08_ubuntu_base = "24.04"
2024-02-08 09:28:56 -07:00
pop_20_ubuntu_base = "22.04"
2022-12-10 13:27:23 -06:00
pop_22_ubuntu_base = "22.04"
2024-06-04 17:06:07 -06:00
pop_24_ubuntu_base = "24.04"
2013-07-26 21:24:09 -04:00
# Translate Ubuntu derivatives to their base Ubuntu version
2018-05-31 13:07:35 -04:00
match = $( echo " $DISTRO_NAME_L " | grep -E ${ 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
}
2017-04-28 12:34:58 +03:00
2017-05-31 09:04:32 -06:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_dpkg_architecture
# DESCRIPTION: Determine the primary architecture for packages to install on Debian and derivatives
# and issue all necessary error messages.
#----------------------------------------------------------------------------------------------------------------------
__check_dpkg_architecture( ) {
if __check_command_exists dpkg; then
DPKG_ARCHITECTURE = " $( dpkg --print-architecture) "
else
echoerror "dpkg: command not found."
return 1
fi
__REPO_ARCH = " $DPKG_ARCHITECTURE "
2024-06-28 17:04:56 -06:00
## DGM __REPO_ARCH_DEB='deb [signed-by=/etc/apt/keyrings/salt-archive-keyring-2023.gpg]'
__REPO_ARCH_DEB = 'deb [signed-by=/usr/share/keyrings/salt-archive-keyring.gpg]'
2017-05-31 09:16:40 -06:00
__return_code = 0
2017-05-31 09:04:32 -06:00
case $DPKG_ARCHITECTURE in
"i386" )
2024-02-08 09:28:56 -07:00
error_msg = " $_REPO_URL likely doesn't have required 32-bit packages for $DISTRO_NAME $DISTRO_MAJOR_VERSION . "
2017-05-31 09:04:32 -06:00
# amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location
2024-02-08 09:28:56 -07:00
__return_code = 1
2017-05-31 09:04:32 -06:00
; ;
"amd64" )
error_msg = ""
; ;
2018-06-24 19:41:20 +02:00
"arm64" )
2024-06-28 17:04:56 -06:00
# Saltstack official repository has full arm64 support since 3006
__REPO_ARCH = "arm64"
__REPO_ARCH_DEB = " deb [signed-by=/usr/share/keyrings/salt-archive-keyring.gpg arch= $__REPO_ARCH ] "
2018-06-24 19:41:20 +02:00
; ;
2017-05-31 09:04:32 -06:00
"armhf" )
2024-06-28 17:04:56 -06:00
error_msg = " $_REPO_URL doesn't have packages for your system architecture: $DPKG_ARCHITECTURE . "
__return_code = 1
2017-05-31 09:04:32 -06:00
; ;
*)
error_msg = " $_REPO_URL doesn't have packages for your system architecture: $DPKG_ARCHITECTURE . "
2017-05-31 09:16:40 -06:00
__return_code = 1
2017-05-31 09:04:32 -06:00
; ;
esac
2018-08-04 03:54:00 +02:00
if [ " ${ warn_msg :- } " != "" ] ; then
2018-06-24 19:41:20 +02:00
# AArch64: Do not fail at this point, but warn the user about experimental support
# See https://github.com/saltstack/salt-bootstrap/issues/1240
echowarn " ${ warn_msg } "
fi
2017-05-31 09:04:32 -06:00
if [ " ${ error_msg } " != "" ] ; then
echoerror " ${ error_msg } "
if [ " $ITYPE " != "git" ] ; then
2024-02-08 09:28:56 -07:00
echoerror " You can try git installation mode, i.e.: sh ${ __ScriptName } git v3006.6. "
2017-05-31 09:04:32 -06:00
echoerror "It may be necessary to use git installation mode with pip and disable the SaltStack apt repository."
echoerror "For example:"
2024-02-08 09:28:56 -07:00
echoerror " sh ${ __ScriptName } -r -P git v3006.6 "
2017-05-31 09:04:32 -06:00
fi
fi
2017-06-02 09:40:24 -06:00
if [ " ${ __return_code } " -eq 0 ] ; then
return 0
else
return 1
fi
2017-05-31 09:04:32 -06:00
}
2015-10-20 16:34:27 -06:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __ubuntu_codename_translation
# DESCRIPTION: Map Ubuntu major versions to their corresponding codenames
#----------------------------------------------------------------------------------------------------------------------
# shellcheck disable=SC2034
__ubuntu_codename_translation( ) {
case $DISTRO_MINOR_VERSION in
"04" )
_april = "yes"
; ;
"10" )
_april = ""
; ;
*)
_april = "yes"
; ;
esac
case $DISTRO_MAJOR_VERSION in
"12" )
DISTRO_CODENAME = "precise"
; ;
"14" )
DISTRO_CODENAME = "trusty"
; ;
2016-05-16 09:48:08 -07:00
"16" )
2018-01-22 13:15:28 -05:00
DISTRO_CODENAME = "xenial"
2016-05-16 09:48:08 -07:00
; ;
2018-05-10 15:56:48 -04:00
"18" )
DISTRO_CODENAME = "bionic"
; ;
2020-02-03 16:57:11 -07:00
"20" )
DISTRO_CODENAME = "focal"
; ;
2021-05-07 18:32:42 +02:00
"21" )
DISTRO_CODENAME = "hirsute"
; ;
2022-04-23 10:05:45 +02:00
"22" )
DISTRO_CODENAME = "jammy"
; ;
2024-02-08 09:28:56 -07:00
"23" )
DISTRO_CODENAME = "lunar"
; ;
"24" )
DISTRO_CODENAME = "noble"
; ;
2015-10-20 16:34:27 -06:00
*)
2024-06-26 14:14:24 -06:00
DISTRO_CODENAME = "noble"
2015-10-20 16:34:27 -06:00
; ;
esac
}
2017-04-28 12:34:58 +03:00
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
2020-06-09 11:34:02 +01:00
DEBIAN_DERIVATIVES = "(cumulus|devuan|kali|linuxmint|raspbian|bunsenlabs|turnkey)"
2014-05-22 11:06:37 +03:00
# Mappings
2024-06-04 17:06:07 -06:00
cumulus_5_debian_base = "11.0"
cumulus_6_debian_base = "12.0"
devuan_4_debian_base = "11.0"
devuan_5_debian_base = "12.0"
2017-04-28 12:34:58 +03:00
kali_1_debian_base = "7.0"
2022-01-07 10:53:57 +01:00
kali_2021_debian_base = "10.0"
2024-06-04 17:06:07 -06:00
linuxmint_4_debian_base = "11.0"
linuxmint_5_debian_base = "12.0"
2021-11-14 12:10:58 +01:00
raspbian_11_debian_base = "11.0"
2024-02-08 09:28:56 -07:00
raspbian_12_debian_base = "12.0"
2018-12-28 23:11:08 -05:00
bunsenlabs_9_debian_base = "9.0"
2024-06-04 17:06:07 -06:00
bunsenlabs_11_debian_base = "11.0"
bunsenlabs_12_debian_base = "12.0"
turnkey_11_debian_base = "11.0"
turnkey_12_debian_base = "12.0"
2014-05-22 11:06:37 +03:00
# Translate Debian derivatives to their base Debian version
2018-05-31 13:07:35 -04:00
match = $( echo " $DISTRO_NAME_L " | grep -E ${ 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
2020-06-09 11:34:02 +01:00
cumulus*)
2017-04-28 12:34:58 +03:00
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
_debian_derivative = "cumulus"
; ;
2017-11-11 18:16:52 +01:00
devuan)
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
_debian_derivative = "devuan"
; ;
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"
; ;
2017-04-28 12:34:58 +03:00
raspbian)
2016-10-04 11:19:30 -04:00
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
2017-04-28 12:34:58 +03:00
_debian_derivative = "raspbian"
2016-10-04 11:19:30 -04:00
; ;
2018-12-28 23:11:08 -05:00
bunsenlabs)
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
_debian_derivative = "bunsenlabs"
; ;
2019-02-02 02:17:58 +00:00
turnkey)
_major = $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' )
2019-02-05 13:00:02 +00:00
_debian_derivative = "turnkey"
2019-02-02 02:17:58 +00:00
; ;
2014-05-25 01:27:47 +01:00
esac
2017-09-08 09:41:14 +03:00
_debian_version = $( eval echo " \$ ${ _debian_derivative } _ ${ _major } _debian_base " 2>/dev/null)
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 "
2017-11-11 18:19:53 +01:00
DISTRO_MAJOR_VERSION = " $( echo " $DISTRO_VERSION " | sed 's/^\([0-9]*\).*/\1/g' ) "
2014-05-22 11:06:37 +03:00
fi
fi
}
2016-04-05 15:00:13 -06:00
2017-06-12 16:45:43 -06:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __debian_codename_translation
# DESCRIPTION: Map Debian major versions to their corresponding code names
#----------------------------------------------------------------------------------------------------------------------
# shellcheck disable=SC2034
__debian_codename_translation( ) {
case $DISTRO_MAJOR_VERSION in
2017-07-05 15:32:08 -06:00
"9" )
DISTRO_CODENAME = "stretch"
; ;
2017-07-13 13:48:07 -06:00
"10" )
DISTRO_CODENAME = "buster"
; ;
2020-12-04 17:15:02 -05:00
"11" )
DISTRO_CODENAME = "bullseye"
; ;
2023-09-08 09:09:50 +10:00
"12" )
DISTRO_CODENAME = "bookworm"
; ;
2017-06-12 16:45:43 -06:00
*)
2024-02-08 09:28:56 -07:00
DISTRO_CODENAME = "bookworm"
2017-06-12 16:45:43 -06:00
; ;
esac
}
2017-05-18 11:53:46 +03:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __check_end_of_life_versions
# DESCRIPTION: Check for end of life distribution versions
#----------------------------------------------------------------------------------------------------------------------
__check_end_of_life_versions( ) {
case " ${ DISTRO_NAME_L } " in
debian)
2024-06-26 14:14:24 -06:00
# Debian versions below 11 are not supported
2024-02-05 16:56:12 -07:00
## DGM if [ "$DISTRO_MAJOR_VERSION" -lt 9 ]; then
2024-06-28 17:04:56 -06:00
if [ " $DISTRO_MAJOR_VERSION " -lt 11 ] ; then
2017-05-18 11:53:46 +03: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
; ;
ubuntu)
# Ubuntu versions not supported
#
2024-02-08 09:28:56 -07:00
# < 20.04
2022-01-21 17:40:27 -05:00
# = 20.10
2024-02-08 09:28:56 -07:00
# = 21.04, 21.10
# = 22.10
# = 23.04, 23.10
2024-02-05 16:56:12 -07:00
if [ " $DISTRO_MAJOR_VERSION " -lt 20 ] || \
{ [ " $DISTRO_MAJOR_VERSION " -eq 20 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ; } || \
{ [ " $DISTRO_MAJOR_VERSION " -eq 21 ] && [ " $DISTRO_MINOR_VERSION " -eq 04 ] ; } || \
{ [ " $DISTRO_MAJOR_VERSION " -eq 21 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ; } || \
{ [ " $DISTRO_MAJOR_VERSION " -eq 22 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ; } || \
{ [ " $DISTRO_MAJOR_VERSION " -eq 23 ] && [ " $DISTRO_MINOR_VERSION " -eq 04 ] ; } || \
{ [ " $DISTRO_MAJOR_VERSION " -eq 23 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ; } ; then
2017-05-18 11:53:46 +03: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
fi
; ;
opensuse)
# openSUSE versions not supported
#
2017-08-18 10:31:58 +03:00
# <= 13.X
2018-07-11 11:11:58 -04:00
# <= 42.2
if [ " $DISTRO_MAJOR_VERSION " -lt 15 ] || \
{ [ " $DISTRO_MAJOR_VERSION " -eq 42 ] && [ " $DISTRO_MINOR_VERSION " -le 2 ] ; } ; then
2017-05-18 11:53:46 +03: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
; ;
suse)
# SuSE versions not supported
#
2017-09-19 11:14:56 +03:00
# < 11 SP4
2017-09-21 16:53:34 +03:00
# < 12 SP2
2020-02-14 18:25:47 +01:00
# < 15 SP1
2020-02-14 18:47:52 +01:00
SUSE_PATCHLEVEL = $( awk -F'=' '/VERSION_ID/ { print $2 }' /etc/os-release | grep -oP "\.\K\w+" )
2017-05-18 11:53:46 +03:00
if [ " ${ SUSE_PATCHLEVEL } " = "" ] ; then
SUSE_PATCHLEVEL = "00"
fi
2017-09-21 16:53:34 +03:00
if [ " $DISTRO_MAJOR_VERSION " -lt 11 ] || \
2018-07-09 11:13:56 -04:00
{ [ " $DISTRO_MAJOR_VERSION " -eq 11 ] && [ " $SUSE_PATCHLEVEL " -lt 04 ] ; } || \
2020-02-14 18:25:47 +01:00
{ [ " $DISTRO_MAJOR_VERSION " -eq 15 ] && [ " $SUSE_PATCHLEVEL " -lt 01 ] ; } || \
2018-07-09 11:13:56 -04:00
{ [ " $DISTRO_MAJOR_VERSION " -eq 12 ] && [ " $SUSE_PATCHLEVEL " -lt 02 ] ; } ; then
2020-02-14 18:25:47 +01:00
echoerror "Versions lower than SuSE 11 SP4, 12 SP2 or 15 SP1 are not supported."
2017-05-18 11:53:46 +03:00
echoerror "Please consider upgrading to the next stable"
2017-09-22 11:16:43 +03:00
echoerror " https://www.suse.com/lifecycle/"
2017-05-18 11:53:46 +03:00
exit 1
fi
; ;
fedora)
2024-02-08 09:28:56 -07:00
# Fedora lower than 38 are no longer supported
2024-06-26 14:14:24 -06:00
if [ " $DISTRO_MAJOR_VERSION " -lt 39 ] ; then
2017-05-18 11:53:46 +03: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
; ;
centos)
2024-06-26 14:14:24 -06:00
# CentOS versions lower than 8 are no longer supported
if [ " $DISTRO_MAJOR_VERSION " -lt 8 ] ; then
2017-05-18 11:53:46 +03: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
; ;
red_hat*linux)
2024-06-26 14:14:24 -06:00
# Red Hat (Enterprise) Linux versions lower than 8 are no longer supported
if [ " $DISTRO_MAJOR_VERSION " -lt 8 ] ; then
2017-05-18 11:53:46 +03: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
; ;
oracle*linux)
2024-06-26 14:14:24 -06:00
# Oracle Linux versions lower than 8 are no longer supported
if [ " $DISTRO_MAJOR_VERSION " -lt 8 ] ; then
2017-05-18 11:53:46 +03:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " http://www.oracle.com/us/support/library/elsp-lifetime-069338.pdf"
exit 1
fi
; ;
scientific*linux)
2024-06-26 14:14:24 -06:00
# Scientific Linux versions lower than 8 are no longer supported
if [ " $DISTRO_MAJOR_VERSION " -lt 8 ] ; then
2017-05-18 11:53:46 +03:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://www.scientificlinux.org/downloads/sl-versions/"
exit 1
fi
; ;
cloud*linux)
2024-06-26 14:14:24 -06:00
# Cloud Linux versions lower than 8 are no longer supported
if [ " $DISTRO_MAJOR_VERSION " -lt 8 ] ; then
2017-05-18 11:53:46 +03:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://docs.cloudlinux.com/index.html?cloudlinux_life-cycle.html"
exit 1
fi
; ;
amazon*linux*ami)
2021-07-23 19:31:17 +00:00
# Amazon Linux versions 2018.XX and lower no longer supported
2018-10-30 06:48:22 +00:00
# Except for Amazon Linux 2, which reset the major version counter
2021-07-23 19:31:17 +00:00
if [ " $DISTRO_MAJOR_VERSION " -le 2018 ] && [ " $DISTRO_MAJOR_VERSION " -gt 10 ] ; then
2017-05-18 11:53:46 +03:00
echoerror "End of life distributions are not supported."
echoerror "Please consider upgrading to the next stable. See:"
echoerror " https://aws.amazon.com/amazon-linux-ami/"
exit 1
fi
; ;
*)
; ;
esac
}
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
2017-05-18 11:53:46 +03:00
# Simplify distro name naming on functions
2020-03-26 23:32:34 +00:00
DISTRO_NAME_L = $( echo " $DISTRO_NAME " | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -Ee 's/([[:space:]])+/_/g' | sed -Ee 's/tumbleweed//' )
2017-05-18 11:53:46 +03:00
# Simplify version naming on functions
if [ " $DISTRO_VERSION " = "" ] || [ ${ _SIMPLIFY_VERSION } -eq $BS_FALSE ] ; then
DISTRO_MAJOR_VERSION = ""
DISTRO_MINOR_VERSION = ""
PREFIXED_DISTRO_MAJOR_VERSION = ""
PREFIXED_DISTRO_MINOR_VERSION = ""
else
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' )
PREFIXED_DISTRO_MAJOR_VERSION = " _ ${ DISTRO_MAJOR_VERSION } "
if [ " ${ PREFIXED_DISTRO_MAJOR_VERSION } " = "_" ] ; then
PREFIXED_DISTRO_MAJOR_VERSION = ""
fi
PREFIXED_DISTRO_MINOR_VERSION = " _ ${ DISTRO_MINOR_VERSION } "
if [ " ${ PREFIXED_DISTRO_MINOR_VERSION } " = "_" ] ; then
PREFIXED_DISTRO_MINOR_VERSION = ""
fi
fi
# For Ubuntu derivatives, pretend to be their Ubuntu base version
__ubuntu_derivatives_translation
# For Debian derivates, pretend to be their Debian base version
__debian_derivatives_translation
# Fail soon for end of life versions
__check_end_of_life_versions
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
2024-02-02 17:57:31 -07:00
echoinfo "Installing salt-cloud and required python3-libcloud package"
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
2017-06-13 12:26:01 -07:00
if [ " ${ DISTRO_NAME_L } " = "ubuntu" ] ; then
# For ubuntu versions, obtain the codename from the release version
__ubuntu_codename_translation
elif [ " ${ DISTRO_NAME_L } " = "debian" ] ; then
# For debian versions, obtain the codename from the release version
__debian_codename_translation
fi
2017-06-12 16:45:43 -06:00
2022-02-26 09:14:00 +00:00
if [ " $( echo " ${ DISTRO_NAME_L } " | grep -E '(debian|ubuntu|centos|gentoo|red_hat|oracle|scientific|amazon|fedora|macosx|almalinux|rocky)' ) " = "" ] && [ " $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
2022-02-26 09:14:00 +00:00
if [ " $( echo " ${ DISTRO_NAME_L } " | grep -E '(centos|red_hat|amazon|oracle|almalinux|rocky)' ) " = "" ] ; 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
2016-04-11 15:27:04 -07:00
# Only Ubuntu has support for installing to virtualenvs
2018-07-09 11:13:56 -04:00
if [ " ${ DISTRO_NAME_L } " != "ubuntu" ] && [ " $_VIRTUALENV_DIR " != "null" ] ; then
2016-04-11 15:27:04 -07:00
echoerror " ${ DISTRO_NAME } does not have -V support "
exit 1
fi
# Only Ubuntu has support for pip installing all packages
2024-06-28 17:04:56 -06:00
if [ " ${ DISTRO_NAME_L } " != "ubuntu" ] && [ $_PIP_ALL -eq $BS_TRUE ] ; then
2016-04-11 15:27:04 -07:00
echoerror " ${ DISTRO_NAME } does not have -a support "
exit 1
fi
2016-08-18 17:39:11 +03:00
2020-01-28 19:20:03 +00:00
if [ " $ITYPE " = "git" ] ; then
if [ " ${ GIT_REV } " = "master" ] ; then
__TAG_REGEX_MATCH = "MATCH"
else
case ${ OS_NAME_L } in
2024-06-20 14:36:36 -06:00
darwin )
2020-01-28 19:20:03 +00:00
__NEW_VS_TAG_REGEX_MATCH = $( echo " ${ GIT_REV } " | sed -E 's/^(v?3[0-9]{3}(\.[0-9]{1,2})?).*$/MATCH/' )
if [ " $__NEW_VS_TAG_REGEX_MATCH " = "MATCH" ] ; then
__TAG_REGEX_MATCH = " ${ __NEW_VS_TAG_REGEX_MATCH } "
echodebug " Post Neon Tag Regex Match On: ${ GIT_REV } "
else
__TAG_REGEX_MATCH = $( echo " ${ GIT_REV } " | sed -E 's/^(v?[0-9]{1,4}\.[0-9]{1,2})(\.[0-9]{1,2})?.*$/MATCH/' )
echodebug " Pre Neon Tag Regex Match On: ${ GIT_REV } "
fi
; ;
* )
__NEW_VS_TAG_REGEX_MATCH = $( echo " ${ GIT_REV } " | sed 's/^.*\(v\?3[[:digit:]]\{3\}\(\.[[:digit:]]\{1,2\}\)\?\).*$/MATCH/' )
if [ " $__NEW_VS_TAG_REGEX_MATCH " = "MATCH" ] ; then
__TAG_REGEX_MATCH = " ${ __NEW_VS_TAG_REGEX_MATCH } "
echodebug " Post Neon Tag Regex Match On: ${ GIT_REV } "
else
__TAG_REGEX_MATCH = $( echo " ${ GIT_REV } " | sed 's/^.*\(v\?[[:digit:]]\{1,4\}\.[[:digit:]]\{1,2\}\)\(\.[[:digit:]]\{1,2\}\)\?.*$/MATCH/' )
echodebug " Pre Neon Tag Regex Match On: ${ GIT_REV } "
fi
; ;
esac
fi
2024-02-08 09:28:56 -07:00
echo
echowarn "Post Neon git based installations will always install salt"
echowarn "and its dependencies using pip which will be upgraded to"
echowarn " at least v ${ _MINIMUM_PIP_VERSION } , and, in case the setuptools version is also "
echowarn " too old, it will be upgraded to at least v ${ _MINIMUM_SETUPTOOLS_VERSION } "
echo
echowarn "You have 10 seconds to cancel and stop the bootstrap process..."
echo
sleep 10
_PIP_ALLOWED = $BS_TRUE
2020-01-28 19:20:03 +00:00
fi
2016-12-17 21:42:49 +01:00
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
2017-12-28 10:04:42 -05:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __wait_for_apt
# DESCRIPTION: Check if any apt, apt-get, aptitude, or dpkg processes are running before
# calling these again. This is useful when these process calls are part of
# a boot process, such as on AWS AMIs. This func will wait until the boot
# process is finished so the script doesn't exit on a locked proc.
#----------------------------------------------------------------------------------------------------------------------
__wait_for_apt( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2024-07-01 11:48:29 -06:00
2017-12-28 10:04:42 -05:00
# Timeout set at 15 minutes
WAIT_TIMEOUT = 900
2024-06-27 11:34:44 -06:00
## DGM see if sync'ing the clocks helps
2024-07-02 13:57:12 -06:00
if [ -f /usr/sbin/hwclock ] ; then
/usr/sbin/hwclock -s
fi
2024-06-27 11:34:44 -06:00
2018-11-02 09:20:36 -04:00
# Run our passed in apt command
2019-04-05 08:57:47 -04:00
" ${ @ } " 2>" $APT_ERR "
2018-11-02 09:20:36 -04:00
APT_RETURN = $?
2017-12-28 10:04:42 -05:00
2024-06-27 11:34:44 -06:00
echoerror" DGM __wait_for_apt APT_ERR: $APT_ERR "
2019-03-20 14:19:18 -04:00
# Make sure we're not waiting on a lock
2024-02-02 15:32:40 -07:00
while [ " $APT_RETURN " -ne 0 ] && grep -q '^E: Could not get lock' " $APT_ERR " ; do
2019-05-15 14:21:23 +01:00
echoinfo " Aware of the lock. Patiently waiting $WAIT_TIMEOUT more seconds... "
sleep 1
WAIT_TIMEOUT = $(( WAIT_TIMEOUT - 1 ))
if [ " $WAIT_TIMEOUT " -eq 0 ] ; then
echoerror "Apt, apt-get, aptitude, or dpkg process is taking too long."
echoerror "Bootstrap script cannot proceed. Aborting."
return 1
else
" ${ @ } " 2>" $APT_ERR "
APT_RETURN = $?
fi
2017-12-28 10:04:42 -05:00
done
2024-06-28 17:04:56 -06:00
return $APT_RETURN
2017-12-28 10:04:42 -05:00
}
2016-08-18 17:39:11 +03:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __apt_get_install_noinput
# DESCRIPTION: (DRY) apt-get install with noinput options
# PARAMETERS: packages
#----------------------------------------------------------------------------------------------------------------------
__apt_get_install_noinput( ) {
2024-06-27 11:34:44 -06:00
## DGM __wait_for_apt apt-get install -y -o DPkg::Options::=--force-confold "${@}"; return $?
__wait_for_apt apt-get install -V -y -o DPkg::Options::= --force-confold " ${ @ } " ; return $?
2016-08-18 17:39:11 +03:00
} # ---------- end of function __apt_get_install_noinput ----------
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __apt_get_upgrade_noinput
# DESCRIPTION: (DRY) apt-get upgrade with noinput options
#----------------------------------------------------------------------------------------------------------------------
__apt_get_upgrade_noinput( ) {
2024-06-27 11:34:44 -06:00
## DGM __wait_for_apt apt-get upgrade -y -o DPkg::Options::=--force-confold; return $?
__wait_for_apt apt-get upgrade -V -y -o DPkg::Options::= --force-confold; return $?
2016-08-18 17:39:11 +03:00
} # ---------- end of function __apt_get_upgrade_noinput ----------
2019-05-13 08:26:12 +02:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __temp_gpg_pub
# DESCRIPTION: Create a temporary file for downloading a GPG public key.
#----------------------------------------------------------------------------------------------------------------------
__temp_gpg_pub( ) {
if __check_command_exists mktemp; then
tempfile = " $( mktemp /tmp/salt-gpg-XXXXXXXX.pub 2>/dev/null) "
if [ -z " $tempfile " ] ; then
echoerror "Failed to create temporary file in /tmp"
return 1
fi
else
tempfile = " /tmp/salt-gpg- $$ .pub "
fi
2024-06-28 17:04:56 -06:00
echo $tempfile
2019-05-13 08:26:12 +02:00
} # ----------- end of function __temp_gpg_pub -----------
2016-08-18 17:39:11 +03:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __apt_key_fetch
# DESCRIPTION: Download and import GPG public key for "apt-secure"
# PARAMETERS: url
#----------------------------------------------------------------------------------------------------------------------
__apt_key_fetch( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2016-08-18 17:39:11 +03:00
url = $1
2019-05-13 10:45:33 +02:00
tempfile = " $( __temp_gpg_pub) "
2019-05-13 08:26:12 +02:00
__fetch_url " $tempfile " " $url " || return 1
2024-06-27 15:02:27 -06:00
## DGM mkdir -p /etc/apt/keyrings || return 1
## DGM cp -f "$tempfile" /etc/apt/keyrings/salt-archive-keyring-2023.gpg && chmod 644 /etc/apt/keyrings/salt-archive-keyring-2023.gpg || return 1
cp -f " $tempfile " /usr/share/keyrings/salt-archive-keyring.gpg && chmod 644 /usr/share/keyrings/salt-archive-keyring.gpg || return 1
2019-05-13 08:26:12 +02:00
rm -f " $tempfile "
return 0
2016-08-19 11:14:58 +03:00
} # ---------- end of function __apt_key_fetch ----------
2016-08-18 17:39:11 +03:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __rpm_import_gpg
# DESCRIPTION: Download and import GPG public key to rpm database
# PARAMETERS: url
#----------------------------------------------------------------------------------------------------------------------
__rpm_import_gpg( ) {
url = $1
2019-05-13 10:45:33 +02:00
tempfile = " $( __temp_gpg_pub) "
2016-08-18 17:39:11 +03:00
__fetch_url " $tempfile " " $url " || return 1
2020-05-27 18:43:57 +01:00
# At least on CentOS 8, a missing newline at the end causes:
# error: /tmp/salt-gpg-n1gKUb1u.pub: key 1 not an armored public key.
# shellcheck disable=SC1003,SC2086
sed -i -e '$a\' $tempfile
2016-08-18 17:39:11 +03:00
rpm --import " $tempfile " || return 1
rm -f " $tempfile "
return 0
} # ---------- end of function __rpm_import_gpg ----------
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __yum_install_noinput
2016-08-19 11:14:58 +03:00
# DESCRIPTION: (DRY) yum install with noinput options
2016-08-18 17:39:11 +03:00
#----------------------------------------------------------------------------------------------------------------------
__yum_install_noinput( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2016-08-18 17:39:11 +03:00
if [ " $DISTRO_NAME_L " = "oracle_linux" ] ; then
# We need to install one package at a time because --enablerepo=X disables ALL OTHER REPOS!!!!
for package in " ${ @ } " ; do
2022-12-06 08:44:39 -08:00
yum -y install " ${ package } " || yum -y install " ${ package } " || return $?
2016-08-18 17:39:11 +03:00
done
else
2022-12-06 08:44:39 -08:00
yum -y install " ${ @ } " || return $?
2016-08-18 17:39:11 +03:00
fi
2016-08-19 11:14:58 +03:00
} # ---------- end of function __yum_install_noinput ----------
2016-08-18 17:39:11 +03:00
2019-12-17 09:31:23 -08:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __dnf_install_noinput
# DESCRIPTION: (DRY) dnf install with noinput options
#----------------------------------------------------------------------------------------------------------------------
__dnf_install_noinput( ) {
2024-07-01 11:48:29 -06:00
## DGM Debugging
set -v
set -x
2019-12-17 09:31:23 -08:00
dnf -y install " ${ @ } " || return $?
} # ---------- end of function __dnf_install_noinput ----------
2016-08-18 17:39:11 +03:00
2023-04-21 12:45:35 -07:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __tdnf_install_noinput
2023-08-10 08:30:49 -07:00
# DESCRIPTION: (DRY) tdnf install with noinput options
2023-04-21 12:45:35 -07:00
#----------------------------------------------------------------------------------------------------------------------
__tdnf_install_noinput( ) {
2024-07-01 11:48:29 -06:00
## DGM Debugging
set -v
set -x
2023-04-21 12:45:35 -07:00
tdnf -y install " ${ @ } " || return $?
} # ---------- end of function __tdnf_install_noinput ----------
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 }' ) "
2016-10-27 11:59:45 +09:00
# Turn off SSL verification if -I flag was set for insecure downloads
if [ " $_INSECURE_DL " -eq $BS_TRUE ] ; then
export GIT_SSL_NO_VERIFY = 1
fi
2014-08-04 15:42:36 +01:00
2016-03-07 11:38:28 +02: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 } "
2016-03-07 11:38:28 +02: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 } "
2016-02-28 22:48:46 +02:00
# shellcheck disable=SC2164
2014-08-14 03:37:14 +01:00
cd " ${ __SALT_GIT_CHECKOUT_PARENT_DIR } "
2016-03-07 11:38:28 +02:00
if [ -d " ${ _SALT_GIT_CHECKOUT_DIR } " ] ; then
2014-07-29 13:11:35 +01:00
echodebug "Found a checked out Salt repository"
2016-02-28 22:48:46 +02:00
# shellcheck disable=SC2164
2016-03-07 11:38:28 +02: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.
2018-07-09 12:49:11 -04:00
if git branch -a | grep -q " ${ GIT_REV } " ; 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
2015-09-22 13:30:42 +02:00
if [ " $_FORCE_SHALLOW_CLONE " -eq " ${ BS_TRUE } " ] ; then
echoinfo "Forced shallow cloning of git repository."
2016-07-22 11:03:14 +03:00
__SHALLOW_CLONE = $BS_TRUE
2017-03-29 14:39:29 -03:00
elif [ " $__TAG_REGEX_MATCH " = "MATCH" ] ; then
2015-09-22 13:30:42 +02:00
echoinfo "Git revision matches a Salt version tag, shallow cloning enabled."
2016-07-22 11:03:14 +03:00
__SHALLOW_CLONE = $BS_TRUE
2015-09-22 13:30:42 +02:00
else
echowarn "The git revision being installed does not match a Salt version tag. Shallow cloning disabled"
2016-07-22 11:03:14 +03:00
__SHALLOW_CLONE = $BS_FALSE
2015-09-22 13:30:42 +02:00
fi
2016-07-22 11:03:14 +03:00
if [ " $__SHALLOW_CLONE " -eq $BS_TRUE ] ; then
2014-08-17 00:58:55 +01:00
# 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
2015-12-22 16:40:29 +02:00
if [ " $( git clone 2>& 1 | grep 'single-branch' ) " != "" ] ; then
2014-08-17 00:58:55 +01:00
# The "--single-branch" option is supported, attempt shallow cloning
echoinfo " Attempting to shallow clone $GIT_REV from Salt's repository ${ _SALT_REPO_URL } "
2018-07-09 12:49:11 -04:00
if git clone --depth 1 --branch " $GIT_REV " " $_SALT_REPO_URL " " $__SALT_CHECKOUT_REPONAME " ; then
2016-02-28 22:48:46 +02:00
# shellcheck disable=SC2164
2016-03-07 11:38:28 +02:00
cd " ${ _SALT_GIT_CHECKOUT_DIR } "
2016-07-22 11:03:14 +03:00
__SHALLOW_CLONE = $BS_TRUE
2014-08-17 00:58:55 +01:00
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"
2016-07-22 11:03:14 +03:00
__SHALLOW_CLONE = $BS_FALSE
2014-08-17 00:58:55 +01:00
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."
2016-07-22 11:03:14 +03:00
__SHALLOW_CLONE = $BS_FALSE
2014-08-04 16:14:48 +01:00
fi
2015-09-22 13:30:42 +02:00
fi
2016-07-22 11:03:14 +03:00
if [ " $__SHALLOW_CLONE " -eq $BS_FALSE ] ; then
2014-10-16 14:45:50 +08:00
git clone " $_SALT_REPO_URL " " $__SALT_CHECKOUT_REPONAME " || return 1
2016-03-10 11:01:22 +02:00
# shellcheck disable=SC2164
2016-03-07 11:38:28 +02:00
cd " ${ _SALT_GIT_CHECKOUT_DIR } "
2014-07-29 13:11:35 +01:00
2016-08-27 23:40:56 +03:00
if ! echo " $_SALT_REPO_URL " | grep -q -F -w " ${ _SALTSTACK_REPO_URL #* : // } " ; then
2015-09-22 14:37:24 +02:00
# We need to add the saltstack repository as a remote and fetch tags for proper versioning
echoinfo "Adding SaltStack's Salt repository as a remote"
git remote add upstream " $_SALTSTACK_REPO_URL " || return 1
2016-07-22 11:03:14 +03:00
2016-06-24 10:45:35 +03:00
echodebug "Fetching upstream (SaltStack's Salt repository) git tags"
2015-09-22 14:37:24 +02:00
git fetch --tags upstream || return 1
2016-07-22 11:03:14 +03:00
# Check if GIT_REV is a remote branch or just a commit hash
if git branch -r | grep -q -F -w " origin/ $GIT_REV " ; then
GIT_REV = " origin/ $GIT_REV "
fi
2015-09-22 14:37:24 +02:00
fi
2014-04-07 22:28:04 +01:00
2014-08-04 15:42:36 +01:00
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
2016-07-22 11:03:14 +03:00
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 -------------------------------------------------------------------------------------------------------
2016-03-04 10:33:47 +02:00
# NAME: __copyfile
2013-03-18 16:50:49 +00:00
# DESCRIPTION: Simple function to copy files. Overrides if asked.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2016-03-04 10:33:47 +02: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
2019-12-11 15:37:50 -07:00
echoerror "Wrong number of arguments for __copyfile()"
2016-03-04 10:33:47 +02:00
echoinfo "USAGE: __copyfile <source> <dest> OR __copyfile <source> <dest> <overwrite>"
2013-03-18 16:50:49 +00:00
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
2016-06-24 10:45:35 +03:00
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
2024-06-28 17:04:56 -06:00
elif [ -f " $dfile " ] && [ " $overwrite " -eq $BS_TRUE ] ; then
2013-03-18 16:50:49 +00:00
# The destination exist and we're overwriting
2016-08-10 11:20:31 +03:00
echodebug " Overwriting $dfile with $sfile "
2013-08-16 21:25:01 +01:00
cp -f " $sfile " " $dfile " || return 1
2024-06-28 17:04:56 -06:00
elif [ -f " $dfile " ] && [ " $overwrite " -ne $BS_TRUE ] ; then
2016-08-10 11:20:31 +03:00
echodebug " Not overwriting $dfile with $sfile "
2013-03-18 16:50:49 +00:00
fi
return 0
}
2014-02-17 15:21:29 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2016-03-04 10:33:47 +02:00
# NAME: __movefile
2013-04-23 11:15:54 +01:00
# DESCRIPTION: Simple function to move files. Overrides if asked.
2014-02-17 15:21:29 +00:00
#----------------------------------------------------------------------------------------------------------------------
2016-03-04 10:33:47 +02: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
2019-12-11 15:37:50 -07:00
echoerror "Wrong number of arguments for __movefile()"
2016-03-04 10:33:47 +02:00
echoinfo "USAGE: __movefile <source> <dest> OR __movefile <source> <dest> <overwrite>"
2013-04-23 11:15:54 +01:00
exit 1
fi
2024-06-28 17:04:56 -06: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"
2016-03-04 10:33:47 +02: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
2016-02-28 17:08:43 +02:00
# The destination file does not exist, move
2013-04-23 11:15:54 +01:00
echodebug " Moving $sfile to $dfile "
mv " $sfile " " $dfile " || return 1
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06: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
2016-02-28 17:08:43 +02:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2016-02-28 22:49:52 +02:00
# NAME: __linkfile
2016-02-28 17:08:43 +02:00
# DESCRIPTION: Simple function to create symlinks. Overrides if asked. Accepts globs.
#----------------------------------------------------------------------------------------------------------------------
2016-02-28 22:49:52 +02:00
__linkfile( ) {
2016-02-28 17:08:43 +02:00
overwrite = $_FORCE_OVERWRITE
if [ $# -eq 2 ] ; then
target = $1
linkname = $2
elif [ $# -eq 3 ] ; then
target = $1
linkname = $2
overwrite = $3
else
2019-12-11 15:37:50 -07:00
echoerror "Wrong number of arguments for __linkfile()"
2016-02-28 22:49:52 +02:00
echoinfo "USAGE: __linkfile <target> <link> OR __linkfile <tagret> <link> <overwrite>"
2016-02-28 17:08:43 +02:00
exit 1
fi
for sfile in $target ; do
# Does the source file exist?
if [ ! -f " $sfile " ] ; then
echowarn " $sfile does not exist! "
return 1
fi
# If the destination is a directory, let's make it a full path so the logic
# below works as expected
if [ -d " $linkname " ] ; then
echodebug " The passed link name ( $linkname ) is a directory "
linkname = " ${ linkname } / $( basename " $sfile " ) "
echodebug " Full destination path is now: $linkname "
fi
if [ ! -e " $linkname " ] ; then
# The destination file does not exist, create link
echodebug " Creating $linkname symlink pointing to $sfile "
ln -s " $sfile " " $linkname " || return 1
2024-06-28 17:04:56 -06:00
elif [ -e " $linkname " ] && [ " $overwrite " -eq $BS_TRUE ] ; then
2016-02-28 17:08:43 +02:00
# The destination exist and we're overwriting
echodebug " Overwriting $linkname symlink to point on $sfile "
ln -sf " $sfile " " $linkname " || return 1
2024-06-28 17:04:56 -06:00
elif [ -e " $linkname " ] && [ " $overwrite " -ne $BS_TRUE ] ; then
2016-02-28 17:08:43 +02:00
echodebug " Not overwriting $linkname symlink to point on $sfile "
fi
done
return 0
}
2016-05-06 12:53:11 -06:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __overwriteconfig()
# DESCRIPTION: Simple function to overwrite master or minion config files.
#----------------------------------------------------------------------------------------------------------------------
__overwriteconfig( ) {
if [ $# -eq 2 ] ; then
target = $1
json = $2
else
2019-12-11 15:37:50 -07:00
echoerror "Wrong number of arguments for __convert_json_to_yaml_str()"
2016-05-06 12:53:11 -06:00
echoinfo "USAGE: __convert_json_to_yaml_str <configfile> <jsonstring>"
exit 1
fi
2016-05-10 12:59:27 -06:00
# Make a tempfile to dump any python errors into.
if __check_command_exists mktemp; then
tempfile = " $( mktemp /tmp/salt-config-XXXXXXXX 2>/dev/null) "
2016-05-06 12:53:11 -06:00
2016-05-10 12:59:27 -06:00
if [ -z " $tempfile " ] ; then
echoerror "Failed to create temporary file in /tmp"
return 1
fi
else
tempfile = " /tmp/salt-config- $$ "
fi
2019-08-28 20:40:07 -06:00
if [ -n " $_PY_EXE " ] ; then
good_python = " $_PY_EXE "
2016-09-13 03:35:20 +10:00
# If python does not have yaml installed we're on Arch and should use python2
2024-02-02 17:57:31 -07:00
# but no more support, hence error out
2019-08-28 20:40:07 -06:00
elif python -c "import yaml" 2> /dev/null; then
2024-02-08 09:28:56 -07:00
good_python = python # assume python is python 3 on Arch
2016-09-13 03:35:20 +10:00
else
2024-02-02 17:57:31 -07:00
## good_python=python2
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2016-09-13 03:35:20 +10:00
fi
2016-05-10 12:59:27 -06:00
# Convert json string to a yaml string and write it to config file. Output is dumped into tempfile.
2024-02-02 15:32:40 -07:00
" $good_python " -c " import json; import yaml; jsn=json.loads(' $json '); yml=yaml.safe_dump(jsn, line_break='\\n', default_flow_style=False); config_file=open(' $target ', 'w'); config_file.write(yml); config_file.close(); " 2>" $tempfile "
2016-05-10 12:59:27 -06:00
# No python errors output to the tempfile
2016-09-13 03:33:27 +10:00
if [ ! -s " $tempfile " ] ; then
2016-05-10 12:59:27 -06:00
rm -f " $tempfile "
return 0
fi
2016-09-13 03:33:27 +10:00
# Errors are present in the tempfile - let's expose them to the user.
fullerror = $( cat " $tempfile " )
2016-05-10 12:59:27 -06:00
echodebug " $fullerror "
echoerror "Python error encountered. This is likely due to passing in a malformed JSON string. Please use -D to see stacktrace."
rm -f " $tempfile "
return 1
2016-05-06 12:53:11 -06:00
}
2016-02-28 17:08:43 +02:00
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
2018-07-09 12:49:11 -04:00
if initctl list | grep " ${ servicename } " > /dev/null 2>& 1; then
2014-02-20 12:57:37 +00:00
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 "
2018-05-31 13:28:18 -04:00
if [ " $( LC_ALL = C /sbin/chkconfig --list | grep " \\< ${ servicename } \\> " | 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 "
2016-04-28 10:49:39 +03:00
# Check if the service is going to be started at any runlevel, fixes bootstrap in container (Docker, LXC)
if ls /etc/rc?.d/S*" ${ servicename } " >/dev/null 2>& 1; 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 ----------
2017-01-08 15:18:51 +01:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
2020-09-25 16:28:26 +02:00
# NAME: __check_services_openrc
2017-01-08 15:18:51 +01:00
# DESCRIPTION: Return 0 or 1 in case the service is enabled or not
# PARAMETERS: servicename
#----------------------------------------------------------------------------------------------------------------------
2020-09-25 16:28:26 +02:00
__check_services_openrc( ) {
2017-01-08 15:18:51 +01:00
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 "
# shellcheck disable=SC2086,SC2046,SC2144
2018-05-31 13:28:18 -04:00
if rc-status $( rc-status -r) | tail -n +2 | grep -q " \\< $servicename \\> " ; then
2017-01-08 15:18:51 +01:00
echodebug " Service ${ servicename } is enabled "
return 0
else
echodebug " Service ${ servicename } is NOT enabled "
return 1
fi
2020-09-25 16:28:26 +02:00
} # ---------- end of function __check_services_openrc ----------
2017-01-08 15:18:51 +01:00
2015-12-30 00:13:11 -05:00
2016-04-11 15:27:04 -07:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __create_virtualenv
# DESCRIPTION: Return 0 or 1 depending on successful creation of virtualenv
#----------------------------------------------------------------------------------------------------------------------
__create_virtualenv( ) {
if [ ! -d " $_VIRTUALENV_DIR " ] ; then
echoinfo " Creating virtualenv ${ _VIRTUALENV_DIR } "
2024-06-28 17:04:56 -06:00
if [ " $_PIP_ALL " -eq $BS_TRUE ] ; then
2016-04-13 02:52:10 -06:00
virtualenv --no-site-packages " ${ _VIRTUALENV_DIR } " || return 1
2016-04-11 15:27:04 -07:00
else
2016-04-13 02:52:10 -06:00
virtualenv --system-site-packages " ${ _VIRTUALENV_DIR } " || return 1
2016-04-11 15:27:04 -07:00
fi
fi
return 0
} # ---------- end of function __create_virtualenv ----------
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __activate_virtualenv
# DESCRIPTION: Return 0 or 1 depending on successful activation of virtualenv
#----------------------------------------------------------------------------------------------------------------------
__activate_virtualenv( ) {
set +o nounset
# Is virtualenv empty
2018-05-10 16:16:17 -04:00
if [ -z " $_VIRTUALENV_DIR " ] ; then
2016-04-11 15:27:04 -07:00
__create_virtualenv || return 1
2016-04-13 13:11:04 -06:00
# shellcheck source=/dev/null
2016-04-13 02:52:10 -06:00
. " ${ _VIRTUALENV_DIR } /bin/activate " || return 1
2016-04-11 15:27:04 -07:00
echoinfo " Activated virtualenv ${ _VIRTUALENV_DIR } "
fi
set -o nounset
return 0
} # ---------- end of function __activate_virtualenv ----------
2017-04-19 13:40:25 -04:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __install_pip_pkgs
# DESCRIPTION: Return 0 or 1 if successfully able to install pip packages. Can provide a different python version to
2024-06-28 17:04:56 -06:00
# install pip packages with. If $py_ver is not specified it will use the default python version.
2023-04-22 12:23:05 -07:00
# PARAMETERS: pkgs, py_ver, upgrade
2017-04-19 13:40:25 -04:00
#----------------------------------------------------------------------------------------------------------------------
__install_pip_pkgs( ) {
_pip_pkgs = " $1 "
_py_exe = " $2 "
2024-06-28 17:04:56 -06:00
_py_pkg = $( echo " $_py_exe " | sed -E "s/\\.//g" )
_pip_cmd = " ${ _py_exe } -m pip "
2017-04-19 13:40:25 -04:00
2017-04-19 13:55:09 -04:00
if [ " ${ _py_exe } " = "" ] ; then
2024-02-02 17:57:31 -07:00
_py_exe = 'python3'
2017-04-19 13:40:25 -04:00
fi
__check_pip_allowed
# Install pip and pip dependencies
if ! __check_command_exists " ${ _pip_cmd } --version " ; then
2019-10-29 14:56:03 -04:00
__PACKAGES = " ${ _py_pkg } -setuptools ${ _py_pkg } -pip gcc "
2017-04-19 13:55:09 -04:00
# shellcheck disable=SC2086
2020-02-05 09:14:57 -07:00
if [ " $DISTRO_NAME_L " = "debian" ] || [ " $DISTRO_NAME_L " = "ubuntu" ] ; then
2019-10-29 14:56:03 -04:00
__PACKAGES = " ${ __PACKAGES } ${ _py_pkg } -dev "
__apt_get_install_noinput ${ __PACKAGES } || return 1
else
__PACKAGES = " ${ __PACKAGES } ${ _py_pkg } -devel "
2019-12-17 09:31:23 -08:00
if [ " $DISTRO_NAME_L " = "fedora" ] ; then
__dnf_install_noinput ${ __PACKAGES } || return 1
else
__yum_install_noinput ${ __PACKAGES } || return 1
fi
2019-10-29 14:56:03 -04:00
fi
2017-04-19 13:40:25 -04:00
fi
echoinfo " Installing pip packages: ${ _pip_pkgs } using ${ _py_exe } "
2017-04-19 13:55:09 -04:00
# shellcheck disable=SC2086
2017-04-19 13:40:25 -04:00
${ _pip_cmd } install ${ _pip_pkgs } || return 1
}
2016-04-11 15:27:04 -07:00
2024-07-01 11:48:29 -06:00
## DGM #--- FUNCTION -------------------------------------------------------------------------------------------------------
## DGM # NAME: __install_tornado_pip
## DGM # PARAMETERS: python executable
## DGM # DESCRIPTION: Return 0 or 1 if successfully able to install tornado<5.0
## DGM #----------------------------------------------------------------------------------------------------------------------
## DGM __install_tornado_pip() {
## DGM # OS needs tornado <5.0 from pip
## DGM __check_pip_allowed "You need to allow pip based installations (-P) for Tornado <5.0 in order to install Salt on Python 3"
## DGM ## install pip if its not installed and install tornado
## DGM __install_pip_pkgs "tornado<5.0" "${1}" || return 1
## DGM }
2019-10-29 14:56:03 -04:00
2016-04-11 15:27:04 -07:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __install_pip_deps
# DESCRIPTION: Return 0 or 1 if successfully able to install pip packages via requirements file
2016-08-18 17:39:11 +03:00
# PARAMETERS: requirements_file
2016-04-11 15:27:04 -07:00
#----------------------------------------------------------------------------------------------------------------------
__install_pip_deps( ) {
# Install virtualenv to system pip before activating virtualenv if thats going to be used
# We assume pip pkg is installed since that is distro specific
if [ " $_VIRTUALENV_DIR " != "null" ] ; then
2016-04-13 14:04:00 -06:00
if ! __check_command_exists pip; then
2016-04-11 15:27:04 -07:00
echoerror "Pip not installed: required for -a installs"
exit 1
fi
pip install -U virtualenv
__activate_virtualenv || return 1
else
echoerror "Must have virtualenv dir specified for -a installs"
fi
requirements_file = $1
if [ ! -f " ${ requirements_file } " ] ; then
echoerror " Requirements file: ${ requirements_file } cannot be found, needed for -a (pip pkg) installs "
exit 1
fi
__PIP_PACKAGES = ''
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2016-04-11 15:27:04 -07:00
# shellcheck disable=SC2089
__PIP_PACKAGES = " ${ __PIP_PACKAGES } 'apache-libcloud>= $_LIBCLOUD_MIN_VERSION ' "
fi
# shellcheck disable=SC2086,SC2090
pip install -U -r ${ requirements_file } ${ __PIP_PACKAGES }
2016-08-18 17:39:11 +03:00
} # ---------- end of function __install_pip_deps ----------
2016-04-11 15:27:04 -07:00
2020-01-28 19:20:03 +00:00
#--- FUNCTION -------------------------------------------------------------------------------------------------------
# NAME: __install_salt_from_repo_post_neon
# DESCRIPTION: Return 0 or 1 if successfully able to install. Can provide a different python version to
# install pip packages with. If $py_exe is not specified it will use the default python version.
# PARAMETERS: py_exe
#----------------------------------------------------------------------------------------------------------------------
__install_salt_from_repo_post_neon( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2020-01-28 19:20:03 +00:00
_py_exe = " $1 "
if [ " ${ _py_exe } " = "" ] ; then
2024-02-08 09:28:56 -07:00
_py_exe = "python3"
2020-01-28 19:20:03 +00:00
fi
echodebug " __install_salt_from_repo_post_neon py_exe= $_py_exe "
2020-01-30 12:36:56 +00:00
_py_version = $( ${ _py_exe } -c "import sys; print('{0}.{1}'.format(*sys.version_info))" )
_pip_cmd = " pip ${ _py_version } "
if ! __check_command_exists " ${ _pip_cmd } " ; then
echodebug " The pip binary ' ${ _pip_cmd } ' was not found in PATH "
_pip_cmd = " pip $( echo " ${ _py_version } " | cut -c -1) "
if ! __check_command_exists " ${ _pip_cmd } " ; then
echodebug " The pip binary ' ${ _pip_cmd } ' was not found in PATH "
_pip_cmd = "pip"
if ! __check_command_exists " ${ _pip_cmd } " ; then
echoerror "Unable to find a pip binary"
return 1
fi
fi
fi
2020-01-28 19:20:03 +00:00
__check_pip_allowed
2020-01-30 12:36:56 +00:00
echodebug " Installed pip version: $( ${ _pip_cmd } --version) "
CHECK_PIP_VERSION_SCRIPT = $( cat << EOM
import sys
try:
import pip
installed_pip_version = tuple( [ int( part.strip( ) ) for part in pip.__version__.split( '.' ) if part.isdigit( ) ] )
2024-06-28 17:04:56 -06:00
desired_pip_version = ( $( echo ${ _MINIMUM_PIP_VERSION } | sed 's/\./, /g' ) )
2020-01-30 12:36:56 +00:00
if installed_pip_version < desired_pip_version:
print( 'Desired pip version {!r} > Installed pip version {!r}' .format( '.' .join( map( str, desired_pip_version) ) , '.' .join( map( str, installed_pip_version) ) ) )
sys.exit( 1)
print( 'Desired pip version {!r} < Installed pip version {!r}' .format( '.' .join( map( str, desired_pip_version) ) , '.' .join( map( str, installed_pip_version) ) ) )
sys.exit( 0)
except ImportError:
print( 'Failed to import pip' )
sys.exit( 1)
EOM
)
if ! ${ _py_exe } -c " $CHECK_PIP_VERSION_SCRIPT " ; then
2024-02-02 17:57:31 -07:00
# Upgrade pip to at least 1.2 which is when we can start using "python3 -m pip"
2024-02-08 09:28:56 -07:00
echodebug " Running ' ${ _pip_cmd } install ${ _POST_NEON_PIP_INSTALL_ARGS } pip>= ${ _MINIMUM_PIP_VERSION } ' "
2024-06-27 14:18:42 -06:00
## DGM ${_pip_cmd} install "${_POST_NEON_PIP_INSTALL_ARGS}" -v "pip>=${_MINIMUM_PIP_VERSION}"
${ _pip_cmd } install ${ _POST_NEON_PIP_INSTALL_ARGS } -v " pip>= ${ _MINIMUM_PIP_VERSION } "
2020-01-30 12:36:56 +00:00
sleep 1
echodebug " PATH: ${ PATH } "
_pip_cmd = " pip ${ _py_version } "
if ! __check_command_exists " ${ _pip_cmd } " ; then
echodebug " The pip binary ' ${ _pip_cmd } ' was not found in PATH "
_pip_cmd = " pip $( echo " ${ _py_version } " | cut -c -1) "
if ! __check_command_exists " ${ _pip_cmd } " ; then
echodebug " The pip binary ' ${ _pip_cmd } ' was not found in PATH "
_pip_cmd = "pip"
if ! __check_command_exists " ${ _pip_cmd } " ; then
echoerror "Unable to find a pip binary"
return 1
fi
fi
2020-01-28 19:20:03 +00:00
fi
2020-01-30 12:36:56 +00:00
echodebug " Installed pip version: $( ${ _pip_cmd } --version) "
2020-01-28 19:20:03 +00:00
fi
2021-05-01 14:59:26 +02:00
_setuptools_dep = " setuptools>= ${ _MINIMUM_SETUPTOOLS_VERSION } "
2024-06-26 12:00:17 -06:00
if [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2021-05-01 14:59:26 +02:00
fi
2024-07-02 15:27:05 -06:00
_USE_BREAK_SYSTEM_PACKAGES = ""
_PIP_VERSION = $( ${ _pip_cmd } --version | awk '{print $2}' )
# shellcheck disable=SC2086,SC2090
if [ ${ _PIP_VERSION } -ge 24 ] ; then
_USE_BREAK_SYSTEM_PACKAGES = "--break-system-packages"
echodebug " pip command is greater than / equal 24, using ${ _USE_BREAK_SYSTEM_PACKAGES } "
fi
2021-05-01 14:59:26 +02:00
echodebug " Running ' ${ _pip_cmd } install wheel ${ _setuptools_dep } ' "
2024-06-27 14:18:42 -06:00
## DGM ${_pip_cmd} install --upgrade "${_POST_NEON_PIP_INSTALL_ARGS}" wheel "${_setuptools_dep}"
2024-07-02 14:54:14 -06:00
### DGM ${_pip_cmd} install --upgrade ${_POST_NEON_PIP_INSTALL_ARGS} wheel "${_setuptools_dep}"
2024-07-02 15:27:05 -06:00
${ _pip_cmd } install ${ _USE_BREAK_SYSTEM_PACKAGES } --upgrade ${ _POST_NEON_PIP_INSTALL_ARGS } wheel " ${ _setuptools_dep } "
2020-01-28 19:20:03 +00:00
echoinfo " Installing salt using ${ _py_exe } "
cd " ${ _SALT_GIT_CHECKOUT_DIR } " || return 1
2020-01-30 12:36:56 +00:00
mkdir /tmp/git/deps
echoinfo "Downloading Salt Dependencies from PyPi"
2023-02-03 16:39:35 -08:00
echodebug " Running ' ${ _pip_cmd } download -d /tmp/git/deps ${ _PIP_DOWNLOAD_ARGS } .' "
2024-06-27 14:18:42 -06:00
## DGM ${_pip_cmd} download -d /tmp/git/deps "${_PIP_DOWNLOAD_ARGS}" . || (echo "Failed to download salt dependencies" && return 1)
${ _pip_cmd } download -d /tmp/git/deps ${ _PIP_DOWNLOAD_ARGS } . || ( echo "Failed to download salt dependencies" && return 1)
2020-01-30 12:36:56 +00:00
echoinfo "Installing Downloaded Salt Dependencies"
echodebug " Running ' ${ _pip_cmd } install --ignore-installed ${ _POST_NEON_PIP_INSTALL_ARGS } /tmp/git/deps/*' "
2024-06-27 14:18:42 -06:00
## ${_pip_cmd} install --ignore-installed "${_POST_NEON_PIP_INSTALL_ARGS}" /tmp/git/deps/* || return 1
2024-07-02 14:54:14 -06:00
## DGM ${_pip_cmd} install --ignore-installed ${_POST_NEON_PIP_INSTALL_ARGS} /tmp/git/deps/* || return 1
2024-07-02 15:27:05 -06:00
${ _pip_cmd } install ${ _USE_BREAK_SYSTEM_PACKAGES } --ignore-installed ${ _POST_NEON_PIP_INSTALL_ARGS } /tmp/git/deps/* || return 1
2020-01-30 12:36:56 +00:00
rm -f /tmp/git/deps/*
echoinfo "Building Salt Python Wheel"
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
2020-01-30 12:36:56 +00:00
SETUP_PY_INSTALL_ARGS = "-v"
fi
echodebug " Running ' ${ _py_exe } setup.py --salt-config-dir= $_SALT_ETC_DIR --salt-cache-dir= ${ _SALT_CACHE_DIR } ${ SETUP_PY_INSTALL_ARGS } bdist_wheel' "
2024-02-02 15:32:40 -07:00
${ _py_exe } setup.py --salt-config-dir= " $_SALT_ETC_DIR " --salt-cache-dir= " ${ _SALT_CACHE_DIR } ${ SETUP_PY_INSTALL_ARGS } " bdist_wheel || return 1
2020-01-30 12:36:56 +00:00
mv dist/salt*.whl /tmp/git/deps/ || return 1
cd " ${ __SALT_GIT_CHECKOUT_PARENT_DIR } " || return 1
echoinfo "Installing Built Salt Wheel"
${ _pip_cmd } uninstall --yes salt 2>/dev/null || true
echodebug " Running ' ${ _pip_cmd } install --no-deps --force-reinstall ${ _POST_NEON_PIP_INSTALL_ARGS } /tmp/git/deps/salt*.whl' "
2024-06-27 14:18:42 -06:00
## DGM "${_POST_NEON_PIP_INSTALL_ARGS}" \
2020-01-30 12:36:56 +00:00
${ _pip_cmd } install --no-deps --force-reinstall \
2024-06-27 14:18:42 -06:00
${ _POST_NEON_PIP_INSTALL_ARGS } \
2020-01-30 12:36:56 +00:00
--global-option= " --salt-config-dir= $_SALT_ETC_DIR --salt-cache-dir= ${ _SALT_CACHE_DIR } ${ SETUP_PY_INSTALL_ARGS } " \
/tmp/git/deps/salt*.whl || return 1
echoinfo " Checking if Salt can be imported using ${ _py_exe } "
CHECK_SALT_SCRIPT = $( cat << EOM
import os
import sys
try:
import salt
import salt.version
print( '\nInstalled Salt Version: {}' .format( salt.version.__version__) )
print( 'Installed Salt Package Path: {}\n' .format( os.path.dirname( salt.__file__) ) )
sys.exit( 0)
except ImportError:
print( '\nFailed to import salt\n' )
sys.exit( 1)
EOM
)
if ! ${ _py_exe } -c " $CHECK_SALT_SCRIPT " ; then
return 1
fi
return 0
2020-01-28 19:20:03 +00:00
} # ---------- end of function __install_salt_from_repo_post_neon ----------
2016-04-11 15:27:04 -07:00
2024-02-02 17:57:31 -07:00
# shellcheck disable=SC2268
if [ " x ${ _PY_MAJOR_VERSION } " = "x" ] ; then
# Default to python 3 for post Neon install
_PY_MAJOR_VERSION = 3
2020-05-27 10:12:47 +01:00
fi
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"
2016-12-22 10:13:01 -07:00
add-apt-repository -y " deb http://archive.ubuntu.com/ubuntu $( lsb_release -sc) universe " || return 1
2015-12-04 13:47:24 -05:00
2013-09-25 17:38:27 +01:00
return 0
}
2024-07-02 13:57:12 -06:00
## DGM __install_saltstack_ubuntu_repository() {
## DGM # Workaround for latest non-LTS Ubuntu
## DGM ## DGM Debugging
## DGM set -v
## DGM set -x
## DGM
## DGM echodebug "DGM Ubuntu A checking STABLE_REV ,${STABLE_REV}, ONEDIR_REV ,$ONEDIR_REV,"
## DGM
## DGM if { [ "$DISTRO_MAJOR_VERSION" -eq 20 ] && [ "$DISTRO_MINOR_VERSION" -eq 10 ]; } || \
## DGM { [ "$DISTRO_MAJOR_VERSION" -eq 22 ] && [ "$DISTRO_MINOR_VERSION" -eq 10 ]; } || \
## DGM [ "$DISTRO_MAJOR_VERSION" -eq 21 ] || [ "$DISTRO_MAJOR_VERSION" -eq 23 ]; then
## DGM echowarn "Non-LTS Ubuntu detected, but stable packages requested. Trying packages for previous LTS release. You may experience problems."
## DGM UBUNTU_VERSION=24.04
## DGM UBUNTU_CODENAME="noble"
## DGM else
## DGM UBUNTU_VERSION=${DISTRO_VERSION}
## DGM UBUNTU_CODENAME=${DISTRO_CODENAME}
## DGM fi
## DGM
## DGM # Install downloader backend for GPG keys fetching
## DGM __PACKAGES='wget'
## DGM
## DGM # Required as it is not installed by default on Ubuntu 18+
## DGM if [ "$DISTRO_MAJOR_VERSION" -ge 18 ]; then
## DGM __PACKAGES="${__PACKAGES} gnupg"
## DGM fi
## DGM
## DGM # Make sure https transport is available
## DGM if [ "$HTTP_VAL" = "https" ] ; then
## DGM __PACKAGES="${__PACKAGES} apt-transport-https ca-certificates"
## DGM fi
## DGM
## DGM ## DGM tornado appears to be missing in 3006.x pkg requirements
## DGM ## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
## DGM
## DGM ## DGM include hwclock if not part of base OS (23.10 and up)
## DGM if [ ! -f /usr/sbin/hwclock ]; then
## DGM __PACKAGES="${__PACKAGES} util-linux-extra"
## DGM fi
## DGM
## DGM # shellcheck disable=SC2086,SC2090
## DGM __apt_get_install_noinput ${__PACKAGES} || return 1
## DGM
## DGM if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -ne 3 ]; then
## DGM echoerror "Python version is not supported, only Python 3"
## DGM return 1
## DGM fi
## DGM
## DGM # SaltStack's stable Ubuntu repository:
## DGM SALTSTACK_UBUNTU_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/ubuntu/${UBUNTU_VERSION}/${__REPO_ARCH}/${STABLE_REV}"
## DGM echo "$__REPO_ARCH_DEB $SALTSTACK_UBUNTU_URL $UBUNTU_CODENAME main" > /etc/apt/sources.list.d/salt.list
## DGM __apt_key_fetch "$SALTSTACK_UBUNTU_URL/SALT-PROJECT-GPG-PUBKEY-2023.gpg" || return 1
## DGM
## DGM __wait_for_apt apt-get update || return 1
## DGM }
2017-05-25 17:55:56 -06:00
2022-07-27 13:25:02 -07:00
__install_saltstack_ubuntu_onedir_repository( ) {
2022-04-11 16:47:01 -07:00
# Workaround for latest non-LTS Ubuntu
if { [ " $DISTRO_MAJOR_VERSION " -eq 20 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ; } || \
2024-02-08 09:28:56 -07:00
{ [ " $DISTRO_MAJOR_VERSION " -eq 22 ] && [ " $DISTRO_MINOR_VERSION " -eq 10 ] ; } || \
[ " $DISTRO_MAJOR_VERSION " -eq 21 ] || [ " $DISTRO_MAJOR_VERSION " -eq 23 ] ; then
2022-04-11 16:47:01 -07:00
echowarn "Non-LTS Ubuntu detected, but stable packages requested. Trying packages for previous LTS release. You may experience problems."
2024-06-04 17:06:07 -06:00
UBUNTU_VERSION = 24.04
UBUNTU_CODENAME = "noble"
2022-04-11 16:47:01 -07:00
else
UBUNTU_VERSION = ${ DISTRO_VERSION }
UBUNTU_CODENAME = ${ DISTRO_CODENAME }
fi
2024-07-01 16:29:40 -06:00
echodebug " DGM Ubuntu B checking ONEDIR_REV , $ONEDIR_REV , "
2024-07-01 13:45:45 -06:00
2022-04-11 16:47:01 -07:00
# Install downloader backend for GPG keys fetching
__PACKAGES = 'wget'
# Required as it is not installed by default on Ubuntu 18+
if [ " $DISTRO_MAJOR_VERSION " -ge 18 ] ; then
__PACKAGES = " ${ __PACKAGES } gnupg "
fi
# Make sure https transport is available
if [ " $HTTP_VAL " = "https" ] ; then
__PACKAGES = " ${ __PACKAGES } apt-transport-https ca-certificates "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-07-02 13:57:12 -06:00
## DGM include hwclock if not part of base OS (23.10 and up)
if [ ! -f /usr/sbin/hwclock ] ; then
__PACKAGES = " ${ __PACKAGES } util-linux-extra "
fi
2022-04-11 16:47:01 -07:00
# shellcheck disable=SC2086,SC2090
__apt_get_install_noinput ${ __PACKAGES } || return 1
# SaltStack's stable Ubuntu repository:
2022-07-27 13:25:02 -07:00
SALTSTACK_UBUNTU_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /ubuntu/ ${ UBUNTU_VERSION } / ${ __REPO_ARCH } / ${ ONEDIR_REV } / "
2022-12-05 08:11:23 +00:00
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
SALTSTACK_UBUNTU_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /ubuntu/ ${ UBUNTU_VERSION } / ${ __REPO_ARCH } / "
fi
2022-07-21 15:43:17 -07:00
echo " $__REPO_ARCH_DEB $SALTSTACK_UBUNTU_URL $UBUNTU_CODENAME main " > /etc/apt/sources.list.d/salt.list
2022-04-11 16:47:01 -07:00
2024-07-01 13:45:45 -06:00
__apt_key_fetch " ${ SALTSTACK_UBUNTU_URL } SALT-PROJECT-GPG-PUBKEY-2023.gpg " || return 1
2022-04-11 16:47:01 -07:00
__wait_for_apt apt-get update || return 1
}
2012-10-17 14:02:09 +01:00
install_ubuntu_deps( ) {
2024-06-28 17:04:56 -06:00
if [ " $_DISABLE_REPOS " -eq $BS_FALSE ] ; then
2017-05-24 10:48:29 +03:00
# Install add-apt-repository
if ! __check_command_exists add-apt-repository; then
__apt_get_install_noinput software-properties-common || return 1
2015-10-20 16:34:27 -06:00
fi
2017-05-24 10:48:29 +03:00
__enable_universe_repository || return 1
2018-11-01 14:19:59 -04:00
__wait_for_apt apt-get update || return 1
2016-08-16 18:22:44 +03:00
fi
2015-07-22 13:13:25 +01:00
2017-05-24 10:48:29 +03:00
__PACKAGES = ''
2024-06-26 12:00:17 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2019-06-30 15:43:44 +01:00
fi
2024-02-08 09:28:56 -07:00
if [ " $DISTRO_MAJOR_VERSION " -ge 20 ] && [ -z " $_PY_EXE " ] ; then
2024-06-28 17:04:56 -06:00
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } "
2016-04-15 13:32:42 -06:00
fi
2017-05-24 10:48:29 +03:00
2016-04-11 15:27:04 -07:00
if [ " $_VIRTUALENV_DIR " != "null" ] ; then
2024-06-28 17:04:56 -06:00
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -virtualenv "
2016-04-11 15:27:04 -07:00
fi
2024-06-28 17:04:56 -06:00
2014-07-31 13:40:51 -07:00
# Need python-apt for managing packages via Salt
2019-06-30 15:43:44 +01:00
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -apt "
2015-07-22 12:54:37 +01:00
2015-10-20 16:34:27 -06:00
# requests is still used by many salt modules
2019-06-30 15:43:44 +01:00
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -requests "
2014-07-31 13:40:51 -07:00
2016-11-22 12:10:02 +02:00
# YAML module is used for generating custom master/minion configs
2019-06-30 15:43:44 +01:00
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -yaml "
2016-11-22 12:10:02 +02:00
2016-04-11 15:27:04 -07:00
# Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813
2015-07-22 12:54:37 +01:00
__PACKAGES = " ${ __PACKAGES } procps pciutils "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-07-02 13:57:12 -06:00
## DGM include hwclock if not part of base OS (23.10 and up)
if [ ! -f /usr/sbin/hwclock ] ; then
__PACKAGES = " ${ __PACKAGES } util-linux-extra "
fi
2016-08-16 18:22:44 +03:00
# shellcheck disable=SC2086,SC2090
__apt_get_install_noinput ${ __PACKAGES } || return 1
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
}
2024-07-02 13:57:12 -06:00
## DGM install_ubuntu_stable_deps() {
## DGM if [ "$_START_DAEMONS" -eq $BS_FALSE ]; then
## DGM echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
## DGM fi
## DGM
## DGM # No user interaction, libc6 restart services for example
## DGM export DEBIAN_FRONTEND=noninteractive
## DGM
## DGM __wait_for_apt apt-get update || return 1
## DGM
## DGM if [ "${_UPGRADE_SYS}" -eq $BS_TRUE ]; then
## DGM if [ "${_INSECURE_DL}" -eq $BS_TRUE ]; then
## DGM ## TBD DGM Need to understand what this code is doing, since '-ge 20' already covers '-ge 21' etc., added 23 & 24 to continue style
## DGM ## also apt-key is deprecated
## DGM if [ "$DISTRO_MAJOR_VERSION" -ge 20 ] || [ "$DISTRO_MAJOR_VERSION" -ge 21 ] || [ "$DISTRO_MAJOR_VERSION" -ge 22 ] || [ "$DISTRO_MAJOR_VERSION" -ge 23 ] || [ "$DISTRO_MAJOR_VERSION" -ge 24 ]; then
## DGM __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1
## DGM else
## DGM __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring &&
## DGM apt-key update && apt-get update || return 1
## DGM fi
## DGM fi
## DGM
## DGM __apt_get_upgrade_noinput || return 1
## DGM fi
## DGM
## DGM if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
## DGM __check_dpkg_architecture || return 1
## DGM __install_saltstack_ubuntu_repository || return 1
## DGM fi
## DGM
## DGM install_ubuntu_deps || return 1
## DGM }
2015-03-12 03:52:31 -07:00
2012-10-19 21:16:00 -07:00
install_ubuntu_git_deps( ) {
2024-06-27 14:18:42 -06:00
## DGM Debugging
set -v
set -x
2018-11-01 14:19:59 -04:00
__wait_for_apt apt-get update || return 1
2016-11-29 12:36:56 +02:00
if ! __check_command_exists git; then
__apt_get_install_noinput git-core || return 1
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSECURE_DL " -eq $BS_FALSE ] && [ " ${ _SALT_REPO_URL %% : //* } " = "https" ] ; then
2016-11-29 12:36:56 +02:00
__apt_get_install_noinput ca-certificates
fi
2013-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-01-18 02:42:49 +00:00
2024-06-26 12:00:17 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2020-01-28 19:20:03 +00:00
fi
2024-02-02 17:57:31 -07:00
__PACKAGES = " python ${ PY_PKG_VER } -dev python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools gcc "
if [ " $DISTRO_MAJOR_VERSION " -ge 22 ] ; then
__PACKAGES = " ${ __PACKAGES } g++ "
2015-05-01 14:30:55 +01:00
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-07-02 13:57:12 -06:00
## DGM include hwclock if not part of base OS (23.10 and up)
if [ ! -f /usr/sbin/hwclock ] ; then
__PACKAGES = " ${ __PACKAGES } util-linux-extra "
fi
2024-02-02 17:57:31 -07:00
# shellcheck disable=SC2086
__apt_get_install_noinput ${ __PACKAGES } || return 1
2015-05-01 14:30:55 +01:00
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
2016-03-07 11:38:28 +02: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
}
2022-07-27 13:25:02 -07:00
install_ubuntu_onedir_deps( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
if [ " $_START_DAEMONS " -eq $BS_FALSE ] ; then
2022-04-11 16:47:01 -07:00
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
__wait_for_apt apt-get update || return 1
2024-06-28 17:04:56 -06:00
if [ " ${ _UPGRADE_SYS } " -eq $BS_TRUE ] ; then
if [ " ${ _INSECURE_DL } " -eq $BS_TRUE ] ; then
2024-02-08 09:28:56 -07:00
## TBD DGM Need to understand what this code is doing, since '-ge 20' already covers '-ge 21' etc.
## also apt-key is deprecated
2024-06-28 17:04:56 -06:00
if [ " $DISTRO_MAJOR_VERSION " -ge 20 ] || [ " $DISTRO_MAJOR_VERSION " -ge 21 ] || [ " $DISTRO_MAJOR_VERSION " -ge 22 ] || [ " $DISTRO_MAJOR_VERSION " -ge 23 ] || [ " $DISTRO_MAJOR_VERSION " -ge 24 ] ; then
2022-04-11 16:47:01 -07:00
__apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1
else
__apt_get_install_noinput --allow-unauthenticated debian-archive-keyring &&
apt-key update && apt-get update || return 1
fi
fi
__apt_get_upgrade_noinput || return 1
fi
if [ " $_DISABLE_REPOS " -eq " $BS_FALSE " ] || [ " $_CUSTOM_REPO_URL " != "null" ] ; then
__check_dpkg_architecture || return 1
2022-07-27 13:25:02 -07:00
__install_saltstack_ubuntu_onedir_repository || return 1
2022-04-11 16:47:01 -07:00
fi
install_ubuntu_deps || return 1
}
2012-10-17 14:02:09 +01:00
install_ubuntu_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2016-08-03 12:14:25 +03:00
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2016-08-03 12:14:25 +03:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
2013-01-25 20:18:08 +00:00
fi
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2016-08-03 12:14:25 +03:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06: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
2016-08-05 15:43:25 +03:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
__apt_get_install_noinput ${ __PACKAGES } || return 1
2017-05-24 10:48:29 +03:00
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
2012-10-19 21:16:00 -07:00
install_ubuntu_git( ) {
2024-07-02 14:54:14 -06:00
## DGM Debugging
set -v
set -x
2016-04-11 15:27:04 -07:00
# Activate virtualenv before install
if [ " ${ _VIRTUALENV_DIR } " != "null" ] ; then
__activate_virtualenv || return 1
fi
2018-05-31 10:13:12 -04:00
if [ -n " $_PY_EXE " ] ; then
_PYEXE = ${ _PY_EXE }
else
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2018-05-31 10:13:12 -04:00
fi
2024-06-27 14:18:42 -06:00
## DGM this original code was then negated to "" originally, why was it not removed ?
## DGM # We can use --prefix on debian based ditributions
## DGM if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
## DGM _POST_NEON_PIP_INSTALL_ARGS="--target=/usr/lib/python3/dist-packages --install-option=--install-scripts=/usr/bin"
## DGM else
## DGM _POST_NEON_PIP_INSTALL_ARGS="--target=/usr/lib/python2.7/dist-packages --install-option=--install-scripts=/usr/bin"
## DGM fi
2024-02-08 09:28:56 -07:00
_POST_NEON_PIP_INSTALL_ARGS = ""
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
cd " ${ _SALT_GIT_CHECKOUT_DIR } " || return 1
2020-01-28 19:20:03 +00:00
2024-02-08 09:28:56 -07:00
# Account for new path for services files in later releases
if [ -d "pkg/common" ] ; then
_SERVICE_DIR = "pkg/common"
2014-02-16 22:01:31 +00:00
else
2024-02-08 09:28:56 -07:00
_SERVICE_DIR = "pkg"
2014-02-16 22:01:31 +00:00
fi
2017-05-24 10:48:29 +03:00
2024-02-08 09:28:56 -07:00
sed -i 's:/usr/bin:/usr/local/bin:g' " ${ _SERVICE_DIR } " /*.service
2013-03-23 11:55:45 +00:00
return 0
2024-02-08 09:28:56 -07:00
2012-10-19 21:16:00 -07:00
}
2022-07-27 13:25:02 -07:00
install_ubuntu_onedir( ) {
2022-04-11 16:47:01 -07:00
__PACKAGES = ""
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-master "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2022-04-11 16:47:01 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
__apt_get_install_noinput ${ __PACKAGES } || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2016-04-18 10:21:53 -06:00
install_ubuntu_stable_post( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; do
2016-04-18 10:21:53 -06:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2016-04-18 10:21:53 -06:00
2016-08-13 18:58:38 +03:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2016-04-18 10:21:53 -06:00
if [ -f /bin/systemctl ] ; then
# Using systemd
2024-06-28 17:04:56 -06:00
/bin/systemctl is-enabled salt-$fname .service > /dev/null 2>& 1 || (
/bin/systemctl preset salt-$fname .service > /dev/null 2>& 1 &&
/bin/systemctl enable salt-$fname .service > /dev/null 2>& 1
2016-04-18 10:21:53 -06:00
)
2017-05-26 16:49:43 +02:00
sleep 1
2016-05-16 09:48:08 -07:00
/bin/systemctl daemon-reload
2024-06-28 17:04:56 -06:00
elif [ -f /etc/init.d/salt-$fname ] ; then
update-rc.d salt-$fname defaults
2016-04-18 10:21:53 -06:00
fi
done
2017-05-24 10:48:29 +03:00
return 0
2016-04-18 10:21:53 -06:00
}
2013-01-25 23:41:57 +00:00
2016-08-13 18:58:38 +03:00
install_ubuntu_git_post( ) {
for fname in api master minion syndic; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2023-02-02 08:51:12 -08:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common "
else
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg "
fi
2016-12-21 10:20:03 -07:00
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 16 ] ; then
2023-02-02 08:51:12 -08:00
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
2015-05-03 15:43:58 +01:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2015-05-03 15:43:58 +01:00
2024-06-28 17:04:56 -06:00
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
2017-05-26 16:49:43 +02:00
sleep 1
2015-05-03 15:43:58 +01:00
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"
2024-06-28 17:04:56 -06: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 "
2023-02-02 08:51:12 -08:00
echodebug " Copying ${ _SERVICE_DIR } /salt- $fname .upstart to $_upstart_conf "
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .upstart " " $_upstart_conf "
2016-04-11 15:27:04 -07:00
# Set service to know about virtualenv
if [ " ${ _VIRTUALENV_DIR } " != "null" ] ; then
2024-06-28 17:04:56 -06:00
echo " SALT_USE_VIRTUALENV= ${ _VIRTUALENV_DIR } " > /etc/default/salt-${ fname }
2016-04-11 15:27:04 -07:00
fi
2015-09-05 11:11:44 +01:00
/sbin/initctl reload-configuration || return 1
2013-01-25 20:18:08 +00:00
fi
2013-02-08 11:56:03 +00:00
# No upstart support in Ubuntu!?
2017-06-12 15:25:52 -06:00
elif [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/salt- ${ fname } .init " ] ; then
2013-03-17 23:19:27 +00:00
echodebug "There's NO upstart support!?"
2017-06-12 15:25:52 -06:00
echodebug " Copying ${ _SALT_GIT_CHECKOUT_DIR } /pkg/salt- ${ fname } .init to /etc/init.d/salt- $fname "
__copyfile " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/salt- ${ fname } .init " " /etc/init.d/salt- $fname "
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2024-06-28 17:04:56 -06:00
update-rc.d salt-$fname defaults
2013-03-17 23:30:25 +00:00
else
2016-04-11 15:27:04 -07:00
echoerror " Neither upstart nor init.d was setup for salt- $fname "
2013-02-08 11:56:03 +00:00
fi
done
2017-05-24 10:48:29 +03:00
return 0
2013-02-08 11:56:03 +00:00
}
2013-02-16 10:04:25 +00:00
install_ubuntu_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2015-05-20 18:20:34 +01:00
# Ensure upstart configs / systemd units are loaded
2016-12-21 10:20:03 -07:00
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 16 ] ; then
2015-05-03 15:57:02 +01:00
systemctl daemon-reload
elif [ -f /sbin/initctl ] ; then
/sbin/initctl reload-configuration
fi
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-02-08 11:56:03 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-26 18:22:26 +00:00
2016-12-21 10:20:03 -07:00
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 16 ] ; then
2015-05-03 15:43:58 +01:00
echodebug " There's systemd support while checking salt- $fname "
2024-06-28 17:04:56 -06:00
systemctl stop salt-$fname > /dev/null 2>& 1
systemctl start salt-$fname .service && continue
2015-05-03 15:43:58 +01:00
# We failed to start the service, let's test the SysV code below
echodebug " Failed to start salt- $fname using systemd "
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2020-01-30 12:36:56 +00:00
journalctl -xe
fi
2015-05-03 15:43:58 +01:00
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
2024-06-28 17:04:56 -06:00
if status salt-$fname 2>/dev/null | grep -q running; then
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
2024-06-28 17:04:56 -06:00
start salt-$fname && continue
2013-07-26 21:19:04 -04:00
# 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
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
/etc/init.d/salt-$fname stop > /dev/null 2>& 1
/etc/init.d/salt-$fname start
2012-10-27 04:51:54 +01:00
done
2017-05-24 10:48:29 +03:00
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( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-08-23 23:28:09 +01:00
2014-02-20 13:01:07 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2015-05-03 15:43:58 +01:00
2016-12-21 10:20:03 -07:00
if [ -f /bin/systemctl ] && [ " $DISTRO_MAJOR_VERSION " -ge 16 ] ; then
2024-06-04 17:06:07 -06:00
__check_services_systemd salt-$fname || return 1
elif [ -f /etc/init.d/salt-$fname ] ; then
__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
2016-08-13 18:58:38 +03:00
2014-02-20 13:01:07 +00:00
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
#
2024-07-02 13:57:12 -06:00
## DGM __install_saltstack_debian_repository() {
## DGM ## DGM Debugging
## DGM set -v
## DGM set -x
## DGM
## DGM DEBIAN_RELEASE="$DISTRO_MAJOR_VERSION"
## DGM DEBIAN_CODENAME="$DISTRO_CODENAME"
## DGM
## DGM if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -ne 3 ]; then
## DGM echoerror "Python version is no longer supported, only Python 3"
## DGM return 1
## DGM fi
## DGM
## DGM # Install downloader backend for GPG keys fetching
## DGM __PACKAGES='wget'
## DGM
## DGM # Required as it is not installed by default on Debian 9+
## DGM if [ "$DISTRO_MAJOR_VERSION" -ge 9 ]; then
## DGM __PACKAGES="${__PACKAGES} gnupg2"
## DGM fi
## DGM
## DGM # Make sure https transport is available
## DGM if [ "$HTTP_VAL" = "https" ] ; then
## DGM __PACKAGES="${__PACKAGES} apt-transport-https ca-certificates"
## DGM fi
## DGM
## DGM ## DGM tornado appears to be missing in 3006.x pkg requirements
## DGM ## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
## DGM
## DGM # shellcheck disable=SC2086,SC2090
## DGM ## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
## DGM __apt_get_install_noinput ${__PACKAGES} || return 1
## DGM
## DGM SALTSTACK_DEBIAN_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/debian/${DEBIAN_RELEASE}/${__REPO_ARCH}/${STABLE_REV}"
## DGM echo "$__REPO_ARCH_DEB $SALTSTACK_DEBIAN_URL $DEBIAN_CODENAME main" > "/etc/apt/sources.list.d/salt.list"
## DGM
## DGM __apt_key_fetch "$SALTSTACK_DEBIAN_URL/SALT-PROJECT-GPG-PUBKEY-2023.gpg" || return 1
## DGM
## DGM __wait_for_apt apt-get update || return 1
## DGM }
2017-05-26 12:00:31 -06:00
2022-07-27 13:25:02 -07:00
__install_saltstack_debian_onedir_repository( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2022-07-22 12:41:34 -07:00
DEBIAN_RELEASE = " $DISTRO_MAJOR_VERSION "
2022-04-11 16:47:01 -07:00
DEBIAN_CODENAME = " $DISTRO_CODENAME "
2024-07-01 16:29:40 -06:00
echodebug " DGM Debian B checking, ONEDIR_REV , $ONEDIR_REV , "
2024-07-01 13:45:45 -06:00
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
2022-04-11 16:47:01 -07:00
fi
# Install downloader backend for GPG keys fetching
__PACKAGES = 'wget'
# Required as it is not installed by default on Debian 9+
if [ " $DISTRO_MAJOR_VERSION " -ge 9 ] ; then
__PACKAGES = " ${ __PACKAGES } gnupg2 "
fi
# Make sure https transport is available
if [ " $HTTP_VAL " = "https" ] ; then
__PACKAGES = " ${ __PACKAGES } apt-transport-https ca-certificates "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2022-04-11 16:47:01 -07:00
# shellcheck disable=SC2086,SC2090
2024-06-27 11:34:44 -06:00
## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
__apt_get_install_noinput ${ __PACKAGES } || return 1
2022-04-11 16:47:01 -07:00
2024-06-26 12:00:17 -06:00
# amd64 is just a part of repository URI
2024-07-02 13:57:12 -06:00
SALTSTACK_DEBIAN_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /debian/ ${ DEBIAN_RELEASE } / ${ __REPO_ARCH } / ${ ONEDIR_REV } "
2022-12-05 08:06:47 +00:00
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
2024-07-02 13:57:12 -06:00
SALTSTACK_DEBIAN_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /debian/ ${ DEBIAN_RELEASE } / ${ __REPO_ARCH } "
2022-12-05 08:06:47 +00:00
fi
2022-04-11 16:47:01 -07:00
echo " $__REPO_ARCH_DEB $SALTSTACK_DEBIAN_URL $DEBIAN_CODENAME main " > "/etc/apt/sources.list.d/salt.list"
2024-07-02 13:57:12 -06:00
__apt_key_fetch " ${ SALTSTACK_DEBIAN_URL } /SALT-PROJECT-GPG-PUBKEY-2023.gpg " || return 1
2022-04-11 16:47:01 -07:00
__wait_for_apt apt-get update || return 1
}
2024-07-02 13:57:12 -06:00
## DGM install_debian_deps() {
## DGM if [ "$_START_DAEMONS" -eq $BS_FALSE ]; then
## DGM echowarn "Not starting daemons on Debian based distributions is not working mostly because starting them is the default behaviour."
## DGM fi
## DGM
## DGM # No user interaction, libc6 restart services for example
## DGM export DEBIAN_FRONTEND=noninteractive
## DGM
## DGM __wait_for_apt apt-get update || return 1
## DGM
## DGM if [ "${_UPGRADE_SYS}" -eq $BS_TRUE ]; then
## DGM # Try to update GPG keys first if allowed
## DGM if [ "${_INSECURE_DL}" -eq $BS_TRUE ]; then
## DGM if [ "$DISTRO_MAJOR_VERSION" -ge 10 ]; then
## DGM __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1
## DGM else
## DGM __apt_get_install_noinput --allow-unauthenticated debian-archive-keyring &&
## DGM apt-key update && apt-get update || return 1
## DGM fi
## DGM fi
## DGM
## DGM __apt_get_upgrade_noinput || return 1
## DGM fi
## DGM
## DGM if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -ne 3 ]; then
## DGM echoerror "Python version is no longer supported, only Python 3"
## DGM return 1
## DGM fi
## DGM
## DGM # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813
## DGM __PACKAGES='procps pciutils'
## DGM
## DGM # YAML module is used for generating custom master/minion configs
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-yaml"
## DGM
## DGM ## DGM tornado appears to be missing in 3006.x pkg requirements
## DGM ## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
## DGM
## DGM # shellcheck disable=SC2086
## DGM ## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
## DGM __apt_get_install_noinput ${__PACKAGES} || return 1
## DGM
## DGM if [ "$_DISABLE_REPOS" -eq "$BS_FALSE" ] || [ "$_CUSTOM_REPO_URL" != "null" ]; then
## DGM __check_dpkg_architecture || return 1
## DGM __install_saltstack_debian_repository || return 1
## DGM fi
## DGM
## DGM if [ "${_EXTRA_PACKAGES}" != "" ]; then
## DGM echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}"
## DGM # shellcheck disable=SC2086
## DGM ## DGM __apt_get_install_noinput "${_EXTRA_PACKAGES}" || return 1
## DGM __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1
## DGM fi
## DGM
## DGM return 0
## DGM }
2014-02-25 19:21:39 +00:00
2022-07-27 13:25:02 -07:00
install_debian_onedir_deps( ) {
2024-06-26 16:10:43 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
if [ " $_START_DAEMONS " -eq $BS_FALSE ] ; then
2022-07-22 11:52:37 -07:00
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
__wait_for_apt apt-get update || return 1
2024-06-28 17:04:56 -06:00
if [ " ${ _UPGRADE_SYS } " -eq $BS_TRUE ] ; then
2022-07-22 11:52:37 -07:00
# Try to update GPG keys first if allowed
2024-06-28 17:04:56 -06:00
if [ " ${ _INSECURE_DL } " -eq $BS_TRUE ] ; then
2022-07-22 11:52:37 -07:00
if [ " $DISTRO_MAJOR_VERSION " -ge 10 ] ; then
__apt_get_install_noinput --allow-unauthenticated debian-archive-keyring && apt-get update || return 1
else
__apt_get_install_noinput --allow-unauthenticated debian-archive-keyring &&
apt-key update && apt-get update || return 1
fi
fi
__apt_get_upgrade_noinput || return 1
fi
2024-06-26 12:00:17 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
2022-07-22 11:52:37 -07:00
fi
# Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813
__PACKAGES = 'procps pciutils'
# YAML module is used for generating custom master/minion configs
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -yaml "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2022-07-22 11:52:37 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
__apt_get_install_noinput ${ __PACKAGES } || return 1
2022-07-22 11:52:37 -07:00
if [ " $_DISABLE_REPOS " -eq " $BS_FALSE " ] || [ " $_CUSTOM_REPO_URL " != "null" ] ; then
__check_dpkg_architecture || return 1
2022-07-27 13:25:02 -07:00
__install_saltstack_debian_onedir_repository || return 1
2022-07-22 11:52:37 -07:00
fi
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __apt_get_install_noinput "${_EXTRA_PACKAGES}" || return 1
__apt_get_install_noinput ${ _EXTRA_PACKAGES } || return 1
2022-07-22 11:52:37 -07:00
fi
return 0
}
2019-10-29 14:56:03 -04:00
install_debian_git_pre( ) {
if ! __check_command_exists git; then
__apt_get_install_noinput git || return 1
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSECURE_DL " -eq $BS_FALSE ] && [ " ${ _SALT_REPO_URL %% : //* } " = "https" ] ; then
2019-10-29 14:56:03 -04:00
__apt_get_install_noinput ca-certificates
fi
__git_clone_and_checkout || return 1
# Let's trigger config_salt()
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
_TEMP_CONFIG_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /conf/ "
CONFIG_SALT_FUNC = "config_salt"
fi
}
2012-12-11 16:31:54 +00:00
install_debian_git_deps( ) {
2024-07-02 13:57:12 -06:00
install_debian_onedir_deps || return 1
2020-01-30 12:36:56 +00:00
install_debian_git_pre || return 1
2013-01-18 02:42:49 +00:00
2024-06-26 12:00:17 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
2020-01-28 19:20:03 +00:00
fi
2024-02-02 17:57:31 -07:00
__PACKAGES = " python ${ PY_PKG_VER } -dev python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools gcc "
echodebug " install_debian_git_deps() Installing ${ __PACKAGES } "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-02-02 17:57:31 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
__apt_get_install_noinput ${ __PACKAGES } || return 1
2013-03-06 22:05:31 +00:00
return 0
2012-12-11 16:31:54 +00:00
}
2016-03-03 10:12:50 +02:00
install_debian_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2016-08-01 13:34:51 +03:00
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2016-08-01 13:34:51 +03:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
2013-01-25 20:18:08 +00:00
fi
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2016-08-01 13:34:51 +03:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06: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
2016-08-01 13:34:51 +03:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __apt_get_install_noinput "${__PACKAGES}" || return 1
__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
}
2024-06-28 17:04:56 -06:00
install_debian_11_git_deps( ) {
install_debian_git_deps || return 1
return 0
}
install_debian_12_git_deps( ) {
install_debian_git_deps || return 1
return 0
}
2013-01-25 02:16:41 +00:00
install_debian_git( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2018-06-06 17:02:27 -04:00
if [ -n " $_PY_EXE " ] ; then
_PYEXE = ${ _PY_EXE }
else
2024-02-02 17:57:31 -07:00
## _PYEXE=python
echoerror "Python 2 is no longer supported, only Py3 packages"
return 1
2018-06-06 17:02:27 -04:00
fi
2024-06-26 12:00:17 -06:00
# We can use --prefix on debian based ditributions
2024-06-27 14:18:42 -06:00
## DGM this original code was then negated to "" originally, why was it not removed ?
## DGM # We can use --prefix on debian based ditributions
## DGM if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -eq 3 ]; then
## DGM _POST_NEON_PIP_INSTALL_ARGS="--target=/usr/lib/python3/dist-packages --install-option=--install-scripts=/usr/bin"
## DGM else
## DGM _POST_NEON_PIP_INSTALL_ARGS="--target=/usr/lib/python2.7/dist-packages --install-option=--install-scripts=/usr/bin"
## DGM fi
_POST_NEON_PIP_INSTALL_ARGS = ""
2023-02-02 13:59:20 -08:00
2024-06-26 12:00:17 -06:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
cd " ${ _SALT_GIT_CHECKOUT_DIR } " || return 1
2023-02-02 13:59:20 -08:00
2024-06-26 12:00:17 -06:00
# Account for new path for services files in later releases
if [ -d "pkg/common" ] ; then
_SERVICE_DIR = "pkg/common"
2024-02-02 17:57:31 -07:00
else
2024-06-26 12:00:17 -06:00
_SERVICE_DIR = "pkg"
2020-01-28 19:20:03 +00:00
fi
2024-06-26 12:00:17 -06:00
sed -i 's:/usr/bin:/usr/local/bin:g' " ${ _SERVICE_DIR } " /*.service
return 0
2012-10-18 19:54:05 -07:00
}
2012-12-20 09:58:17 -08:00
2024-06-28 17:04:56 -06:00
install_debian_11_git( ) {
install_debian_git || return 1
return 0
}
install_debian_12_git( ) {
install_debian_git || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_debian_onedir( ) {
2022-04-11 16:47:01 -07:00
__PACKAGES = ""
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-master "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2022-04-11 16:47:01 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## __apt_get_install_noinput "${__PACKAGES}" || return 1
__apt_get_install_noinput ${ __PACKAGES } || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2012-12-20 09:58:17 -08:00
install_debian_git_post( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2016-04-27 11:36:04 +03:00
[ " $fname " = "api" ] && \
2024-06-28 17:04:56 -06:00
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ " $fname " = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ " $fname " = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ " $fname " = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2023-02-02 08:51:12 -08:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common "
else
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg "
fi
2016-04-27 11:36:04 +03:00
# Configure SystemD for Debian 8 "Jessie" and later
2015-03-16 08:30:47 +11:00
if [ -f /bin/systemctl ] ; then
2024-06-28 17:04:56 -06:00
if [ ! -f /lib/systemd/system/salt-${ fname } .service ] || \
{ [ -f /lib/systemd/system/salt-${ fname } .service ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ] ; } ; then
2023-02-02 08:51:12 -08:00
if [ -f " ${ _SERVICE_DIR } /salt- ${ fname } .service " ] ; then
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " /lib/systemd/system
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .environment " " /etc/default/salt- ${ fname } "
2016-04-27 11:36:04 +03:00
else
# workaround before adding Debian-specific unit files to the Salt main repo
2023-02-02 08:51:12 -08:00
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " /lib/systemd/system
2024-06-28 17:04:56 -06:00
sed -i -e '/^Type/ s/notify/simple/' /lib/systemd/system/salt-${ fname } .service
2016-04-27 11:36:04 +03:00
fi
2015-03-16 08:30:47 +11:00
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
2016-04-27 11:36:04 +03:00
[ " $fname " = "api" ] && continue
2015-03-16 08:30:47 +11:00
2016-04-27 11:36:04 +03:00
/bin/systemctl enable " salt- ${ fname } .service "
2024-06-28 17:04:56 -06:00
SYSTEMD_RELOAD = $BS_TRUE
2015-03-16 08:30:47 +11:00
2024-07-01 13:45:45 -06:00
## DGM # Install initscripts for Debian 7 "Wheezy"
## DGM elif [ ! -f "/etc/init.d/salt-$fname" ] || \
## DGM { [ -f "/etc/init.d/salt-$fname" ] && [ "$_FORCE_OVERWRITE" -eq $BS_TRUE ]; }; then
## DGM __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.init" "/etc/init.d/salt-${fname}"
## DGM __copyfile "${_SALT_GIT_CHECKOUT_DIR}/pkg/deb/salt-${fname}.environment" "/etc/default/salt-${fname}"
2016-04-27 11:36:04 +03:00
2024-07-01 13:45:45 -06:00
## DGM if [ ! -f "/etc/init.d/salt-${fname}" ]; then
## DGM echowarn "The init script for salt-${fname} was not found, skipping it..."
## DGM continue
## DGM fi
2016-04-27 11:36:04 +03:00
2024-07-01 13:45:45 -06:00
## DGM chmod +x "/etc/init.d/salt-${fname}"
2015-03-16 08:30:47 +11:00
2024-07-01 13:45:45 -06:00
## DGM # Skip salt-api since the service should be opt-in and not necessarily started on boot
## DGM [ "$fname" = "api" ] && continue
## DGM update-rc.d "salt-${fname}" defaults
2015-03-16 08:30:47 +11:00
fi
2013-02-08 11:59:06 +00:00
done
}
2022-01-07 10:53:57 +01:00
install_debian_2021_post( ) {
# Kali 2021 (debian derivative) disables all network services by default
# Using archlinux post function to enable salt systemd services
install_arch_linux_post || return 1
return 0
}
2013-02-16 10:04:25 +00:00
install_debian_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return 0
2013-10-24 16:49:04 +02:00
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-02-08 11:59:06 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2016-08-13 18:58:38 +03:00
2015-03-16 08:30:47 +11:00
if [ -f /bin/systemctl ] ; then
2024-06-26 12:00:17 -06:00
# Debian 8 and above uses systemd
2024-06-28 17:04:56 -06:00
/bin/systemctl stop salt-$fname > /dev/null 2>& 1
/bin/systemctl start salt-$fname .service && continue
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2020-01-30 12:36:56 +00:00
journalctl -xe
fi
2024-06-28 17:04:56 -06:00
elif [ -f /etc/init.d/salt-$fname ] ; then
2015-03-16 08:30:47 +11:00
# Still in SysV init
2024-06-28 17:04:56 -06:00
/etc/init.d/salt-$fname stop > /dev/null 2>& 1
/etc/init.d/salt-$fname start
2015-03-16 08:30:47 +11:00
fi
2012-12-20 09:58:17 -08:00
done
}
2014-03-10 12:11:20 +00:00
install_debian_check_services( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-08-23 23:28:09 +01:00
2014-03-10 12:11:20 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2016-08-01 13:34:51 +03:00
2015-03-16 08:30:47 +11:00
if [ -f /bin/systemctl ] ; then
2024-06-28 17:04:56 -06:00
__check_services_systemd salt-$fname || return 1
elif [ -f /etc/init.d/salt-$fname ] ; then
__check_services_debian salt-$fname || return 1
2015-03-16 08:30:47 +11:00
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
#
2015-10-01 23:16:59 +02:00
2023-04-21 12:45:35 -07:00
__install_saltstack_fedora_onedir_repository( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2023-04-21 12:45:35 -07:00
if [ " $ITYPE " = "stable" ] ; then
2023-04-23 19:57:49 -07:00
REPO_REV = " $ONEDIR_REV "
2023-04-21 12:45:35 -07:00
else
2023-04-23 19:57:49 -07:00
REPO_REV = "latest"
2023-04-21 12:45:35 -07:00
fi
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
2023-04-21 12:45:35 -07:00
fi
2024-02-08 15:00:59 -07:00
__PY_VERSION_REPO = "py3"
2024-02-08 09:28:56 -07:00
2023-04-22 10:39:19 -07:00
GPG_KEY = "SALT-PROJECT-GPG-PUBKEY-2023.pub"
2023-04-21 12:45:35 -07:00
2023-04-22 10:39:19 -07:00
REPO_FILE = "/etc/yum.repos.d/salt.repo"
2023-04-21 12:45:35 -07:00
2024-06-28 17:04:56 -06:00
if [ ! -s " $REPO_FILE " ] || [ " $_FORCE_OVERWRITE " -eq $BS_TRUE ] ; then
2023-04-23 19:57:49 -07:00
FETCH_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /fedora/ ${ DISTRO_MAJOR_VERSION } / ${ CPU_ARCH_L } / ${ ONEDIR_REV } "
2023-04-21 12:45:35 -07:00
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
2024-07-01 13:45:45 -06:00
## DGM FETCH_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_NIGHTLY_DIR}/${__PY_VERSION_REPO}/fedora/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/"
2023-04-23 19:57:49 -07:00
FETCH_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /fedora/ ${ DISTRO_MAJOR_VERSION } / ${ CPU_ARCH_L } / "
2023-04-21 12:45:35 -07:00
fi
2023-04-21 14:22:13 -07:00
2023-04-23 19:57:49 -07:00
__fetch_url " ${ REPO_FILE } " " ${ FETCH_URL } .repo "
2023-04-21 14:22:13 -07:00
2023-04-23 19:57:49 -07:00
__rpm_import_gpg " ${ FETCH_URL } / ${ GPG_KEY } " || return 1
2023-04-21 12:45:35 -07:00
yum clean metadata || return 1
2023-04-23 19:57:49 -07:00
elif [ " $REPO_REV " != "latest" ] ; then
2023-04-21 12:45:35 -07:00
echowarn "salt.repo already exists, ignoring salt version argument."
2023-04-23 19:57:49 -07:00
echowarn " Use -F (forced overwrite) to install $REPO_REV . "
2023-04-21 12:45:35 -07:00
fi
return 0
}
2012-10-27 07:31:14 +01:00
install_fedora_deps( ) {
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2018-08-15 16:38:00 +02:00
dnf -y update || return 1
fi
2018-08-14 19:21:14 +02:00
__PACKAGES = " ${ __PACKAGES : = } "
2024-06-26 12:00:17 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
2020-02-03 17:21:30 +00:00
return 1
2018-08-09 12:39:30 +02:00
fi
2014-02-16 21:38:15 +00:00
2020-02-03 17:21:30 +00:00
# Salt on Fedora is Py3
PY_PKG_VER = 3
2024-02-08 16:57:24 -07:00
## DGM can find no dnf-utils in Fedora packaging archives and yum-utils EL7 and F30, none after
## DGM but find it on 8 and 9 Centos Stream
2024-06-25 16:54:18 -06:00
__PACKAGES = " ${ __PACKAGES } dnf-utils libyaml procps-ng python ${ PY_PKG_VER } -crypto python ${ PY_PKG_VER } -jinja2 "
2018-08-09 21:03:18 +02:00
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -msgpack python ${ PY_PKG_VER } -requests python ${ PY_PKG_VER } -zmq "
2020-02-03 15:58:04 +00:00
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -m2crypto python ${ PY_PKG_VER } -pyyaml "
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -systemd "
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 } "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2018-08-15 16:38:00 +02:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __dnf_install_noinput "${__PACKAGES}" "${_EXTRA_PACKAGES}" || return 1
__dnf_install_noinput ${ __PACKAGES } ${ _EXTRA_PACKAGES } || return 1
2018-08-15 16:38:00 +02:00
2013-03-23 11:55:45 +00:00
return 0
2012-10-27 07:31:14 +01:00
}
2024-07-02 13:57:12 -06:00
## DGM install_fedora_stable() {
## DGM ## DGM Debugging
## DGM set -v
## DGM set -x
## DGM
## DGM if [ "$STABLE_REV" = "latest" ]; then
## DGM __SALT_VERSION=""
## DGM else
## DGM __SALT_VERSION="$(dnf list --showduplicates salt | grep "$STABLE_REV" | head -n 1 | awk '{print $2}')"
## DGM # shellcheck disable=SC2268
## DGM if [ "x${__SALT_VERSION}" = "x" ]; then
## DGM echoerror "Could not find a stable install for Salt ${STABLE_REV}"
## DGM exit 1
2024-06-28 17:04:56 -06:00
## DGM fi
2024-07-02 13:57:12 -06:00
## DGM echoinfo "Installing Stable Package Version ${__SALT_VERSION}"
## DGM __SALT_VERSION="-${__SALT_VERSION}"
2024-06-28 17:04:56 -06:00
## DGM fi
2024-07-02 13:57:12 -06:00
## DGM __PACKAGES=""
## DGM
## DGM if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then
## DGM __PACKAGES="${__PACKAGES} salt-cloud${__SALT_VERSION}"
## DGM fi
## DGM if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then
## DGM __PACKAGES="${__PACKAGES} salt-master${__SALT_VERSION}"
## DGM fi
## DGM if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then
## DGM __PACKAGES="${__PACKAGES} salt-minion${__SALT_VERSION}"
## DGM fi
## DGM if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then
## DGM __PACKAGES="${__PACKAGES} salt-syndic${__SALT_VERSION}"
## DGM fi
## DGM
## DGM ## DGM tornado appears to be missing in 3006.x pkg requirements
## DGM ## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
## DGM
## DGM # shellcheck disable=SC2086
## DGM ## DGM __dnf_install_noinput "${__PACKAGES}" || return 1
## DGM __dnf_install_noinput ${__PACKAGES} || return 1
## DGM
## DGM ## DGM __python="python3"
## DGM if ! __check_command_exists python3; then
## DGM echoerror "Could not find a python3 binary?!"
## DGM return 1
## DGM fi
## DGM
## DGM ## DGM if [ "${_POST_NEON_INSTALL}" -eq $BS_FALSE ]; then
## DGM ## DGM __check_pip_allowed "You need to allow pip based installations (-P) for Tornado <5.0 in order to install Salt"
## DGM ## DGM __installed_tornado_rpm=$(rpm -qa | grep python${PY_PKG_VER}-tornado)
## DGM ## DGM if [ -n "${__installed_tornado_rpm}" ]; then
## DGM ## DGM echodebug "Removing system package ${__installed_tornado_rpm}"
## DGM ## DGM rpm -e --nodeps "${__installed_tornado_rpm}" || return 1
## DGM ## DGM fi
## DGM ## DGM __get_site_packages_dir_code=$(cat << EOM
## DGM ## DGM import site
## DGM ## DGM print([d for d in site.getsitepackages() if d.startswith('/usr/lib/python')][0])
## DGM ## DGM EOM
## DGM ## DGM )
## DGM ## DGM __target_path=$(${__python} -c "${__get_site_packages_dir_code}")
## DGM ## DGM echodebug "Running '${__python}' -m pip install --target ${__target_path} 'tornado<5.0'"
## DGM ## DGM "${__python}" -m pip install --target "${__target_path}" "tornado<5" || return 1
## DGM ## DGM fi
## DGM
## DGM return 0
## DGM }
2016-08-05 15:43:25 +03:00
2024-07-02 13:57:12 -06:00
## DGM install_fedora_stable_post() {
## DGM for fname in api master minion syndic; do
## DGM # Skip salt-api since the service should be opt-in and not necessarily started on boot
## DGM [ $fname = "api" ] && continue
## DGM
## DGM # Skip if not meant to be installed
## DGM [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue
## DGM [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue
## DGM [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue
## DGM
## DGM systemctl is-enabled salt-$fname.service || (systemctl preset salt-$fname.service && systemctl enable salt-$fname.service)
## DGM sleep 1
## DGM systemctl daemon-reload
## DGM done
## DGM }
2014-02-01 04:56:47 -07:00
2012-10-27 07:31:14 +01:00
install_fedora_git_deps( ) {
2024-06-26 12:00:17 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2018-08-09 12:39:30 +02:00
fi
2016-11-29 18:09:48 +02:00
2020-02-01 18:11:56 +00:00
__PACKAGES = ""
if ! __check_command_exists ps; then
__PACKAGES = " ${ __PACKAGES } procps-ng "
fi
2016-01-25 09:00:32 -05:00
if ! __check_command_exists git; then
2018-08-15 16:38:00 +02:00
__PACKAGES = " ${ __PACKAGES } git "
2015-04-30 12:12:22 +01:00
fi
2020-02-01 18:11:56 +00:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2020-02-01 18:11:56 +00:00
if [ -n " ${ __PACKAGES } " ] ; then
2020-02-03 15:58:04 +00:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __dnf_install_noinput "${__PACKAGES}" || return 1
__dnf_install_noinput ${ __PACKAGES } || return 1
2020-02-01 18:11:56 +00:00
__PACKAGES = ""
fi
2020-01-28 19:20:03 +00:00
__git_clone_and_checkout || return 1
2024-06-28 17:04:56 -06:00
__PACKAGES = " python ${ PY_PKG_VER } -devel python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools gcc gcc-c++ "
2024-06-27 14:18:42 -06:00
# shellcheck disable=SC2086
## DGM __dnf_install_noinput "${__PACKAGES}" || return 1
__dnf_install_noinput ${ __PACKAGES } || return 1
2015-05-01 14:30:55 +01:00
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
2016-03-07 11:38:28 +02: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( ) {
2018-08-09 12:39:30 +02:00
if [ " ${ _PY_EXE } " != "" ] ; then
_PYEXE = ${ _PY_EXE }
echoinfo " Using the following python version: ${ _PY_EXE } to install salt "
else
2024-02-02 17:57:31 -07:00
## DGM _PYEXE='python2'
echoerror "Python 2 is no longer supported, only Py3 packages"
return 1
2018-08-09 12:39:30 +02:00
fi
2024-06-28 17:04:56 -06:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
2013-03-23 11:55:45 +00:00
return 0
2024-06-28 17:04:56 -06:00
2012-10-27 07:31:14 +01:00
}
install_fedora_git_post( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2023-02-02 10:12:59 -08:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common "
else
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/rpm "
fi
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
2012-10-27 07:31:14 +01:00
2022-04-09 15:07:39 +01:00
# Salt executables are located under `/usr/local/bin/` on Fedora 36+
2022-12-05 12:48:23 -08:00
#if [ "${DISTRO_VERSION}" -ge 36 ]; then
# sed -i -e 's:/usr/bin/:/usr/local/bin/:g' /lib/systemd/system/salt-*.service
#fi
2022-04-09 15:07:39 +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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2024-06-28 17:04:56 -06:00
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
2017-05-26 16:49:43 +02:00
sleep 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( ) {
2024-06-28 17:04:56 -06:00
[ $_START_DAEMONS -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2013-02-08 12:01:50 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-08 12:01:50 +00:00
2024-06-28 17:04:56 -06:00
systemctl stop salt-$fname > /dev/null 2>& 1
systemctl start salt-$fname .service && continue
2020-01-30 12:36:56 +00:00
echodebug " Failed to start salt- $fname using systemd "
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2020-01-30 12:36:56 +00:00
journalctl -xe
fi
2012-10-27 07:31:14 +01:00
done
}
2014-02-20 11:00:12 +00:00
install_fedora_check_services( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-08-23 23:28:09 +01:00
2014-02-20 11:44:34 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2016-08-13 18:58:38 +03:00
2024-06-28 17:04:56 -06:00
__check_services_systemd salt-$fname || return 1
2014-02-20 11:44:34 +00:00
done
2016-08-13 18:58:38 +03:00
2014-02-20 11:44:34 +00:00
return 0
2014-02-20 11:00:12 +00:00
}
2023-04-21 12:45:35 -07:00
install_fedora_onedir_deps( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2023-04-21 12:45:35 -07:00
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
yum -y update || return 1
fi
if [ " $_DISABLE_REPOS " -eq " $BS_TRUE " ] && [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ] ; then
echowarn "Detected -r or -R option while installing Salt packages for Python 3."
echowarn "Python 3 packages for older Salt releases requires the EPEL repository to be installed."
echowarn "Installing the EPEL repository automatically is disabled when using the -r or -R options."
fi
if [ " $_DISABLE_REPOS " -eq " $BS_FALSE " ] ; then
__install_saltstack_fedora_onedir_repository || return 1
fi
# If -R was passed, we need to configure custom repo url with rsync-ed packages
2024-02-08 09:28:56 -07:00
# Which is still handled in __install_saltstack_rhel_onedir_repository. This call has
2023-04-21 12:45:35 -07:00
# its own check in case -r was passed without -R.
if [ " $_CUSTOM_REPO_URL " != "null" ] ; then
__install_saltstack_fedora_onedir_repository || return 1
fi
2024-02-08 16:57:24 -07:00
## DGM can find no dnf-utils in Fedora packaging archives and yum-utils EL7 and F30, none after
2024-06-25 15:56:18 -06:00
## DGM but find it on 8 and 9 Centos Stream also EL9 doesn't have propcs
2024-06-25 16:54:18 -06:00
## DGM if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
## DGM __PACKAGES="dnf-utils chkconfig"
## DGM else
## DGM __PACKAGES="yum-utils chkconfig"
## DGM fi
2024-02-08 16:57:24 -07:00
2024-06-25 16:54:18 -06:00
## DGM __PACKAGES="${__PACKAGES} procps"
2024-06-25 15:56:18 -06:00
2024-06-25 16:54:18 -06:00
__PACKAGES = "dnf-utils chkconfig procps-ng"
2024-06-25 15:56:18 -06:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2023-04-21 12:45:35 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1
__yum_install_noinput ${ _EXTRA_PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
fi
return 0
}
2023-03-30 12:57:20 -07:00
install_fedora_onedir( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
STABLE_REV = $ONEDIR_REV
2023-04-21 12:45:35 -07:00
#install_fedora_stable || return 1
__PACKAGES = ""
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-master "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2023-04-21 12:45:35 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2023-03-30 12:57:20 -07:00
return 0
}
2023-03-31 16:00:31 -07:00
install_fedora_onedir_post( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
STABLE_REV = $ONEDIR_REV
2024-07-02 13:57:12 -06:00
## DGM install_fedora_stable_post || return 1
## DGM this was the only caller to install_fedora_stable_post, so moved it here
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
[ $fname = "api" ] && continue
# Skip if not meant to be installed
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
sleep 1
systemctl daemon-reload
done
2023-03-31 16:00:31 -07:00
return 0
}
2024-07-02 13:57:12 -06: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
#
2022-07-27 13:25:02 -07:00
__install_saltstack_rhel_onedir_repository( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2022-04-11 16:47:01 -07:00
if [ " $ITYPE " = "stable" ] ; then
2022-07-27 13:25:02 -07:00
repo_rev = " $ONEDIR_REV "
2022-04-11 16:47:01 -07:00
else
repo_rev = "latest"
fi
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2022-04-11 16:47:01 -07:00
fi
# Avoid using '$releasever' variable for yum.
# Instead, this should work correctly on all RHEL variants.
2022-07-27 13:25:02 -07:00
base_url = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /redhat/ ${ DISTRO_MAJOR_VERSION } /\$basearch/ ${ ONEDIR_REV } / "
2022-12-05 08:25:59 +00:00
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
base_url = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /redhat/ ${ DISTRO_MAJOR_VERSION } /\$basearch/ "
fi
2024-02-08 09:28:56 -07:00
gpg_key = "SALT-PROJECT-GPG-PUBKEY-2023.pub"
2022-04-11 16:47:01 -07:00
gpg_key_urls = ""
for key in $gpg_key ; do
gpg_key_urls = $( printf " ${ base_url } ${ key } ,%s " " $gpg_key_urls " )
done
repo_file = "/etc/yum.repos.d/salt.repo"
2024-06-28 17:04:56 -06:00
if [ ! -s " $repo_file " ] || [ " $_FORCE_OVERWRITE " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
cat <<_eof > "$repo_ file"
[ saltstack]
name = SaltStack ${ repo_rev } Release Channel for RHEL/CentOS \$ releasever
baseurl = ${ base_url }
skip_if_unavailable = True
gpgcheck = 1
gpgkey = ${ gpg_key_urls }
enabled = 1
enabled_metadata = 1
_eof
2022-09-01 13:05:48 -07:00
fetch_url = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /redhat/ ${ DISTRO_MAJOR_VERSION } / ${ CPU_ARCH_L } / ${ ONEDIR_REV } / "
2022-12-05 08:25:59 +00:00
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
fetch_url = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /redhat/ ${ DISTRO_MAJOR_VERSION } / ${ CPU_ARCH_L } / "
fi
2022-04-11 16:47:01 -07:00
for key in $gpg_key ; do
__rpm_import_gpg " ${ fetch_url } ${ key } " || return 1
done
yum clean metadata || return 1
elif [ " $repo_rev " != "latest" ] ; then
echowarn "salt.repo already exists, ignoring salt version argument."
echowarn " Use -F (forced overwrite) to install $repo_rev . "
fi
return 0
}
2024-07-01 13:45:45 -06:00
2014-06-16 09:39:30 +01:00
install_centos_stable_deps( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2016-07-19 15:43:12 +03:00
yum -y update || return 1
fi
2018-06-06 14:55:45 -04:00
if [ " $_DISABLE_REPOS " -eq " $BS_TRUE " ] && [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ] ; then
2020-06-18 13:06:47 -06:00
echowarn "Detected -r or -R option while installing Salt packages for Python 3."
echowarn "Python 3 packages for older Salt releases requires the EPEL repository to be installed."
echowarn "Installing the EPEL repository automatically is disabled when using the -r or -R options."
2018-06-06 14:55:45 -04:00
fi
2018-06-05 15:35:48 -04:00
2018-06-06 14:55:45 -04:00
if [ " $_DISABLE_REPOS " -eq " $BS_FALSE " ] ; then
2024-06-28 17:04:56 -06:00
echoerror "old-stable packages are no longer supported and are End-Of-Life."
return 1
2016-04-18 11:57:24 -06:00
fi
2014-10-20 20:44:16 +01:00
2016-06-09 11:18:30 -06:00
# If -R was passed, we need to configure custom repo url with rsync-ed packages
2024-02-08 09:28:56 -07:00
# Which is still handled in __install_saltstack_rhel_onedir_repository. This call has
2016-06-09 11:18:30 -06:00
# its own check in case -r was passed without -R.
if [ " $_CUSTOM_REPO_URL " != "null" ] ; then
2024-02-08 09:28:56 -07:00
__install_saltstack_rhel_onedir_repository || return 1
2016-06-09 11:18:30 -06:00
fi
2024-06-26 14:14:24 -06:00
## DGM ## DGM can find no dnf-utils in Fedora packaging archives and yum-utils EL7 and F30, none after
## DGM ## DGM but find it on 8 and 9 Centos Stream, and Alma 8 & 9 but versions we are using doesn't have them
## DGM ## DGM also EL9 doesn't have propcs and probably don't need these packages since using onedir
## DGM ## DGM if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
## DGM ## DGM __PACKAGES="dnf-utils chkconfig"
## DGM ## DGM else
## DGM ## DGM __PACKAGES="yum-utils chkconfig"
## DGM ## DGM fi
2024-02-09 11:39:42 -07:00
2024-06-26 14:14:24 -06:00
## DGM ## DGM __PACKAGES="${__PACKAGES} procps"
## DGM __PACKAGES="yum-utils chkconfig procps-ng"
## DGM Trying original
2024-06-26 16:45:14 -06:00
### if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
### __PACKAGES="dnf-utils chkconfig"
### else
### __PACKAGES="yum-utils chkconfig"
### fi
2024-06-25 16:54:18 -06:00
2024-06-26 16:45:14 -06:00
### __PACKAGES="${__PACKAGES} procps"
2024-06-28 11:21:30 -06:00
__PACKAGES = "yum-utils chkconfig procps-ng findutils"
2024-06-25 15:56:18 -06:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2016-07-19 15:43:12 +03:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2016-07-19 15:43:12 +03:00
2016-11-22 12:10:02 +02:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1
__yum_install_noinput ${ _EXTRA_PACKAGES } || return 1
2016-11-22 12:10:02 +02: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( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2016-07-19 15:43:12 +03:00
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2016-07-19 15:43:12 +03:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
2013-01-26 12:01:46 +00:00
fi
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2016-07-19 15:43:12 +03:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2015-02-06 15:00:52 +01:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
2013-01-26 12:01:46 +00:00
fi
2015-03-12 04:00:24 -07:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2016-07-19 15:43:12 +03:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2016-07-19 15:43:12 +03:00
2023-03-15 17:41:00 -07:00
# Workaround for 3.11 broken on CentOS Stream 8.x
# Re-install Python 3.6
_py_version = $( ${ _PY_EXE } -c "import sys; print('{0}.{1}'.format(*sys.version_info))" )
if [ " $DISTRO_MAJOR_VERSION " -eq 8 ] && [ " ${ _py_version } " = "3.11" ] ; then
__yum_install_noinput python3
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( ) {
2016-07-18 13:46:35 +03:00
SYSTEMD_RELOAD = $BS_FALSE
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2016-07-18 13:46:35 +03:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-08 12:07:11 +00:00
2016-07-18 13:46:35 +03:00
if [ -f /bin/systemctl ] ; then
2024-06-28 17:04:56 -06:00
/bin/systemctl is-enabled salt-${ fname } .service > /dev/null 2>& 1 || (
/bin/systemctl preset salt-${ fname } .service > /dev/null 2>& 1 &&
/bin/systemctl enable salt-${ fname } .service > /dev/null 2>& 1
2014-07-20 19:17:15 +01:00
)
2016-07-18 13:46:35 +03:00
SYSTEMD_RELOAD = $BS_TRUE
elif [ -f " /etc/init.d/salt- ${ fname } " ] ; then
2024-06-28 17:04:56 -06:00
/sbin/chkconfig salt-${ fname } on
2013-02-08 12:07:11 +00:00
fi
done
2016-07-18 13:46:35 +03:00
2024-06-28 17:04:56 -06:00
if [ " $SYSTEMD_RELOAD " -eq $BS_TRUE ] ; then
2016-07-18 13:46:35 +03:00
/bin/systemctl daemon-reload
fi
return 0
2013-02-08 12:07:11 +00:00
}
2013-01-27 18:11:30 +00:00
install_centos_git_deps( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2024-06-27 14:18:42 -06:00
2022-12-21 09:47:22 -08:00
# First try stable deps then fall back to onedir deps if that one fails
# if we're installing on a Red Hat based host that doesn't have the classic
# package repos available.
2022-12-21 10:40:46 -08:00
# Set ONEDIR_REV to STABLE_REV in case we
# end up calling install_centos_onedir_deps
2024-06-28 17:04:56 -06:00
ONEDIR_REV = ${ STABLE_REV }
2024-06-26 14:14:24 -06:00
install_centos_onedir_deps || return 1
2017-04-17 17:37:38 -04:00
2024-06-28 17:04:56 -06:00
if [ " $_INSECURE_DL " -eq $BS_FALSE ] && [ " ${ _SALT_REPO_URL %% : //* } " = "https" ] ; then
2017-05-08 11:39:47 +03:00
__yum_install_noinput ca-certificates || return 1
2016-11-29 18:09:48 +02:00
fi
2016-01-25 09:00:32 -05:00
if ! __check_command_exists git; then
2016-07-19 15:43:12 +03:00
__yum_install_noinput git || return 1
2014-06-21 13:21:35 +01:00
fi
2015-05-01 16:42:55 +01:00
2016-07-19 15:43:12 +03:00
__git_clone_and_checkout || return 1
2019-10-30 12:16:02 -04:00
__PACKAGES = ""
2020-01-30 12:36:56 +00:00
2018-06-05 15:35:48 -04:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ] ; then
2024-06-27 14:18:42 -06:00
# Packages are named python3-<whatever>
PY_PKG_VER = 3
__PACKAGES = " ${ __PACKAGES } python3 "
2018-06-05 15:35:48 -04:00
else
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
fi
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -devel python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools gcc "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-02-02 17:57:31 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2020-01-30 12:36:56 +00:00
2016-07-19 15:43:12 +03:00
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
2016-03-07 11:38:28 +02: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( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2017-05-08 11:39:47 +03:00
if [ " ${ _PY_EXE } " != "" ] ; then
2017-04-17 17:37:38 -04:00
_PYEXE = ${ _PY_EXE }
2017-04-19 13:22:45 -04:00
echoinfo " Using the following python version: ${ _PY_EXE } to install salt "
2013-02-12 22:44:12 +00:00
else
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2014-02-16 22:01:31 +00:00
fi
2016-07-19 15:43:12 +03:00
2020-01-28 19:20:03 +00:00
echodebug " _PY_EXE: $_PY_EXE "
2024-02-08 09:28:56 -07:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
2016-07-19 15:43:12 +03:00
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( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
SYSTEMD_RELOAD = $BS_FALSE
2016-07-18 13:46:35 +03:00
for fname in api master minion syndic; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2023-02-01 18:52:13 -08:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_FILE = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service "
else
_SERVICE_FILE = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- ${ fname } .service "
fi
2014-12-16 14:34:03 +00:00
if [ -f /bin/systemctl ] ; then
2016-07-18 13:46:35 +03:00
if [ ! -f " /usr/lib/systemd/system/salt- ${ fname } .service " ] || \
2024-06-28 17:04:56 -06:00
{ [ -f " /usr/lib/systemd/system/salt- ${ fname } .service " ] && [ " $_FORCE_OVERWRITE " -eq $BS_TRUE ] ; } ; then
2023-02-01 18:52:13 -08:00
__copyfile " ${ _SERVICE_FILE } " /usr/lib/systemd/system
2014-12-16 14:39:56 +00:00
fi
2014-11-18 11:26:51 -08:00
2024-06-28 17:04:56 -06:00
SYSTEMD_RELOAD = $BS_TRUE
2016-07-18 13:46:35 +03:00
elif [ ! -f " /etc/init.d/salt- $fname " ] || \
2024-06-28 17:04:56 -06:00
{ [ -f " /etc/init.d/salt- $fname " ] && [ " $_FORCE_OVERWRITE " -eq $BS_TRUE ] ; } ; then
2016-07-19 15:43:12 +03:00
__copyfile " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- ${ fname } " /etc/init.d
2024-06-28 17:04:56 -06:00
chmod +x /etc/init.d/salt-${ fname }
2013-02-08 12:09:37 +00:00
fi
done
2014-11-18 11:26:51 -08:00
2024-06-28 17:04:56 -06:00
if [ " $SYSTEMD_RELOAD " -eq $BS_TRUE ] ; then
2014-11-18 11:26:51 -08:00
/bin/systemctl daemon-reload
fi
2016-07-18 13:46:35 +03:00
2016-08-09 12:20:52 +03:00
install_centos_stable_post || return 1
2016-07-18 13:46:35 +03:00
return 0
2013-02-08 12:09:37 +00:00
}
2022-07-27 13:25:02 -07:00
install_centos_onedir_deps( ) {
2024-06-26 16:45:14 -06:00
## DGM Debugging
set -v
set -x
2024-07-01 13:45:45 -06:00
2024-02-02 15:32:40 -07:00
if [ " $_UPGRADE_SYS " -eq " $BS_TRUE " ] ; then
2022-04-11 16:47:01 -07:00
yum -y update || return 1
fi
if [ " $_DISABLE_REPOS " -eq " $BS_TRUE " ] && [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ] ; then
echowarn "Detected -r or -R option while installing Salt packages for Python 3."
echowarn "Python 3 packages for older Salt releases requires the EPEL repository to be installed."
echowarn "Installing the EPEL repository automatically is disabled when using the -r or -R options."
fi
if [ " $_DISABLE_REPOS " -eq " $BS_FALSE " ] ; then
2022-07-27 13:25:02 -07:00
__install_saltstack_rhel_onedir_repository || return 1
2022-04-11 16:47:01 -07:00
fi
# If -R was passed, we need to configure custom repo url with rsync-ed packages
2024-06-28 17:04:56 -06:00
# Which was still handled in __install_saltstack_rhel_repository, which was for old-stable which
# is removed since End-Of-Life. This call has its own check in case -r was passed without -R.
2022-04-11 16:47:01 -07:00
if [ " $_CUSTOM_REPO_URL " != "null" ] ; then
2022-07-27 13:25:02 -07:00
__install_saltstack_rhel_onedir_repository || return 1
2022-04-11 16:47:01 -07:00
fi
2024-02-09 11:39:42 -07:00
## DGM can find no dnf-utils in Fedora packaging archives and yum-utils EL7 and F30, none after
## DGM but find it on 8 and 9 Centos Stream, and Alma 8 & 9 but versions we are using doesn't have them
2024-06-25 15:56:18 -06:00
## DGM also EL9 doesn't have propcs and probably don't need these packages since using onedir
2024-06-25 16:54:18 -06:00
## DGM if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
## DGM __PACKAGES="dnf-utils chkconfig"
## DGM else
## DGM __PACKAGES="yum-utils chkconfig"
## DGM fi
## DGM __PACKAGES="${__PACKAGES} procps"
2022-04-11 16:47:01 -07:00
2024-06-26 14:14:24 -06:00
## DGM __PACKAGES="yum-utils chkconfig procps-ng"
## DGM can find no dnf-utils in Fedora packaging archives and yum-utils EL7 and F30, none after
## DGM but find it on 8 and 9 Centos Stream, and Alma 8 & 9 but versions we are using doesn't have them
## DGM also EL9 doesn't have propcs and probably don't need these packages since using onedir
## DGM trying original
2024-06-26 16:45:14 -06:00
## if [ "$DISTRO_MAJOR_VERSION" -ge 8 ]; then
## __PACKAGES="dnf-utils chkconfig"
## else
## __PACKAGES="yum-utils chkconfig"
## fi
## __PACKAGES="${__PACKAGES} procps"
2024-06-26 14:14:24 -06:00
2024-06-28 11:21:30 -06:00
__PACKAGES = "yum-utils chkconfig procps-ng findutils"
2024-06-25 15:56:18 -06:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2022-04-11 16:47:01 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2022-04-11 16:47:01 -07:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1
__yum_install_noinput ${ _EXTRA_PACKAGES } || return 1
2022-04-11 16:47:01 -07:00
fi
return 0
}
2022-07-27 13:25:02 -07:00
install_centos_onedir( ) {
2022-04-11 16:47:01 -07:00
__PACKAGES = ""
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-master "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2022-04-11 16:47:01 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2022-07-27 13:25:02 -07:00
install_centos_onedir_post( ) {
2024-06-28 17:04:56 -06:00
SYSTEMD_RELOAD = $BS_FALSE
2022-04-11 16:47:01 -07:00
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2022-04-11 16:47:01 -07:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2022-04-11 16:47:01 -07:00
if [ -f /bin/systemctl ] ; then
2024-06-28 17:04:56 -06:00
/bin/systemctl is-enabled salt-${ fname } .service > /dev/null 2>& 1 || (
/bin/systemctl preset salt-${ fname } .service > /dev/null 2>& 1 &&
/bin/systemctl enable salt-${ fname } .service > /dev/null 2>& 1
2022-04-11 16:47:01 -07:00
)
SYSTEMD_RELOAD = $BS_TRUE
elif [ -f " /etc/init.d/salt- ${ fname } " ] ; then
2024-06-28 17:04:56 -06:00
/sbin/chkconfig salt-${ fname } on
2022-04-11 16:47:01 -07:00
fi
done
2024-06-28 17:04:56 -06:00
if [ " $SYSTEMD_RELOAD " -eq $BS_TRUE ] ; then
2022-04-11 16:47:01 -07:00
/bin/systemctl daemon-reload
fi
return 0
}
2013-02-16 10:04:25 +00:00
install_centos_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2016-07-18 13:46:35 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2016-07-18 13:46:35 +03:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-08 12:09:37 +00:00
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
if ! /sbin/initctl status salt-$fname > /dev/null 2>& 1; then
2014-03-10 11:36:32 +00:00
# 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
2024-06-28 17:04:56 -06:00
/sbin/initctl stop salt-$fname > /dev/null 2>& 1
2014-03-10 11:36:32 +00:00
# Restart service
2024-06-28 17:04:56 -06:00
if ! /sbin/initctl start salt-$fname > /dev/null 2>& 1; then
2014-03-10 11:36:32 +00:00
# Failed the restart?!
return 1
2013-01-26 17:38:48 +00:00
fi
2024-06-28 17:04:56 -06:00
elif [ -f /etc/init.d/salt-$fname ] ; then
2017-01-19 10:21:27 +02:00
# Disable stdin to fix shell session hang on killing tee pipe
2024-06-28 17:04:56 -06:00
service salt-$fname stop < /dev/null > /dev/null 2>& 1
service salt-$fname start < /dev/null
2014-07-20 01:43:30 -04:00
elif [ -f /usr/bin/systemctl ] ; then
# CentOS 7 uses systemd
2024-06-28 17:04:56 -06:00
/usr/bin/systemctl stop salt-$fname > /dev/null 2>& 1
/usr/bin/systemctl start salt-$fname .service && continue
2020-01-30 12:36:56 +00:00
echodebug " Failed to start salt- $fname using systemd "
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2020-01-30 12:36:56 +00:00
journalctl -xe
fi
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( ) {
2016-07-18 13:46:35 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-08-23 23:28:09 +01:00
2014-02-20 13:02:10 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2024-02-02 15:32:40 -07:00
2024-06-28 17:04:56 -06:00
if [ -f " /etc/init.d/salt- $fname " ] ; then
2024-02-02 15:32:40 -07:00
__check_services_sysvinit " salt- $fname " || return 1
2014-07-20 01:43:30 -04:00
elif [ -f /usr/bin/systemctl ] ; then
2024-02-02 15:32:40 -07:00
__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
2016-08-09 12:20:52 +03:00
2014-02-20 13:02:10 +00:00
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
install_red_hat_linux_stable_deps( ) {
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( ) {
2013-03-23 11:55:45 +00:00
install_centos_git_deps || return 1
return 0
2013-01-27 18:11:30 +00:00
}
2022-07-27 13:25:02 -07:00
install_red_hat_linux_onedir_deps( ) {
install_centos_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2020-08-06 13:16:16 +03:00
install_red_hat_enterprise_stable_deps( ) {
install_red_hat_linux_stable_deps || return 1
return 0
}
install_red_hat_enterprise_git_deps( ) {
install_red_hat_linux_git_deps || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_onedir_deps( ) {
install_red_hat_linux_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
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
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_linux_onedir_deps( ) {
install_red_hat_linux_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
return 0
}
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
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_server_onedir_deps( ) {
install_red_hat_linux_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
return 0
}
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
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_workstation_onedir_deps( ) {
2022-04-11 16:47:01 -07:00
install_red_hat_linux_timat_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
}
2022-07-27 13:25:02 -07:00
install_red_hat_linux_onedir( ) {
install_centos_onedir || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2020-08-06 13:16:16 +03:00
install_red_hat_enterprise_stable( ) {
install_red_hat_linux_stable || return 1
return 0
}
install_red_hat_enterprise_git( ) {
install_red_hat_linux_git || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_onedir( ) {
install_red_hat_linux_onedir || return 1
2022-04-11 16:47:01 -07:00
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
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_linux_onedir( ) {
install_red_hat_linux_onedir || return 1
2022-04-11 16:47:01 -07:00
return 0
}
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
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_server_onedir( ) {
install_red_hat_linux_onedir || return 1
2022-04-11 16:47:01 -07:00
return 0
}
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
}
2022-07-27 13:25:02 -07:00
install_red_hat_enterprise_workstation_onedir( ) {
install_red_hat_linux_onedir || return 1
2022-04-11 16:47:01 -07:00
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
}
2020-08-06 13:16:16 +03:00
install_red_hat_enterprise_stable_post( ) {
install_red_hat_linux_stable_post || return 1
return 0
}
install_red_hat_enterprise_restart_daemons( ) {
install_red_hat_linux_restart_daemons || return 1
return 0
}
install_red_hat_enterprise_git_post( ) {
install_red_hat_linux_git_post || return 1
return 0
}
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
}
2020-08-06 13:16:16 +03:00
install_red_hat_enterprise_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
install_red_hat_enterprise_testing( ) {
install_centos_testing || return 1
return 0
}
install_red_hat_enterprise_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
2013-08-29 16:46:44 -04:00
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-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( ) {
2022-06-17 20:58:32 +00:00
# Install Oracle's EPEL.
2024-06-28 17:04:56 -06:00
if [ " ${ _EPEL_REPOS_INSTALLED } " -eq $BS_FALSE ] ; then
_EPEL_REPO = oracle-epel-release-el${ DISTRO_MAJOR_VERSION }
2022-06-17 20:58:32 +00:00
if ! rpm -q " ${ _EPEL_REPO } " > /dev/null; then
2024-06-27 11:34:44 -06:00
# shellcheck disable=SC2086
## DGM __yum_install_noinput "${_EPEL_REPO}"
__yum_install_noinput ${ _EPEL_REPO }
2022-06-17 20:58:32 +00:00
fi
2024-06-28 17:04:56 -06:00
_EPEL_REPOS_INSTALLED = $BS_TRUE
2022-06-17 20:58:32 +00:00
fi
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-03-07 00:33:16 -06:00
install_centos_git_deps || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_oracle_linux_onedir_deps( ) {
install_centos_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
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
}
2022-07-27 13:25:02 -07:00
install_oracle_linux_onedir( ) {
install_centos_onedir || return 1
2022-04-11 16:47:01 -07:00
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
}
2022-10-31 15:14:25 -04:00
install_oracle_linux_onedir_post( ) {
install_centos_onedir_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
2022-02-26 09:11:49 +00:00
#
#######################################################################################################################
#######################################################################################################################
#
# AlmaLinux Install Functions
#
install_almalinux_stable_deps( ) {
install_centos_stable_deps || return 1
return 0
}
install_almalinux_git_deps( ) {
install_centos_git_deps || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_almalinux_onedir_deps( ) {
install_centos_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2022-02-26 09:11:49 +00:00
install_almalinux_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
install_almalinux_stable( ) {
install_centos_stable || return 1
return 0
}
install_almalinux_git( ) {
install_centos_git || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_almalinux_onedir( ) {
install_centos_onedir || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2022-02-26 09:11:49 +00:00
install_almalinux_testing( ) {
install_centos_testing || return 1
return 0
}
install_almalinux_stable_post( ) {
install_centos_stable_post || return 1
return 0
}
install_almalinux_git_post( ) {
install_centos_git_post || return 1
return 0
}
2022-10-31 15:14:25 -04:00
install_almalinux_onedir_post( ) {
install_centos_onedir_post || return 1
return 0
}
2022-02-26 09:11:49 +00:00
install_almalinux_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
install_almalinux_restart_daemons( ) {
install_centos_restart_daemons || return 1
return 0
}
install_almalinux_check_services( ) {
install_centos_check_services || return 1
return 0
}
#
# Ended AlmaLinux Install Functions
2022-02-26 09:14:00 +00:00
#
#######################################################################################################################
#######################################################################################################################
#
# Rocky Linux Install Functions
#
install_rocky_linux_stable_deps( ) {
install_centos_stable_deps || return 1
return 0
}
install_rocky_linux_git_deps( ) {
install_centos_git_deps || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_rocky_linux_onedir_deps( ) {
install_centos_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2022-02-26 09:14:00 +00:00
install_rocky_linux_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
install_rocky_linux_stable( ) {
install_centos_stable || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_rocky_linux_onedir( ) {
install_centos_onedir || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2022-02-26 09:14:00 +00:00
install_rocky_linux_git( ) {
install_centos_git || return 1
return 0
}
install_rocky_linux_testing( ) {
install_centos_testing || return 1
return 0
}
install_rocky_linux_stable_post( ) {
install_centos_stable_post || return 1
return 0
}
install_rocky_linux_git_post( ) {
install_centos_git_post || return 1
return 0
}
2022-10-31 15:14:25 -04:00
install_rocky_linux_onedir_post( ) {
install_centos_onedir_post || return 1
return 0
}
2022-02-26 09:14:00 +00:00
install_rocky_linux_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
install_rocky_linux_restart_daemons( ) {
install_centos_restart_daemons || return 1
return 0
}
install_rocky_linux_check_services( ) {
install_centos_check_services || return 1
return 0
}
#
# Ended Rocky 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
}
2022-07-27 13:25:02 -07:00
install_scientific_linux_onedir_deps( ) {
install_centos_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2014-03-19 19:11:18 +00:00
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
}
2022-07-27 13:25:02 -07:00
install_scientific_linux_onedir( ) {
install_centos_onedir || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2014-03-19 19:11:18 +00:00
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
}
2022-10-31 15:14:25 -04:00
install_scientific_linux_onedir_post( ) {
install_centos_onedir_post || return 1
return 0
}
2014-03-19 19:11:18 +00:00
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
#
#######################################################################################################################
2016-11-14 15:24:04 -07:00
#######################################################################################################################
#
# CloudLinux Install Functions
#
install_cloud_linux_stable_deps( ) {
install_centos_stable_deps || return 1
return 0
}
install_cloud_linux_git_deps( ) {
install_centos_git_deps || return 1
return 0
}
2022-07-27 13:25:02 -07:00
install_cloud_linux_onedir_deps( ) {
install_centos_onedir_deps || return 1
2022-04-11 16:47:01 -07:00
return 0
}
2016-11-14 15:24:04 -07:00
install_cloud_linux_testing_deps( ) {
install_centos_testing_deps || return 1
return 0
}
install_cloud_linux_stable( ) {
install_centos_stable || return 1
return 0
}
install_cloud_linux_git( ) {
install_centos_git || return 1
return 0
}
install_cloud_linux_testing( ) {
install_centos_testing || return 1
return 0
}
install_cloud_linux_stable_post( ) {
install_centos_stable_post || return 1
return 0
}
install_cloud_linux_git_post( ) {
install_centos_git_post || return 1
return 0
}
install_cloud_linux_testing_post( ) {
install_centos_testing_post || return 1
return 0
}
install_cloud_linux_restart_daemons( ) {
install_centos_restart_daemons || return 1
return 0
}
install_cloud_linux_check_services( ) {
install_centos_check_services || return 1
return 0
}
#
# End of CloudLinux Install Functions
#
#######################################################################################################################
2017-01-08 15:18:51 +01:00
#######################################################################################################################
#
# Alpine Linux Install Functions
#
install_alpine_linux_stable_deps( ) {
2017-02-10 11:09:53 +02:00
if ! grep -q '^[^#].\+alpine/.\+/community' /etc/apk/repositories; then
# Add community repository entry based on the "main" repo URL
__REPO = $( grep '^[^#].\+alpine/.\+/main\>' /etc/apk/repositories)
echo " ${ __REPO } " | sed -e 's/main/community/' >> /etc/apk/repositories
2017-01-08 15:18:51 +01:00
fi
2017-02-10 11:09:53 +02:00
apk update
2017-01-08 15:18:51 +01:00
2017-04-12 18:06:33 +03:00
# Get latest root CA certs
apk -U add ca-certificates
2017-04-25 12:42:22 +03:00
if ! __check_command_exists openssl; then
# Install OpenSSL to be able to pull from https:// URLs
apk -U add openssl
fi
}
install_alpine_linux_git_deps( ) {
install_alpine_linux_stable_deps || return 1
2017-01-08 16:03:24 +01:00
if ! __check_command_exists git; then
apk -U add git || return 1
fi
__git_clone_and_checkout || return 1
2024-02-08 09:28:56 -07:00
apk -U add python3 python3-dev py3-pip py3-setuptools g++ linux-headers zeromq-dev openrc || return 1
_PY_EXE = python3
return 0
2017-01-08 16:03:24 +01:00
}
2017-01-08 15:18:51 +01:00
install_alpine_linux_stable( ) {
__PACKAGES = "salt"
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2017-01-08 15:18:51 +01:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2017-01-08 15:18:51 +01:00
__PACKAGES = " ${ __PACKAGES } salt-master "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2017-01-08 15:18:51 +01:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2017-01-08 15:18:51 +01:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2017-02-09 12:01:37 +02:00
# shellcheck disable=SC2086
2024-02-02 15:32:40 -07:00
apk -U add " ${ __PACKAGES } " || return 1
2017-01-08 15:18:51 +01:00
return 0
}
install_alpine_linux_git( ) {
2024-02-08 09:28:56 -07:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
return 0
2017-01-08 15:18:51 +01:00
}
install_alpine_linux_post( ) {
for fname in api master minion syndic; do
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-01-08 15:18:51 +01:00
2017-04-12 18:06:33 +03:00
if [ -f /sbin/rc-update ] ; then
2020-01-28 17:38:43 +00:00
script_url = " ${ _SALTSTACK_REPO_URL %.git } /raw/master/pkg/alpine/salt- $fname "
2017-04-25 12:42:22 +03:00
[ -f " /etc/init.d/salt- $fname " ] || __fetch_url " /etc/init.d/salt- $fname " " $script_url "
2017-01-08 15:18:51 +01:00
2018-07-09 12:49:11 -04:00
# shellcheck disable=SC2181
2017-04-12 18:06:33 +03:00
if [ $? -eq 0 ] ; then
chmod +x " /etc/init.d/salt- $fname "
else
echoerror " Failed to get OpenRC init script for $OS_NAME from $script_url . "
return 1
fi
2017-01-08 16:01:02 +01:00
2017-04-12 18:06:33 +03:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2017-04-12 18:06:33 +03:00
/sbin/rc-update add " salt- $fname " > /dev/null 2>& 1 || return 1
2017-01-08 15:18:51 +01:00
fi
done
}
install_alpine_linux_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " ${ _START_DAEMONS } " -eq $BS_FALSE ] && return
2017-01-08 15:18:51 +01:00
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2017-01-08 15:18:51 +01:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-01-08 15:18:51 +01:00
2017-02-11 18:19:33 +02:00
# Disable stdin to fix shell session hang on killing tee pipe
2024-06-28 17:04:56 -06:00
/sbin/rc-service salt-$fname stop < /dev/null > /dev/null 2>& 1
/sbin/rc-service salt-$fname start < /dev/null || return 1
2017-01-08 15:18:51 +01:00
done
}
2017-01-08 16:01:02 +01:00
install_alpine_linux_check_services( ) {
2017-01-08 15:18:51 +01:00
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2017-01-08 15:18:51 +01:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-01-08 15:18:51 +01:00
2024-06-28 17:04:56 -06:00
__check_services_openrc salt-$fname || return 1
2017-01-08 15:18:51 +01:00
done
return 0
}
2017-01-08 16:01:02 +01:00
daemons_running_alpine_linux( ) {
2024-06-28 17:04:56 -06:00
[ " ${ _START_DAEMONS } " -eq $BS_FALSE ] && return
2017-01-08 16:01:02 +01:00
FAILED_DAEMONS = 0
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2017-01-08 16:01:02 +01:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-01-08 16:01:02 +01:00
2017-01-10 23:17:48 +01:00
# shellcheck disable=SC2009
2024-06-28 17:04:56 -06:00
if [ " $( ps wwwaux | grep -v grep | grep salt-$fname ) " = "" ] ; then
2017-01-08 16:01:02 +01:00
echoerror " salt- $fname was not found running "
FAILED_DAEMONS = $(( FAILED_DAEMONS + 1 ))
fi
done
2024-06-28 17:04:56 -06:00
return $FAILED_DAEMONS
2017-01-08 16:01:02 +01:00
}
2017-01-08 15:18:51 +01:00
#
# Ended Alpine 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
2024-02-02 17:57:31 -07:00
# Support for Amazon Linux 2
install_amazon_linux_ami_2_git_deps( ) {
2024-06-28 17:04:56 -06:00
if [ " $_INSECURE_DL " -eq $BS_FALSE ] && [ " ${ _SALT_REPO_URL %% : //* } " = "https" ] ; then
2024-02-02 17:57:31 -07:00
yum -y install ca-certificates || return 1
2017-12-25 21:59:59 -08:00
fi
2024-02-02 17:57:31 -07:00
if [ " $_PY_MAJOR_VERSION " -eq 2 ] ; then
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2017-12-25 21:59:59 -08:00
fi
2017-01-27 10:53:28 -08:00
2024-02-02 17:57:31 -07:00
install_amazon_linux_ami_2_deps || return 1
2024-02-08 09:28:56 -07:00
PY_PKG_VER = 3
PIP_EXE = '/bin/pip3'
2024-02-02 17:57:31 -07:00
__PACKAGES = " python ${ PY_PKG_VER } -pip "
2017-02-27 18:31:33 +01:00
2024-02-02 17:57:31 -07:00
if ! __check_command_exists " ${ PIP_EXE } " ; then
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2024-02-02 17:57:31 -07:00
fi
2016-10-24 12:58:21 -06:00
2024-02-02 17:57:31 -07:00
if ! __check_command_exists git; then
__yum_install_noinput git || return 1
2016-08-12 10:10:48 -06:00
fi
2024-02-02 17:57:31 -07:00
__git_clone_and_checkout || return 1
2016-04-18 11:57:24 -06:00
2024-02-08 09:28:56 -07:00
__PACKAGES = " python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools python ${ PY_PKG_VER } -devel gcc "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-02-08 09:28:56 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2020-01-28 19:20:03 +00:00
2024-02-08 09:28:56 -07:00
# Let's trigger config_salt()
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
_TEMP_CONFIG_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /conf/ "
CONFIG_SALT_FUNC = "config_salt"
fi
2018-11-14 18:40:24 +00:00
return 0
}
2018-09-14 14:31:59 +01:00
install_amazon_linux_ami_2_deps( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
fi
2018-09-14 14:31:59 +01:00
if [ " $ITYPE " = "stable" ] ; then
repo_rev = " $STABLE_REV "
else
repo_rev = "latest"
fi
# We need to install yum-utils before doing anything else when installing on
# Amazon Linux ECS-optimized images. See issue #974.
__yum_install_noinput yum-utils
# Do upgrade early
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2018-09-14 14:31:59 +01:00
yum -y update || return 1
fi
2024-06-28 17:04:56 -06:00
if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ " $_CUSTOM_REPO_URL " != "null" ] ; then
2021-05-14 22:27:40 +00:00
__REPO_FILENAME = "salt.repo"
2024-02-08 09:28:56 -07:00
PY_PKG_VER = 3
2024-02-08 15:00:59 -07:00
__PY_VERSION_REPO = "py3"
2024-02-08 09:28:56 -07:00
repo_label = "saltstack-py3-repo"
repo_name = "SaltStack Python 3 repo for Amazon Linux 2"
2019-11-22 12:52:08 -07:00
2024-07-01 11:48:29 -06:00
base_url = " $HTTP_VAL :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /amazon/2/\$basearch/ $repo_rev / "
2024-02-08 09:28:56 -07:00
gpg_key = " ${ base_url } SALT-PROJECT-GPG-PUBKEY-2023.gpg "
2018-09-14 14:31:59 +01:00
2024-02-08 09:28:56 -07:00
# This should prob be refactored to use __install_saltstack_rhel_onedir_repository()
2018-09-14 14:31:59 +01:00
# With args passed in to do the right thing. Reformatted to be more like the
# amazon linux yum file.
if [ ! -s " /etc/yum.repos.d/ ${ __REPO_FILENAME } " ] ; then
cat <<_eof > "/etc/yum.repos.d/${_ _REPO_FILENAME} "
2019-12-12 15:15:36 -07:00
[ $repo_label ]
2018-09-14 14:31:59 +01:00
name = $repo_name
failovermethod = priority
priority = 10
gpgcheck = 1
gpgkey = $gpg_key
baseurl = $base_url
_eof
fi
fi
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1
__yum_install_noinput ${ _EXTRA_PACKAGES } || return 1
2018-09-14 14:31:59 +01:00
fi
}
2022-08-01 09:08:41 -07:00
install_amazon_linux_ami_2_onedir_deps( ) {
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
fi
2022-08-01 09:08:41 -07:00
if [ " $ITYPE " = "onedir" ] ; then
repo_rev = " $ONEDIR_REV "
else
repo_rev = "latest"
fi
# We need to install yum-utils before doing anything else when installing on
# Amazon Linux ECS-optimized images. See issue #974.
__yum_install_noinput yum-utils
# Do upgrade early
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2022-08-01 09:08:41 -07:00
yum -y update || return 1
fi
2024-06-28 17:04:56 -06:00
if [ $_DISABLE_REPOS -eq $BS_FALSE ] || [ " $_CUSTOM_REPO_URL " != "null" ] ; then
2022-08-01 09:08:41 -07:00
__REPO_FILENAME = "salt.repo"
2024-02-08 15:00:59 -07:00
__PY_VERSION_REPO = "py3"
2024-02-08 09:28:56 -07:00
PY_PKG_VER = 3
repo_label = "saltstack-py3-repo"
repo_name = "SaltStack Python 3 repo for Amazon Linux 2"
2022-08-01 09:08:41 -07:00
fi
base_url = " $HTTP_VAL :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /amazon/2/\$basearch/ $repo_rev / "
2022-12-05 08:57:41 +00:00
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
base_url = " $HTTP_VAL :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /amazon/2/\$basearch/ "
fi
2023-03-02 18:56:39 -08:00
2024-02-08 09:28:56 -07:00
gpg_key = " ${ base_url } SALT-PROJECT-GPG-PUBKEY-2023.pub "
2022-08-01 09:08:41 -07:00
# With args passed in to do the right thing. Reformatted to be more like the
# amazon linux yum file.
if [ ! -s " /etc/yum.repos.d/ ${ __REPO_FILENAME } " ] ; then
cat <<_eof > "/etc/yum.repos.d/${_ _REPO_FILENAME} "
[ $repo_label ]
name = $repo_name
failovermethod = priority
priority = 10
gpgcheck = 1
gpgkey = $gpg_key
baseurl = $base_url
_eof
fi
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1
__yum_install_noinput ${ _EXTRA_PACKAGES } || return 1
2022-08-01 09:08:41 -07:00
fi
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_stable( ) {
2013-03-23 11:55:45 +00:00
install_centos_stable || return 1
return 0
2013-01-31 18:52:58 +00:00
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_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
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_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
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_git( ) {
2013-03-23 11:55:45 +00:00
install_centos_git || return 1
return 0
2013-01-31 18:52:58 +00:00
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_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
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_testing( ) {
2013-08-29 16:46:44 -04:00
install_centos_testing || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_testing_post( ) {
2013-08-29 16:46:44 -04:00
install_centos_testing_post || return 1
return 0
}
2018-11-14 18:40:24 +00:00
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_check_services( ) {
install_centos_check_services || return 1
return 0
}
install_amazon_linux_ami_2_onedir( ) {
2018-11-14 18:40:24 +00:00
install_centos_stable || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2_onedir_post( ) {
2018-11-14 18:40:24 +00:00
install_centos_stable_post || return 1
return 0
}
2024-02-02 15:32:40 -07:00
# Support for Amazon Linux 2023
# the following code needs adjustment to allow for 2023, 2024, 2025, etc - 2023 for now
install_amazon_linux_ami_2023_git_deps( ) {
2024-06-28 17:04:56 -06:00
if [ " $_INSECURE_DL " -eq $BS_FALSE ] && [ " ${ _SALT_REPO_URL %% : //* } " = "https" ] ; then
2024-02-02 15:32:40 -07:00
yum -y install ca-certificates || return 1
fi
install_amazon_linux_ami_2023_onedir_deps || return 1
PY_PKG_VER = 3
PIP_EXE = '/bin/pip3'
__PACKAGES = " python ${ PY_PKG_VER } -pip "
if ! __check_command_exists " ${ PIP_EXE } " ; then
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2024-02-02 15:32:40 -07:00
fi
if ! __check_command_exists git; then
__yum_install_noinput git || return 1
fi
__git_clone_and_checkout || return 1
2024-02-02 17:57:31 -07:00
__PACKAGES = " python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools python ${ PY_PKG_VER } -devel gcc "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-02-02 17:57:31 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${__PACKAGES}" || return 1
__yum_install_noinput ${ __PACKAGES } || return 1
2024-02-02 15:32:40 -07:00
# Let's trigger config_salt()
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
_TEMP_CONFIG_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /conf/ "
CONFIG_SALT_FUNC = "config_salt"
fi
return 0
}
install_amazon_linux_ami_2023_onedir_deps( ) {
if [ " $ITYPE " = "onedir" ] ; then
repo_rev = " $ONEDIR_REV "
else
repo_rev = "latest"
fi
# We need to install yum-utils before doing anything else when installing on
# Amazon Linux ECS-optimized images. See issue #974.
__yum_install_noinput yum-utils
# Do upgrade early
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2024-02-02 15:32:40 -07:00
yum -y update || return 1
fi
2024-06-28 17:04:56 -06:00
if [ " $_DISABLE_REPOS " -eq $BS_FALSE ] || [ " $_CUSTOM_REPO_URL " != "null" ] ; then
2024-02-02 15:32:40 -07:00
__REPO_FILENAME = "salt.repo"
2024-02-08 15:00:59 -07:00
__PY_VERSION_REPO = "py3"
2024-02-02 15:32:40 -07:00
PY_PKG_VER = 3
repo_label = "saltstack-py3-repo"
repo_name = "SaltStack Python 3 repo for Amazon Linux 2023"
base_url = " $HTTP_VAL :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /amazon/2023/\$basearch/ $repo_rev / "
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
base_url = " $HTTP_VAL :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /amazon/2023/\$basearch/ "
fi
gpg_key = " ${ base_url } SALT-PROJECT-GPG-PUBKEY-2023.pub "
2024-02-08 09:28:56 -07:00
# This should prob be refactored to use __install_saltstack_rhel_onedir_repository()
2024-02-02 15:32:40 -07:00
# With args passed in to do the right thing. Reformatted to be more like the
# amazon linux yum file.
if [ ! -s " /etc/yum.repos.d/ ${ __REPO_FILENAME } " ] ; then
cat <<_eof > "/etc/yum.repos.d/${_ _REPO_FILENAME} "
[ $repo_label ]
name = $repo_name
failovermethod = priority
priority = 10
gpgcheck = 1
gpgkey = $gpg_key
baseurl = $base_url
_eof
fi
fi
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __yum_install_noinput "${_EXTRA_PACKAGES}" || return 1
__yum_install_noinput ${ _EXTRA_PACKAGES } || return 1
2024-02-02 15:32:40 -07:00
fi
}
install_amazon_linux_ami_2023_stable( ) {
install_centos_stable || return 1
return 0
}
install_amazon_linux_ami_2023_stable_post( ) {
install_centos_stable_post || return 1
return 0
}
install_amazon_linux_ami_2023_restart_daemons( ) {
2018-11-14 18:40:24 +00:00
install_centos_restart_daemons || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2023_git( ) {
2018-11-14 18:40:24 +00:00
install_centos_git || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2023_git_post( ) {
2018-11-14 18:40:24 +00:00
install_centos_git_post || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2023_testing( ) {
2018-11-14 18:40:24 +00:00
install_centos_testing || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2023_testing_post( ) {
2018-11-14 18:40:24 +00:00
install_centos_testing_post || return 1
return 0
}
2019-11-22 12:52:08 -07:00
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2023_check_services( ) {
2019-11-22 12:52:08 -07:00
install_centos_check_services || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2023_onedir( ) {
2022-08-01 09:08:41 -07:00
install_centos_stable || return 1
return 0
}
2024-02-02 15:32:40 -07:00
install_amazon_linux_ami_2023_onedir_post( ) {
2022-08-01 09:08:41 -07:00
install_centos_stable_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-09-27 14:23:48 +01:00
if [ ! -f /etc/pacman.d/gnupg ] ; then
pacman-key --init && pacman-key --populate archlinux || return 1
fi
2017-04-27 15:31:18 -06:00
# Pacman does not resolve dependencies on outdated versions
# They always need to be updated
pacman -Syy --noconfirm
2016-06-07 12:32:49 -06:00
2017-04-27 15:31:18 -06:00
pacman -S --noconfirm --needed archlinux-keyring || return 1
pacman -Su --noconfirm --needed pacman || return 1
2015-01-07 03:01:23 +00:00
2016-01-25 09:00:32 -05:00
if __check_command_exists pacman-db-upgrade; then
2015-01-07 01:28:32 +00:00
pacman-db-upgrade || return 1
fi
2020-05-27 19:07:03 +01:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 2 ] ; then
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
return 1
2020-05-27 19:07:03 +01:00
else
PY_PKG_VER = ""
fi
2016-11-22 12:10:02 +02:00
# YAML module is used for generating custom master/minion configs
2020-05-27 19:07:03 +01:00
# shellcheck disable=SC2086
pacman -Su --noconfirm --needed python${ PY_PKG_VER } -yaml
2014-02-16 17:28:52 +00:00
2024-07-01 16:29:40 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
pacman -Su --noconfirm --needed python${ PY_PKG_VER } -tornado
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2020-05-27 19:07:03 +01:00
# shellcheck disable=SC2086
pacman -Su --noconfirm --needed python${ PY_PKG_VER } -apache-libcloud || return 1
2014-02-16 17:28:52 +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
2024-06-28 17:04:56 -06:00
## DGM pacman -Su --noconfirm --needed "${_EXTRA_PACKAGES}" || return 1
pacman -Su --noconfirm --needed ${ _EXTRA_PACKAGES } || return 1
2014-02-16 21:38:15 +00:00
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
2016-01-25 09:00:32 -05:00
if ! __check_command_exists git; then
2015-04-30 12:12:22 +01:00
pacman -Sy --noconfirm --needed git || return 1
fi
2020-01-28 19:20:03 +00:00
__git_clone_and_checkout || return 1
2024-06-27 14:18:42 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 2 ] ; then
echoerror "Python 2 is no longer supported, only Python 3"
return 1
else
PY_PKG_VER = ""
fi
2024-02-02 17:57:31 -07:00
__PACKAGES = " python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools gcc "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-02-02 17:57:31 -07:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM pacman -Su --noconfirm --needed "${__PACKAGES}"
pacman -Su --noconfirm --needed ${ __PACKAGES }
2015-05-01 14:30:55 +01:00
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
2016-03-07 11:38:28 +02: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
}
2023-04-14 05:56:44 -07:00
install_arch_linux_onedir_deps( ) {
install_arch_linux_stable_deps || return 1
}
2013-02-23 02:13:26 +00:00
install_arch_linux_stable( ) {
2017-04-27 15:31:18 -06:00
# Pacman does not resolve dependencies on outdated versions
# They always need to be updated
pacman -Syy --noconfirm
pacman -Su --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
2021-03-24 16:26:13 +00:00
pacman -Syu --noconfirm salt || 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( ) {
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 2 ] ; then
echoerror "Python 2 is no longer supported, only Python 3"
return 1
fi
2020-01-28 19:20:03 +00:00
2023-02-03 14:56:32 -08:00
_POST_NEON_PIP_INSTALL_ARGS = " ${ _POST_NEON_PIP_INSTALL_ARGS } --use-pep517 "
2023-02-03 16:39:35 -08:00
_PIP_DOWNLOAD_ARGS = " ${ _PIP_DOWNLOAD_ARGS } --use-pep517 "
2024-02-02 17:57:31 -07:00
2024-02-08 09:28:56 -07:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
2024-02-02 17:57:31 -07:00
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( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; do
2013-01-26 18:43:48 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $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
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2013-01-26 18:43:48 +00:00
if [ -f /usr/bin/systemctl ] ; then
# Using systemd
2024-06-28 17:04:56 -06: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
)
2017-05-26 16:49:43 +02:00
sleep 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( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; do
2013-01-25 23:41:57 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-01-25 23:41:57 +00:00
2023-02-02 10:24:12 -08:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common "
else
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/rpm "
fi
2013-01-25 23:41:57 +00:00
if [ -f /usr/bin/systemctl ] ; then
2023-02-02 10:24:12 -08:00
__copyfile " ${ _SERVICE_DIR } /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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2024-06-28 17:04:56 -06: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
)
2017-05-26 16:49:43 +02:00
sleep 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!?
2016-03-07 11:38:28 +02:00
__copyfile " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- $fname " " /etc/rc.d/init.d/salt- $fname "
2024-06-28 17:04:56 -06: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( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-02-08 12:33:47 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-08 12:33:47 +00:00
if [ -f /usr/bin/systemctl ] ; then
2024-06-28 17:04:56 -06:00
/usr/bin/systemctl stop salt-$fname .service > /dev/null 2>& 1
/usr/bin/systemctl start salt-$fname .service && continue
2020-01-30 12:36:56 +00:00
echodebug " Failed to start salt- $fname using systemd "
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2020-01-30 12:36:56 +00:00
journalctl -xe
fi
2013-02-08 12:33:47 +00:00
fi
2016-08-13 18:58:38 +03:00
2024-06-28 17:04:56 -06:00
/etc/rc.d/salt-$fname stop > /dev/null 2>& 1
/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
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-08-23 23:28:09 +01:00
2014-02-20 12:03:23 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2016-08-10 11:20:31 +03:00
2024-06-28 17:04:56 -06:00
__check_services_systemd salt-$fname || return 1
2014-02-20 12:03:23 +00:00
done
2016-08-13 18:58:38 +03:00
2014-02-20 12:03:23 +00:00
return 0
}
2023-03-30 17:21:59 -07:00
install_arch_linux_onedir( ) {
install_arch_linux_stable || return 1
return 0
}
2023-03-31 16:01:43 -07:00
install_arch_linux_onedir_post( ) {
2023-04-14 05:56:44 -07:00
install_arch_linux_post || return 1
2023-03-31 16:01:43 -07:00
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
2023-04-21 12:45:35 -07:00
#######################################################################################################################
#
# Photon OS Install Functions
#
__install_saltstack_photon_onedir_repository( ) {
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
2024-06-26 12:00:17 -06:00
echoerror "Python version is no longer supported, only Python 3"
2024-02-08 09:28:56 -07:00
return 1
fi
2023-04-21 12:45:35 -07:00
if [ " $ITYPE " = "stable" ] ; then
2023-04-23 19:57:49 -07:00
REPO_REV = " $ONEDIR_REV "
2023-04-21 12:45:35 -07:00
else
2023-04-23 19:57:49 -07:00
REPO_REV = "latest"
2023-04-21 12:45:35 -07:00
fi
2024-02-08 15:00:59 -07:00
__PY_VERSION_REPO = "py3"
2023-04-22 10:39:19 -07:00
REPO_FILE = "/etc/yum.repos.d/salt.repo"
2023-04-21 12:45:35 -07:00
2024-06-28 17:04:56 -06:00
if [ ! -s " $REPO_FILE " ] || [ " $_FORCE_OVERWRITE " -eq $BS_TRUE ] ; then
2024-07-02 13:57:12 -06:00
## DGM FETCH_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_DIR}/${__PY_VERSION_REPO}/photon/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/${ONEDIR_REV}"
## DGM if [ "${ONEDIR_REV}" = "nightly" ] ; then
## DGM FETCH_URL="${HTTP_VAL}://${_REPO_URL}/${_ONEDIR_NIGHTLY_DIR}/${__PY_VERSION_REPO}/photon/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/"
## DGM fi
## DGM the salt repo has issues, need the Major version dot Zero, eg: 4.0, 5.0
FETCH_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /photon/ ${ DISTRO_MAJOR_VERSION } .0/ ${ CPU_ARCH_L } / ${ ONEDIR_REV } "
2023-04-21 12:45:35 -07:00
if [ " ${ ONEDIR_REV } " = "nightly" ] ; then
2024-07-02 13:57:12 -06:00
FETCH_URL = " ${ HTTP_VAL } :// ${ _REPO_URL } / ${ _ONEDIR_NIGHTLY_DIR } / ${ __PY_VERSION_REPO } /photon/ ${ DISTRO_MAJOR_VERSION } .0/ ${ CPU_ARCH_L } / "
2023-04-21 12:45:35 -07:00
fi
2023-04-21 14:22:13 -07:00
2023-04-23 19:57:49 -07:00
__fetch_url " ${ REPO_FILE } " " ${ FETCH_URL } .repo "
2023-04-21 14:22:13 -07:00
2023-04-22 10:39:19 -07:00
GPG_KEY = "SALT-PROJECT-GPG-PUBKEY-2023.pub"
2023-04-21 14:22:13 -07:00
2023-04-23 19:57:49 -07:00
__rpm_import_gpg " ${ FETCH_URL } / ${ GPG_KEY } " || return 1
2023-04-21 12:45:35 -07:00
2023-04-21 14:22:13 -07:00
tdnf makecache || return 1
2023-04-23 19:57:49 -07:00
elif [ " $REPO_REV " != "latest" ] ; then
2023-04-21 12:45:35 -07:00
echowarn "salt.repo already exists, ignoring salt version argument."
2023-04-23 19:57:49 -07:00
echowarn " Use -F (forced overwrite) to install $REPO_REV . "
2023-04-21 12:45:35 -07:00
fi
return 0
}
install_photon_deps( ) {
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
2024-06-26 12:00:17 -06:00
echoerror "Python version is no longer supported, only Python 3"
2024-02-08 09:28:56 -07:00
return 1
fi
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
tdnf -y update || return 1
fi
__PACKAGES = " ${ __PACKAGES : = } "
PY_PKG_VER = 3
__PACKAGES = " ${ __PACKAGES } libyaml procps-ng python ${ PY_PKG_VER } -crypto python ${ PY_PKG_VER } -jinja2 "
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -msgpack python ${ PY_PKG_VER } -requests python ${ PY_PKG_VER } -zmq "
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -m2crypto python ${ PY_PKG_VER } -pyyaml "
__PACKAGES = " ${ __PACKAGES } python ${ PY_PKG_VER } -systemd "
2024-02-08 09:28:56 -07:00
2023-04-21 12:45:35 -07:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2023-04-21 12:45:35 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __tdnf_install_noinput "${__PACKAGES}" "${_EXTRA_PACKAGES}" || return 1
__tdnf_install_noinput ${ __PACKAGES } ${ _EXTRA_PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
return 0
}
install_photon_stable_post( ) {
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2023-04-21 12:45:35 -07:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2023-04-21 12:45:35 -07:00
2024-06-28 17:04:56 -06:00
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
2023-04-21 12:45:35 -07:00
sleep 1
systemctl daemon-reload
done
}
install_photon_git_deps( ) {
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
2024-06-26 12:00:17 -06:00
echoerror "Python version is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2023-04-21 12:45:35 -07:00
fi
2024-02-08 09:28:56 -07:00
# Packages are named python3-<whatever>
PY_PKG_VER = 3
2023-04-21 12:45:35 -07:00
__PACKAGES = ""
if ! __check_command_exists ps; then
__PACKAGES = " ${ __PACKAGES } procps-ng "
fi
if ! __check_command_exists git; then
__PACKAGES = " ${ __PACKAGES } git "
fi
if [ -n " ${ __PACKAGES } " ] ; then
# shellcheck disable=SC2086
2023-04-21 14:22:13 -07:00
__tdnf_install_noinput ${ __PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
__PACKAGES = ""
fi
__git_clone_and_checkout || return 1
2024-07-02 14:54:14 -06:00
## DGM __PACKAGES="python${PY_PKG_VER}-devel python${PY_PKG_VER}-pip python${PY_PKG_VER}-setuptools gcc glibc-devel linux-devel.x86_64"
__PACKAGES = " python ${ PY_PKG_VER } -devel python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools gcc glibc-devel linux-devel.x86_64 cython ${ PY_PKG_VER } "
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2024-07-02 14:54:14 -06:00
## DGM Photon 5 container is missing systemd on default installation
if [ " ${ DISTRO_MAJOR_VERSION } " -ge 5 ] ; then
# Photon 5 container is missing systemd on default installation
__PACKAGES = " ${ __PACKAGES } systemd "
fi
2024-02-02 17:57:31 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __tdnf_install_noinput "${__PACKAGES}" || return 1
__tdnf_install_noinput ${ __PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
2023-08-09 19:59:58 -07:00
if [ " ${ DISTRO_MAJOR_VERSION } " -gt 3 ] ; then
# Need newer version of setuptools on Photon
_setuptools_dep = " setuptools>= ${ _MINIMUM_SETUPTOOLS_VERSION } "
echodebug " Running ' ${ _PY_EXE } -m pip --upgrade install ${ _setuptools_dep } ' "
${ _PY_EXE } -m pip install --upgrade " ${ _setuptools_dep } "
fi
2023-04-22 12:23:05 -07:00
2023-04-21 12:45:35 -07:00
# Let's trigger config_salt()
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
_TEMP_CONFIG_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /conf/ "
CONFIG_SALT_FUNC = "config_salt"
fi
return 0
}
install_photon_git( ) {
if [ " ${ _PY_EXE } " != "" ] ; then
_PYEXE = ${ _PY_EXE }
echoinfo " Using the following python version: ${ _PY_EXE } to install salt "
else
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2023-04-21 12:45:35 -07:00
fi
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /salt/syspaths.py " ] ; then
2024-06-28 17:04:56 -06:00
${ _PYEXE } setup.py --salt-config-dir= " $_SALT_ETC_DIR " --salt-cache-dir= " ${ _SALT_CACHE_DIR } " ${ SETUP_PY_INSTALL_ARGS } install --prefix= /usr || return 1
2023-04-21 12:45:35 -07:00
else
2024-06-28 17:04:56 -06:00
${ _PYEXE } setup.py ${ SETUP_PY_INSTALL_ARGS } install --prefix= /usr || return 1
2023-04-21 12:45:35 -07:00
fi
return 0
}
install_photon_git_post( ) {
for fname in api master minion syndic; do
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2023-04-21 12:45:35 -07:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common "
else
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/rpm "
fi
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
# Salt executables are located under `/usr/local/bin/` on Fedora 36+
#if [ "${DISTRO_VERSION}" -ge 36 ]; then
# sed -i -e 's:/usr/bin/:/usr/local/bin/:g' /lib/systemd/system/salt-*.service
#fi
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2023-04-21 12:45:35 -07:00
2024-06-28 17:04:56 -06:00
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
2023-04-21 12:45:35 -07:00
sleep 1
systemctl daemon-reload
done
}
install_photon_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2023-04-21 12:45:35 -07:00
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2023-04-21 12:45:35 -07:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2023-04-21 12:45:35 -07:00
2024-06-28 17:04:56 -06:00
systemctl stop salt-$fname > /dev/null 2>& 1
systemctl start salt-$fname .service && continue
2023-04-21 12:45:35 -07:00
echodebug " Failed to start salt- $fname using systemd "
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2023-04-21 12:45:35 -07:00
journalctl -xe
fi
done
}
install_photon_check_services( ) {
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2023-04-21 12:45:35 -07:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2023-04-21 12:45:35 -07:00
2024-06-28 17:04:56 -06:00
__check_services_systemd salt-$fname || return 1
2023-04-21 12:45:35 -07:00
done
return 0
}
install_photon_onedir_deps( ) {
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
tdnf -y update || return 1
fi
if [ " $_DISABLE_REPOS " -eq " $BS_TRUE " ] && [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -eq 3 ] ; then
echowarn "Detected -r or -R option while installing Salt packages for Python 3."
echowarn "Python 3 packages for older Salt releases requires the EPEL repository to be installed."
echowarn "Installing the EPEL repository automatically is disabled when using the -r or -R options."
fi
if [ " $_DISABLE_REPOS " -eq " $BS_FALSE " ] ; then
__install_saltstack_photon_onedir_repository || return 1
fi
# If -R was passed, we need to configure custom repo url with rsync-ed packages
2024-06-28 17:04:56 -06:00
# Which was handled in __install_saltstack_rhel_repository buu that hanlded old-stable which is for
# releases which are End-Of-Life. This call has its own check in case -r was passed without -R.
2023-04-21 12:45:35 -07:00
if [ " $_CUSTOM_REPO_URL " != "null" ] ; then
__install_saltstack_photon_onedir_repository || return 1
fi
__PACKAGES = "procps-ng"
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2023-04-21 12:45:35 -07:00
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __tdnf_install_noinput "${__PACKAGES}" || return 1
__tdnf_install_noinput ${ __PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-27 11:34:44 -06:00
## DGM __tdnf_install_noinput "${_EXTRA_PACKAGES}" || return 1
__tdnf_install_noinput ${ _EXTRA_PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
fi
return 0
}
install_photon_onedir( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
STABLE_REV = $ONEDIR_REV
2023-04-21 12:45:35 -07:00
__PACKAGES = ""
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-master "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] ; then
2023-04-21 12:45:35 -07:00
__PACKAGES = " ${ __PACKAGES } salt-syndic "
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2023-04-21 12:45:35 -07:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __tdnf_install_noinput "${__PACKAGES}" || return 1
__tdnf_install_noinput ${ __PACKAGES } || return 1
2023-04-21 12:45:35 -07:00
return 0
}
install_photon_onedir_post( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
STABLE_REV = $ONEDIR_REV
2023-04-21 12:45:35 -07:00
install_photon_stable_post || return 1
return 0
}
#
# Ended Fedora Install Functions
#
#######################################################################################################################
2012-10-23 08:09:12 +01:00
2024-02-08 09:28:56 -07:00
2014-02-20 10:36:34 +00:00
#######################################################################################################################
2013-02-25 17:03:46 +00:00
#
# openSUSE Install Functions.
#
2015-04-30 13:06:02 +01:00
__ZYPPER_REQUIRES_REPLACE_FILES = -1
2017-10-03 19:50:35 -04:00
__set_suse_pkg_repo( ) {
2017-06-26 12:15:07 +03:00
2017-10-03 19:50:35 -04:00
# Set distro repo variable
if [ " ${ DISTRO_MAJOR_VERSION } " -gt 2015 ] ; then
DISTRO_REPO = "openSUSE_Tumbleweed"
2022-06-17 13:17:21 +01:00
elif [ " ${ DISTRO_MAJOR_VERSION } " -eq 15 ] && [ " ${ DISTRO_MINOR_VERSION } " -ge 4 ] ; then
DISTRO_REPO = " ${ DISTRO_MAJOR_VERSION } . ${ DISTRO_MINOR_VERSION } "
2018-07-11 11:11:58 -04:00
elif [ " ${ DISTRO_MAJOR_VERSION } " -ge 42 ] || [ " ${ DISTRO_MAJOR_VERSION } " -eq 15 ] ; then
2017-10-03 19:50:35 -04:00
DISTRO_REPO = " openSUSE_Leap_ ${ DISTRO_MAJOR_VERSION } . ${ DISTRO_MINOR_VERSION } "
2018-07-11 11:11:58 -04:00
else
DISTRO_REPO = " SLE_ ${ DISTRO_MAJOR_VERSION } _SP ${ SUSE_PATCHLEVEL } "
2017-06-26 12:15:07 +03:00
fi
2023-06-24 10:30:47 -07:00
suse_pkg_url_base = "https://download.opensuse.org/repositories/systemsmanagement:/saltstack"
suse_pkg_url_path = " ${ DISTRO_REPO } /systemsmanagement:saltstack.repo "
2016-08-18 17:39:11 +03:00
SUSE_PKG_URL = " $suse_pkg_url_base / $suse_pkg_url_path "
}
2017-10-03 19:50:35 -04:00
__check_and_refresh_suse_pkg_repo( ) {
# Check to see if systemsmanagement_saltstack exists
2017-10-05 16:23:25 -04:00
__zypper repos | grep -q systemsmanagement_saltstack
2017-10-03 19:50:35 -04:00
if [ $? -eq 1 ] ; then
# zypper does not yet know anything about systemsmanagement_saltstack
__zypper addrepo --refresh " ${ SUSE_PKG_URL } " || return 1
fi
}
2014-11-23 00:59:52 +03:00
__version_lte( ) {
2016-01-25 09:00:32 -05:00
if ! __check_command_exists python; then
2020-01-30 13:14:47 +00:00
zypper --non-interactive install --replacefiles --auto-agree-with-licenses python || \
zypper --non-interactive install --auto-agree-with-licenses python || return 1
2015-04-30 13:06:02 +01:00
fi
2023-06-24 10:30:47 -07:00
if [ " $( ${ _PY_EXE } -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
2024-06-28 17:04:56 -06:00
__ZYPPER_REQUIRES_REPLACE_FILES = ${ BS_TRUE }
2015-04-30 13:06:02 +01:00
else
2024-06-28 17:04:56 -06:00
__ZYPPER_REQUIRES_REPLACE_FILES = ${ BS_FALSE }
2015-04-30 13:06:02 +01:00
fi
2014-11-23 00:59:52 +03:00
}
2015-04-30 13:06:02 +01:00
__zypper( ) {
2017-12-15 15:28:27 -05:00
# Check if any zypper process is running before calling zypper again.
# This is useful when a zypper call is part of a boot process and will
# wait until the zypper process is finished, such as on AWS AMIs.
while pgrep -l zypper; do
sleep 1
done
2020-02-14 19:17:52 +01:00
zypper --non-interactive " ${ @ } "
2020-02-14 18:53:38 +01:00
# Return codes between 100 and 104 are only informations, not errors
# https://en.opensuse.org/SDB:Zypper_manual#EXIT_CODES
2020-02-14 18:58:15 +01:00
if [ " $? " -gt "99" ] && [ " $? " -le "104" ] ; then
2020-02-14 18:53:38 +01:00
return 0
fi
2020-02-14 19:15:27 +01:00
return $?
2015-04-30 13:06:02 +01:00
}
__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
2020-02-14 18:53:38 +01:00
__zypper install --auto-agree-with-licenses --replacefiles " ${ @ } " ; return $?
2020-02-14 19:17:52 +01:00
else
__zypper install --auto-agree-with-licenses " ${ @ } " ; return $?
2015-04-30 13:06:02 +01:00
fi
2014-11-23 00:59:52 +03:00
}
2018-07-12 17:39:00 -04:00
__opensuse_prep_install( ) {
# DRY function for common installation preparatory steps for SUSE
2024-06-28 17:04:56 -06:00
if [ " $_DISABLE_REPOS " -eq $BS_FALSE ] ; then
2016-04-18 11:57:24 -06:00
# Is the repository already known
__set_suse_pkg_repo
2016-09-27 11:19:32 -06:00
# Check zypper repos and refresh if necessary
__check_and_refresh_suse_pkg_repo
2013-04-10 17:25:09 +01:00
fi
2015-04-30 13:06:02 +01:00
__zypper --gpg-auto-import-keys refresh
2018-07-12 17:39:00 -04:00
2018-07-09 12:49:11 -04:00
# shellcheck disable=SC2181
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
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2018-07-12 17:39:00 -04:00
__zypper --gpg-auto-import-keys update || return 1
fi
}
install_opensuse_stable_deps( ) {
__opensuse_prep_install || return 1
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
2017-10-03 19:50:35 -04:00
# YAML module is used for generating custom master/minion configs
# requests is still used by many salt modules
2014-07-19 18:02:42 +01:00
# Salt needs python-zypp installed in order to use the zypper module
2024-07-01 11:48:29 -06:00
__PACKAGES = " python ${ PY_PKG_VER } -PyYAML python ${ PY_PKG_VER } -requests python ${ PY_PKG_VER } -zypp "
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2015-11-19 14:02:17 +03:00
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __zypper_install "${__PACKAGES}" || return 1
__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
2024-06-28 17:04:56 -06:00
## DGM __zypper_install "${_EXTRA_PACKAGES}" || return 1
__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( ) {
2024-06-28 17:04:56 -06:00
if [ " $_INSECURE_DL " -eq $BS_FALSE ] && [ " ${ _SALT_REPO_URL %% : //* } " = "https" ] && ! __check_command_exists update-ca-certificates; then
2016-11-29 18:09:48 +02:00
__zypper_install ca-certificates || return 1
fi
2013-03-23 11:55:45 +00:00
install_opensuse_stable_deps || return 1
2015-04-30 12:12:22 +01:00
2016-01-25 09:00:32 -05:00
if ! __check_command_exists 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-03-06 22:05:31 +00:00
__git_clone_and_checkout || return 1
2013-02-25 17:03:46 +00:00
2024-06-27 14:18:42 -06:00
# Check for Tumbleweed
2024-02-02 17:57:31 -07:00
if [ " ${ DISTRO_MAJOR_VERSION } " -ge 20210101 ] ; then
2022-06-19 20:42:57 +01:00
__PACKAGES = "python3-pip gcc-c++ python3-pyzmq-devel"
2020-01-30 12:36:56 +00:00
else
2024-02-02 17:57:31 -07:00
__PACKAGES = "python3-pip python3-setuptools gcc"
2015-05-01 14:30:55 +01:00
fi
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2016-08-09 12:20:52 +03:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __zypper_install "${__PACKAGES}" || return 1
__zypper_install ${ __PACKAGES } || return 1
2016-08-09 12:20:52 +03:00
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
2016-03-07 11:38:28 +02: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
}
2023-04-14 07:08:28 -07:00
install_opensuse_onedir_deps( ) {
install_opensuse_stable_deps || return 1
}
2013-02-25 17:03:46 +00:00
install_opensuse_stable( ) {
2014-07-06 00:38:13 +01:00
__PACKAGES = ""
2016-08-09 12:20:52 +03:00
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2016-08-09 12:20:52 +03:00
__PACKAGES = " ${ __PACKAGES } salt-cloud "
2013-02-25 17:03:46 +00:00
fi
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2016-08-09 12:20:52 +03:00
__PACKAGES = " ${ __PACKAGES } salt-minion "
fi
2024-06-28 17:04:56 -06: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
2016-08-09 12:20:52 +03:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2014-06-22 10:40:05 +01:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __zypper_install "$__PACKAGES" || return 1
__zypper_install $__PACKAGES || return 1
2016-08-09 12:20:52 +03:00
2013-03-23 11:55:45 +00:00
return 0
2013-02-25 17:03:46 +00:00
}
install_opensuse_git( ) {
2024-02-08 09:28:56 -07:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
2013-03-23 11:55:45 +00:00
return 0
2013-02-25 17:03:46 +00:00
}
2023-04-14 07:08:28 -07:00
install_opensuse_onedir( ) {
install_opensuse_stable || return 1
}
2013-02-25 17:03:46 +00:00
install_opensuse_stable_post( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-02-25 17:03:46 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-25 17:03:46 +00:00
2020-03-26 23:32:34 +00:00
if [ -f /bin/systemctl ] || [ -f /usr/bin/systemctl ] ; then
2024-06-28 17:04:56 -06:00
systemctl is-enabled salt-$fname .service || ( systemctl preset salt-$fname .service && systemctl enable salt-$fname .service)
2017-05-26 16:49:43 +02:00
sleep 1
2013-02-26 18:16:26 +00:00
systemctl daemon-reload
continue
fi
2024-06-28 17:04:56 -06:00
/sbin/chkconfig --add salt-$fname
/sbin/chkconfig salt-$fname on
2013-02-25 17:03:46 +00:00
done
2016-08-13 18:58:38 +03:00
return 0
2013-02-25 17:03:46 +00:00
}
install_opensuse_git_post( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; do
2013-02-25 17:03:46 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-02-25 17:03:46 +00:00
2021-01-20 09:43:08 +00:00
if command -v systemctl; then
2024-06-28 17:04:56 -06:00
use_usr_lib = $BS_FALSE
2016-08-13 18:58:38 +03:00
2018-07-11 11:11:58 -04:00
if [ " ${ DISTRO_MAJOR_VERSION } " -ge 15 ] ; then
2024-06-28 17:04:56 -06:00
use_usr_lib = $BS_TRUE
2016-07-05 12:33:05 -06:00
fi
if [ " ${ DISTRO_MAJOR_VERSION } " -eq 12 ] && [ -d "/usr/lib/systemd/" ] ; then
2024-06-28 17:04:56 -06:00
use_usr_lib = $BS_TRUE
2016-07-05 12:33:05 -06:00
fi
2023-02-02 10:20:50 -08:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common "
else
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/ "
fi
2024-06-28 17:04:56 -06:00
if [ " ${ use_usr_lib } " -eq $BS_TRUE ] ; then
2023-02-02 10:20:50 -08:00
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " " /usr/lib/systemd/system/salt- ${ fname } .service "
2015-05-01 19:12:31 +01:00
else
2023-02-02 10:20:50 -08:00
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
2015-05-01 19:12:31 +01:00
fi
2016-08-13 18:58:38 +03:00
2013-02-26 18:16:26 +00:00
continue
fi
2016-03-07 11:38:28 +02:00
__copyfile " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/rpm/salt- $fname " " /etc/init.d/salt- $fname "
2024-06-28 17:04:56 -06: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
2016-08-13 18:58:38 +03:00
install_opensuse_stable_post || return 1
return 0
2013-02-25 17:03:46 +00:00
}
2023-04-14 07:08:28 -07:00
install_opensuse_onedir_post( ) {
install_opensuse_stable_post || return 1
}
2013-02-25 17:03:46 +00:00
install_opensuse_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-02-25 17:03:46 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $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
2024-06-28 17:04:56 -06:00
systemctl stop salt-$fname > /dev/null 2>& 1
systemctl start salt-$fname .service && continue
2020-01-30 12:36:56 +00:00
echodebug " Failed to start salt- $fname using systemd "
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2020-01-30 12:36:56 +00:00
journalctl -xe
fi
2013-02-26 18:16:26 +00:00
fi
2024-06-28 17:04:56 -06:00
service salt-$fname stop > /dev/null 2>& 1
service salt-$fname start
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
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-08-23 23:28:09 +01:00
2014-02-20 12:04:42 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2016-08-13 18:58:38 +03:00
2024-06-28 17:04:56 -06: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
2016-08-13 18:58:38 +03:00
2014-02-20 12:04:42 +00:00
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
#
2018-07-12 17:39:00 -04:00
# openSUSE Leap 15
2013-02-19 21:30:51 +00:00
#
2016-02-04 01:35:47 -07:00
2018-07-12 17:39:00 -04:00
install_opensuse_15_stable_deps( ) {
__opensuse_prep_install || return 1
# SUSE only packages Salt for Python 3 on Leap 15
# Py3 is the default bootstrap install for Leap 15
2024-02-08 09:28:56 -07:00
# However, git installs that specify "-x python2" are disallowed
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
2016-02-04 01:35:47 -07:00
fi
2018-07-12 17:39:00 -04:00
# YAML module is used for generating custom master/minion configs
# requests is still used by many salt modules
__PACKAGES = " python ${ PY_PKG_VER } -PyYAML python ${ PY_PKG_VER } -requests "
2016-02-04 01:35:47 -07:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2018-07-12 17:39:00 -04:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __zypper_install "${__PACKAGES}" || return 1
__zypper_install ${ __PACKAGES } || return 1
2018-07-12 17:39:00 -04:00
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __zypper_install "${_EXTRA_PACKAGES}" || return 1
__zypper_install ${ _EXTRA_PACKAGES } || return 1
2018-07-12 17:39:00 -04:00
fi
return 0
}
install_opensuse_15_git_deps( ) {
install_opensuse_15_stable_deps || return 1
if ! __check_command_exists git; then
__zypper_install git || return 1
fi
__git_clone_and_checkout || return 1
2024-06-27 14:18:42 -06:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
echoerror "Python version is no longer supported, only Python 3"
return 1
fi
2024-02-08 09:28:56 -07:00
PY_PKG_VER = 3
__PACKAGES = " python ${ PY_PKG_VER } -xml python ${ PY_PKG_VER } -devel python ${ PY_PKG_VER } -pip python ${ PY_PKG_VER } -setuptools gcc "
2018-07-12 17:39:00 -04:00
2024-07-01 11:48:29 -06:00
## DGM tornado appears to be missing in 3006.x pkg requirements
2024-07-01 16:29:40 -06:00
## DGM __PACKAGES="${__PACKAGES} python${PY_PKG_VER}-tornado"
2024-07-01 11:48:29 -06:00
2018-07-12 17:39:00 -04:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __zypper_install "${__PACKAGES}" || return 1
__zypper_install ${ __PACKAGES } || return 1
2018-07-12 17:39:00 -04:00
# Let's trigger config_salt()
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
_TEMP_CONFIG_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /conf/ "
CONFIG_SALT_FUNC = "config_salt"
fi
return 0
}
install_opensuse_15_git( ) {
# Py3 is the default bootstrap install for Leap 15
if [ -n " $_PY_EXE " ] ; then
2024-02-02 15:32:40 -07:00
_PYEXE = " ${ _PY_EXE } "
2018-07-12 17:39:00 -04:00
else
_PYEXE = python3
2016-02-04 01:35:47 -07:00
fi
2024-02-08 09:28:56 -07:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
2018-07-12 17:39:00 -04:00
return 0
}
2023-06-24 10:30:47 -07:00
install_opensuse_15_onedir_deps( ) {
__opensuse_prep_install || return 1
return 0
}
2018-07-12 17:39:00 -04:00
#
# End of openSUSE Leap 15
#
#######################################################################################################################
2020-02-14 18:25:47 +01:00
#######################################################################################################################
#
# SUSE Enterprise 15
#
install_suse_15_stable_deps( ) {
__opensuse_prep_install || return 1
2020-02-15 16:45:56 +01:00
install_opensuse_15_stable_deps || return 1
2020-02-14 18:25:47 +01:00
return 0
}
install_suse_15_git_deps( ) {
2020-02-15 16:52:23 +01:00
install_suse_15_stable_deps || return 1
2020-02-14 18:25:47 +01:00
if ! __check_command_exists git; then
__zypper_install git-core || return 1
fi
2020-02-15 16:09:03 +01:00
install_opensuse_15_git_deps || return 1
2020-02-14 18:25:47 +01:00
return 0
}
2023-06-24 10:30:47 -07:00
install_suse_15_onedir_deps( ) {
__opensuse_prep_install || return 1
install_opensuse_15_onedir_deps || return 1
return 0
}
2020-02-14 18:25:47 +01:00
install_suse_15_stable( ) {
install_opensuse_stable || return 1
return 0
}
install_suse_15_git( ) {
2020-02-15 16:20:48 +01:00
install_opensuse_15_git || return 1
2020-02-14 18:25:47 +01:00
return 0
}
2023-06-24 10:30:47 -07:00
install_suse_15_onedir( ) {
install_opensuse_stable || return 1
return 0
}
2020-02-14 18:25:47 +01:00
install_suse_15_stable_post( ) {
install_opensuse_stable_post || return 1
return 0
}
install_suse_15_git_post( ) {
install_opensuse_git_post || return 1
return 0
}
2023-06-24 10:30:47 -07:00
install_suse_15_onedir_post( ) {
install_opensuse_stable_post || return 1
return 0
}
2020-02-14 18:25:47 +01:00
install_suse_15_restart_daemons( ) {
install_opensuse_restart_daemons || return 1
return 0
}
#
# End of SUSE Enterprise 15
#
#######################################################################################################################
2018-07-12 17:39:00 -04: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.
#
2017-06-01 20:12:24 -04:00
__autounmask( ) {
2020-09-25 16:28:26 +02:00
# Unmask package(s) and accept changes
#
# 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
export CONFIG_PROTECT_MASK = " ${ CONFIG_PROTECT_MASK :- }
/etc/portage/package.accept_keywords
/etc/portage/package.keywords
/etc/portage/package.license
/etc/portage/package.unmask
/etc/portage/package.use"
emerge --autounmask --autounmask-continue --autounmask-only --autounmask-write " ${ @ } " ; return $?
2017-06-01 20:12:24 -04:00
}
2013-08-09 00:04:06 +01:00
__emerge( ) {
2020-09-25 16:28:26 +02:00
EMERGE_FLAGS = '-q'
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
2020-09-25 16:28:26 +02:00
EMERGE_FLAGS = '-v'
2013-06-21 15:41:19 +01:00
fi
2013-05-29 19:27:02 +01:00
2020-09-25 16:28:26 +02:00
# Do not re-emerge packages that are already installed
EMERGE_FLAGS = " ${ EMERGE_FLAGS } --noreplace "
2024-06-28 17:04:56 -06:00
if [ " $_GENTOO_USE_BINHOST " -eq $BS_TRUE ] ; then
2020-09-25 16:28:26 +02:00
EMERGE_FLAGS = " ${ EMERGE_FLAGS } --getbinpkg "
fi
2017-06-01 19:52:38 -04:00
2020-09-25 16:28:26 +02:00
# shellcheck disable=SC2086
emerge ${ EMERGE_FLAGS } " ${ @ } " ; return $?
2013-06-21 15:41:19 +01:00
}
2013-05-29 19:27:02 +01:00
__gentoo_pre_dep( ) {
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
2016-01-25 09:00:32 -05:00
if __check_command_exists 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
2016-01-25 09:00:32 -05:00
if __check_command_exists 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
2014-02-16 18:09:20 +00:00
2020-12-11 16:54:21 +01:00
# Enable Python 3.7 target for Salt Neon using GIT
if [ " ${ ITYPE } " = "git" ] && [ " ${ GIT_REV } " = "v3000" ] ; then
EXTRA_PYTHON_TARGET = python3_7
fi
if [ -n " ${ EXTRA_PYTHON_TARGET :- } " ] ; then
if ! emerge --info | sed 's/.*\(PYTHON_TARGETS="[^"]*"\).*/\1/' | grep -q " ${ EXTRA_PYTHON_TARGET } " ; then
echo " PYTHON_TARGETS=\"\${PYTHON_TARGETS} ${ EXTRA_PYTHON_TARGET } \" " >> /etc/portage/make.conf
2020-12-19 08:43:42 +01:00
emerge --deep --with-bdeps= y --newuse --quiet @world
2020-09-25 16:28:26 +02:00
fi
2014-02-16 18:09:20 +00:00
fi
2020-09-25 16:28:26 +02:00
}
2014-02-16 18:09:20 +00:00
2020-09-25 16:28:26 +02:00
__gentoo_post_dep( ) {
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
2024-06-28 17:04:56 -06:00
## DGM __autounmask "${_EXTRA_PACKAGES}" || return 1
__autounmask ${ _EXTRA_PACKAGES } || return 1
2017-06-02 09:40:24 -06:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __emerge "${_EXTRA_PACKAGES}" || return 1
__emerge ${ _EXTRA_PACKAGES } || return 1
2014-02-16 21:38:15 +00:00
fi
2020-09-25 16:28:26 +02:00
return 0
2013-05-29 19:27:02 +01:00
}
install_gentoo_deps( ) {
__gentoo_pre_dep || return 1
2020-09-25 16:28:26 +02:00
# Make sure that the 'libcloud' use flag is set when Salt Cloud support is requested
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2020-09-25 16:28:26 +02:00
SALT_USE_FILE = '/etc/portage/package.use'
if [ -d '/etc/portage/package.use' ] ; then
SALT_USE_FILE = '/etc/portage/package.use/salt'
fi
2024-06-28 17:04:56 -06:00
SALT_USE_FLAGS = " $( grep -E '^[<>=~]*app-admin/salt.*' ${ SALT_USE_FILE } 2>/dev/null) "
2020-09-25 16:28:26 +02:00
SALT_USE_FLAG_LIBCLOUD = " $( echo " ${ SALT_USE_FLAGS } " | grep ' libcloud' 2>/dev/null) "
# Set the libcloud use flag, if it is not set yet
if [ -z " ${ SALT_USE_FLAGS } " ] ; then
2024-06-28 17:04:56 -06:00
echo "app-admin/salt libcloud" >> ${ SALT_USE_FILE }
2020-09-25 16:28:26 +02:00
elif [ -z " ${ SALT_USE_FLAG_LIBCLOUD } " ] ; then
2024-06-28 17:04:56 -06:00
sed 's#^\([<>=~]*app-admin/salt[^ ]*\)\(.*\)#\1 libcloud\2#g' -i ${ SALT_USE_FILE }
2020-09-25 16:28:26 +02:00
fi
fi
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
2020-09-25 16:28:26 +02:00
# Install pip if it does not exist
if ! __check_command_exists pip ; then
2020-12-11 16:54:21 +01:00
GENTOO_GIT_PACKAGES = " ${ GENTOO_GIT_PACKAGES :- } dev-python/pip "
2020-09-25 16:28:26 +02:00
fi
# Install GIT if it does not exist
if ! __check_command_exists git ; then
2020-12-11 16:54:21 +01:00
GENTOO_GIT_PACKAGES = " ${ GENTOO_GIT_PACKAGES :- } dev-vcs/git "
2020-09-25 16:28:26 +02:00
fi
# Install libcloud when Salt Cloud support was requested
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2020-12-11 16:54:21 +01:00
GENTOO_GIT_PACKAGES = " ${ GENTOO_GIT_PACKAGES :- } dev-python/libcloud "
2020-09-25 16:28:26 +02:00
fi
2020-12-11 16:54:21 +01:00
if [ -n " ${ GENTOO_GIT_PACKAGES :- } " ] ; then
2020-09-25 16:28:26 +02:00
# shellcheck disable=SC2086
__autounmask ${ GENTOO_GIT_PACKAGES } || return 1
# shellcheck disable=SC2086
__emerge ${ GENTOO_GIT_PACKAGES } || return 1
fi
2023-02-03 18:56:22 -08:00
echoinfo "Running emerge -v1 setuptools"
2023-02-03 18:27:12 -08:00
__emerge -v1 setuptools || return 1
2020-09-25 16:28:26 +02:00
__git_clone_and_checkout || 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( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2020-09-25 16:28:26 +02:00
GENTOO_SALT_PACKAGE = "app-admin/salt"
STABLE_REV_WITHOUT_PREFIX = $( echo " ${ STABLE_REV } " | sed 's#archive/##' )
if [ " ${ STABLE_REV_WITHOUT_PREFIX } " != "latest" ] ; then
GENTOO_SALT_PACKAGE = " =app-admin/salt- ${ STABLE_REV_WITHOUT_PREFIX } * "
fi
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __autounmask "${GENTOO_SALT_PACKAGE}" || return 1
__autounmask ${ GENTOO_SALT_PACKAGE } || return 1
2020-09-25 16:28:26 +02:00
# shellcheck disable=SC2086
2024-06-28 17:04:56 -06:00
## DGM __emerge "${GENTOO_SALT_PACKAGE}" || return 1
__emerge ${ GENTOO_SALT_PACKAGE } || return 1
2013-05-29 19:27:02 +01:00
}
install_gentoo_git( ) {
2024-02-02 15:32:40 -07:00
_PYEXE = " ${ _PY_EXE } "
2020-09-25 16:28:26 +02:00
if [ " $_PY_EXE " = "python3" ] || [ -z " $_PY_EXE " ] ; then
2024-02-08 09:28:56 -07:00
_PYEXE = $( emerge --info | grep -oE 'PYTHON_SINGLE_TARGET="[^"]*"' | sed -e 's/"//g' -e 's/_/./g' | cut -d= -f2)
2020-09-25 16:28:26 +02:00
fi
2024-02-08 09:28:56 -07:00
__install_salt_from_repo_post_neon " ${ _PYEXE } " || return 1
2020-09-25 16:28:26 +02:00
return 0
2013-05-29 19:27:02 +01:00
}
2023-04-14 07:08:28 -07:00
install_gentoo_onedir( ) {
2024-07-01 13:45:45 -06:00
## DGM Debugging
set -v
set -x
2024-06-28 17:04:56 -06:00
STABLE_REV = ${ ONEDIR_REV }
2023-04-14 07:08:28 -07:00
install_gentoo_stable || return 1
}
2013-05-29 19:27:02 +01:00
install_gentoo_post( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-05-29 19:27:02 +01:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-05-29 19:27:02 +01:00
2020-09-25 16:28:26 +02:00
if __check_command_exists systemctl ; then
2024-06-28 17:04:56 -06:00
systemctl is-enabled salt-$fname .service > /dev/null 2>& 1 || (
systemctl preset salt-$fname .service > /dev/null 2>& 1 &&
systemctl enable salt-$fname .service > /dev/null 2>& 1
2020-09-25 16:28:26 +02:00
)
2013-09-24 02:17:10 +02:00
else
2020-09-25 16:28:26 +02:00
# Salt minion cannot start in a docker container because the "net" service is not available
2024-06-28 17:04:56 -06:00
if [ $fname = "minion" ] && [ -f /.dockerenv ] ; then
sed '/need net/d' -i /etc/init.d/salt-$fname
2020-09-25 16:28:26 +02:00
fi
rc-update add " salt- $fname " > /dev/null 2>& 1 || return 1
2013-09-24 02:17:10 +02:00
fi
2013-05-29 19:27:02 +01:00
done
}
2020-09-25 16:28:26 +02:00
install_gentoo_git_post( ) {
for fname in api master minion syndic; do
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && \
( [ " $_INSTALL_MASTER " -eq $BS_FALSE ] || ! __check_command_exists " salt- ${ fname } " ) && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2020-09-25 16:28:26 +02:00
2023-02-02 10:28:31 -08:00
# Account for new path for services files in later releases
if [ -f " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common/salt- ${ fname } .service " ] ; then
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg/common "
else
_SERVICE_DIR = " ${ _SALT_GIT_CHECKOUT_DIR } /pkg "
fi
2020-09-25 16:28:26 +02:00
if __check_command_exists systemctl ; then
2023-02-02 10:28:31 -08:00
__copyfile " ${ _SERVICE_DIR } /salt- ${ fname } .service " " /lib/systemd/system/salt- ${ fname } .service "
2020-09-25 16:28:26 +02:00
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2020-09-25 16:28:26 +02:00
2024-06-28 17:04:56 -06:00
systemctl is-enabled salt-$fname .service > /dev/null 2>& 1 || (
systemctl preset salt-$fname .service > /dev/null 2>& 1 &&
systemctl enable salt-$fname .service > /dev/null 2>& 1
2020-09-25 16:28:26 +02:00
)
else
cat <<_eof > " /etc/init.d/salt- ${ fname } "
#!/sbin/openrc-run
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
command = " /usr/bin/salt- ${ fname } "
command_args = "\${SALT_OPTS}"
command_background = "1"
pidfile = " /var/run/salt- ${ fname } .pid "
name = " SALT ${ fname } daemon "
retry = "20"
depend( ) {
use net logger
}
_eof
2024-06-28 17:04:56 -06:00
chmod +x /etc/init.d/salt-$fname
2020-09-25 16:28:26 +02:00
cat <<_eof > " /etc/conf.d/salt- ${ fname } "
# /etc/conf.d/salt-${fname}: config file for /etc/init.d/salt-master
# see man pages for salt-${fname} or run 'salt-${fname} --help'
# for valid cmdline options
SALT_OPTS = "--log-level=warning"
_eof
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2020-09-25 16:28:26 +02:00
rc-update add " salt- $fname " > /dev/null 2>& 1 || return 1
fi
done
return 0
}
2023-04-14 07:08:28 -07:00
install_gentoo_onedir_post( ) {
install_gentoo_post || return 1
}
2013-05-29 19:27:02 +01:00
install_gentoo_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2013-10-24 16:49:04 +02:00
2020-09-25 16:28:26 +02:00
# Ensure upstart configs / systemd units are loaded
if __check_command_exists systemctl ; then
systemctl daemon-reload
fi
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-05-29 19:27:02 +01:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-05-29 19:27:02 +01:00
2020-09-25 16:28:26 +02:00
if __check_command_exists systemctl ; then
2024-06-28 17:04:56 -06:00
systemctl stop salt-$fname > /dev/null 2>& 1
systemctl start salt-$fname .service && continue
2020-01-30 12:36:56 +00:00
echodebug " Failed to start salt- $fname using systemd "
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_TRUE ] ; then
systemctl status salt-$fname .service
2020-01-30 12:36:56 +00:00
journalctl -xe
fi
2013-09-24 02:01:48 +02:00
else
2020-09-25 16:28:26 +02:00
# Disable stdin to fix shell session hang on killing tee pipe
2024-06-28 17:04:56 -06:00
rc-service salt-$fname stop < /dev/null > /dev/null 2>& 1
rc-service salt-$fname start < /dev/null || return 1
2013-09-24 02:01:48 +02:00
fi
2013-05-29 19:27:02 +01:00
done
2020-09-25 16:28:26 +02:00
return 0
2013-05-29 19:27:02 +01:00
}
2014-02-20 12:07:05 +00:00
install_gentoo_check_services( ) {
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-08-23 23:28:09 +01:00
2014-02-20 12:07:05 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2016-08-13 18:58:38 +03:00
2020-09-25 16:28:26 +02:00
if __check_command_exists systemctl ; then
2024-06-28 17:04:56 -06:00
__check_services_systemd salt-$fname || return 1
2020-09-25 16:28:26 +02:00
else
2024-06-28 17:04:56 -06:00
__check_services_openrc salt-$fname || return 1
2020-09-25 16:28:26 +02:00
fi
2014-02-20 12:07:05 +00:00
done
2016-08-13 18:58:38 +03:00
2014-02-20 12:07:05 +00:00
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
2017-02-06 14:32:30 -05:00
#######################################################################################################################
#
# VoidLinux Install Functions
#
install_voidlinux_stable_deps( ) {
2024-06-28 17:04:56 -06:00
if [ " $_UPGRADE_SYS " -eq $BS_TRUE ] ; then
2017-02-06 14:32:30 -05:00
xbps-install -Suy || return 1
fi
if [ " ${ _EXTRA_PACKAGES } " != "" ] ; then
echoinfo " Installing the following extra packages as requested: ${ _EXTRA_PACKAGES } "
2017-02-06 14:41:44 -05:00
xbps-install -Suy " ${ _EXTRA_PACKAGES } " || return 1
2017-02-06 14:32:30 -05:00
fi
return 0
}
install_voidlinux_stable( ) {
xbps-install -Suy salt || return 1
return 0
}
install_voidlinux_stable_post( ) {
for fname in master minion syndic; do
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-02-06 14:32:30 -05:00
2024-06-28 17:04:56 -06:00
ln -s /etc/sv/salt-$fname /var/service/.
2017-02-06 14:32:30 -05:00
done
}
install_voidlinux_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2017-02-06 14:32:30 -05:00
for fname in master minion syndic; do
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-02-06 14:32:30 -05:00
2024-06-28 17:04:56 -06:00
sv restart salt-$fname
2017-02-06 14:32:30 -05:00
done
}
install_voidlinux_check_services( ) {
for fname in master minion syndic; do
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-02-06 14:32:30 -05:00
2024-06-28 17:04:56 -06:00
[ -e /var/service/salt-$fname ] || return 1
2017-02-06 14:32:30 -05:00
done
return 0
}
daemons_running_voidlinux( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return 0
2017-02-06 14:32:30 -05:00
FAILED_DAEMONS = 0
for fname in master minion syndic; do
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2017-02-06 14:32:30 -05:00
2024-06-28 17:04:56 -06:00
if [ " $( sv status salt-$fname | grep run) " = "" ] ; then
2017-02-06 14:32:30 -05:00
echoerror " salt- $fname was not found running "
FAILED_DAEMONS = $(( FAILED_DAEMONS + 1 ))
fi
done
2024-06-28 17:04:56 -06:00
return $FAILED_DAEMONS
2017-02-06 14:32:30 -05:00
}
#
# Ended VoidLinux Install Functions
#
#######################################################################################################################
2019-08-28 13:15:23 -07:00
#######################################################################################################################
#
# OS X / Darwin Install Functions
#
2024-07-01 11:48:29 -06:00
## DGM __macosx_get_packagesite() {
## DGM
## DGM if [ -n "$_PY_EXE" ] && [ "$_PY_MAJOR_VERSION" -ne 3 ]; then
## DGM echoerror "Python 2 is no longer supported, only Python 3"
## DGM return 1
## DGM fi
## DGM
## DGM # TBD DGM need to update for arch and 3006+ repo locations
## DGM
## DGM DARWIN_ARCH="x86_64"
## DGM PKG="salt-${STABLE_REV}-${__PY_VERSION_REPO}-${DARWIN_ARCH}.pkg"
## DGM SALTPKGCONFURL="https://${_REPO_URL}/osx/${PKG}"
## DGM }
2019-08-28 13:15:23 -07:00
2023-04-13 18:58:29 -07:00
__parse_repo_json_python( ) {
# Using latest, grab the right
# version from the repo.json
2023-04-19 12:39:29 -07:00
_JSON_VERSION = $( python - <<-EOF
2023-04-13 18:58:29 -07:00
import json, urllib.request
url = "https://repo.saltproject.io/salt/py3/macos/repo.json"
response = urllib.request.urlopen( url)
data = json.loads( response.read( ) )
2023-04-19 12:39:29 -07:00
version = data[ " ${ _ONEDIR_REV } " ] [ list( data[ " ${ _ONEDIR_REV } " ] ) [ 0] ] [ 'version' ]
2023-04-13 18:58:29 -07:00
print( version)
EOF
)
2023-04-19 12:39:29 -07:00
echo " ${ _JSON_VERSION } "
2023-04-13 18:58:29 -07:00
}
2023-03-31 12:57:37 -07:00
__macosx_get_packagesite_onedir( ) {
2024-02-08 09:28:56 -07:00
# TBD DGM need to update for arch and 3006+ repo locations
2023-03-31 12:57:37 -07:00
2024-02-08 09:28:56 -07:00
if [ -n " $_PY_EXE " ] && [ " $_PY_MAJOR_VERSION " -ne 3 ] ; then
2024-06-26 12:00:17 -06:00
echoerror "Python version is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2023-03-31 12:57:37 -07:00
fi
2024-06-20 11:04:19 -06:00
## DGM TBD need to allow for arm64 arch too
2024-02-08 09:28:56 -07:00
DARWIN_ARCH = "x86_64"
2023-04-14 05:46:31 -07:00
if [ " $( echo " $_ONEDIR_REV " | grep -E '^(latest)$' ) " != "" ] ; then
2023-04-19 12:39:29 -07:00
_PKG_VERSION = $( __parse_repo_json_python)
2024-06-25 15:56:18 -06:00
elif [ " $( echo " $_ONEDIR_REV " | grep -E '^([3-9][0-9]{3}(\.[0-9]*))' ) " != "" ] ; then
2023-04-19 12:39:29 -07:00
_PKG_VERSION = $_ONEDIR_REV
else
_PKG_VERSION = $( __parse_repo_json_python)
2023-04-14 05:46:31 -07:00
fi
2024-02-08 09:28:56 -07:00
PKG = " salt- ${ _PKG_VERSION } - ${ __PY_VERSION_REPO } - ${ DARWIN_ARCH } .pkg "
2023-04-19 12:39:29 -07:00
SALTPKGCONFURL = " https:// ${ _REPO_URL } / ${ _ONEDIR_DIR } / ${ __PY_VERSION_REPO } /macos/ ${ ONEDIR_REV } / ${ PKG } "
2023-03-31 12:57:37 -07:00
}
2019-08-28 13:15:23 -07:00
# Using a separate conf step to head for idempotent install...
2024-07-01 11:48:29 -06:00
## DGM __configure_macosx_pkg_details() {
## DGM ## DGM __macosx_get_packagesite || return 1
## DGM __macosx_get_packagesite_onedir || return 1
## DGM return 0
## DGM }
2019-08-28 13:15:23 -07:00
2023-03-31 12:57:37 -07:00
__configure_macosx_pkg_details_onedir( ) {
__macosx_get_packagesite_onedir || return 1
return 0
}
2019-08-28 13:15:23 -07:00
install_macosx_stable_deps( ) {
2024-07-01 11:48:29 -06:00
## DGM __configure_macosx_pkg_details || return 1
__configure_macosx_pkg_details_onedir || return 1
2019-08-28 13:15:23 -07:00
return 0
}
2023-03-31 12:57:37 -07:00
install_macosx_onedir_deps( ) {
__configure_macosx_pkg_details_onedir || return 1
return 0
}
2019-08-28 13:15:23 -07:00
install_macosx_git_deps( ) {
install_macosx_stable_deps || return 1
2019-11-29 16:40:12 +00:00
if ! echo " $PATH " | grep -q /usr/local/bin; then
2019-11-06 22:56:14 +00:00
echowarn "/usr/local/bin was not found in \$PATH. Adding it for the duration of the script execution."
2024-06-28 17:04:56 -06:00
export PATH = /usr/local/bin:$PATH
2019-11-06 22:56:14 +00:00
fi
2019-08-28 13:15:23 -07:00
__fetch_url "/tmp/get-pip.py" "https://bootstrap.pypa.io/get-pip.py" || return 1
if [ -n " $_PY_EXE " ] ; then
2024-02-02 15:32:40 -07:00
_PYEXE = " ${ _PY_EXE } "
2019-08-28 13:15:23 -07:00
else
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2019-08-28 13:15:23 -07:00
fi
# Install PIP
$_PYEXE /tmp/get-pip.py || return 1
__git_clone_and_checkout || return 1
return 0
}
install_macosx_stable( ) {
install_macosx_stable_deps || return 1
2021-05-10 15:22:00 -06:00
__fetch_url " /tmp/ ${ PKG } " " ${ SALTPKGCONFURL } " || return 1
2019-08-28 13:15:23 -07:00
2019-08-28 15:27:57 -06:00
/usr/sbin/installer -pkg " /tmp/ ${ PKG } " -target / || return 1
2019-08-28 13:15:23 -07:00
return 0
}
2023-03-31 12:57:37 -07:00
install_macosx_onedir( ) {
install_macosx_onedir_deps || return 1
__fetch_url " /tmp/ ${ PKG } " " ${ SALTPKGCONFURL } " || return 1
/usr/sbin/installer -pkg " /tmp/ ${ PKG } " -target / || return 1
return 0
}
2019-08-28 13:15:23 -07:00
install_macosx_git( ) {
if [ -n " $_PY_EXE " ] ; then
2024-02-02 15:32:40 -07:00
_PYEXE = " ${ _PY_EXE } "
2019-08-28 13:15:23 -07:00
else
2024-02-08 09:28:56 -07:00
echoerror "Python 2 is no longer supported, only Python 3"
2024-02-02 17:57:31 -07:00
return 1
2020-01-28 19:20:03 +00:00
fi
2024-02-08 09:28:56 -07:00
__install_salt_from_repo_post_neon " ${ _PY_EXE } " || return 1
2019-08-28 13:15:23 -07:00
return 0
}
install_macosx_stable_post( ) {
2019-11-07 12:12:31 +00:00
if [ ! -f /etc/paths.d/salt ] ; then
print "%s\n" "/opt/salt/bin" "/usr/local/sbin" > /etc/paths.d/salt
fi
2019-08-28 13:15:23 -07:00
2019-11-07 12:12:31 +00:00
# Don'f fail because of unknown variable on the next step
set +o nounset
# shellcheck disable=SC1091
. /etc/profile
# Revert nounset to it's previous state
set -o nounset
2019-08-28 13:15:23 -07:00
2019-11-07 12:12:31 +00:00
return 0
2019-08-28 13:15:23 -07:00
}
2023-03-31 12:57:37 -07:00
install_macosx_onedir_post( ) {
install_macosx_stable_post || return 1
return 0
}
2019-08-28 13:15:23 -07:00
install_macosx_git_post( ) {
install_macosx_stable_post || return 1
return 0
}
install_macosx_restart_daemons( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return
2019-08-28 13:15:23 -07:00
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] ; then
2023-04-19 13:17:46 -07:00
/bin/launchctl unload -w /Library/LaunchDaemons/com.saltstack.salt.minion.plist || return 1
/bin/launchctl load -w /Library/LaunchDaemons/com.saltstack.salt.minion.plist || return 1
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] ; then
2023-04-19 13:17:46 -07:00
/bin/launchctl unload -w /Library/LaunchDaemons/com.saltstack.salt.master.plist || return 1
/bin/launchctl load -w /Library/LaunchDaemons/com.saltstack.salt.master.plist || return 1
fi
2019-08-28 13:15:23 -07:00
return 0
}
#
# Ended OS X / Darwin Install Functions
#
#######################################################################################################################
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
2024-06-28 17:04:56 -06:00
if [ " $_CONFIG_ONLY " -eq $BS_TRUE ] ; then
2019-12-11 15:37:50 -07:00
echowarn "Passing -C (config only) option implies -F (forced overwrite)."
2016-08-10 11:20:31 +03:00
2024-06-28 17:04:56 -06:00
if [ " $_FORCE_OVERWRITE " -ne $BS_TRUE ] ; then
2016-07-19 15:43:12 +03:00
echowarn "Overwriting configs in 11 seconds!"
sleep 11
2024-06-28 17:04:56 -06:00
_FORCE_OVERWRITE = $BS_TRUE
2016-07-19 15:43:12 +03:00
fi
fi
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
2016-05-06 12:53:11 -06:00
# If -C or -F was passed, we don't need a .bak file for the config we're updating
# This is used in the custom master/minion config file checks below
2024-06-28 17:04:56 -06:00
CREATE_BAK = $BS_TRUE
if [ " $_FORCE_OVERWRITE " -eq $BS_TRUE ] ; then
CREATE_BAK = $BS_FALSE
2016-05-06 12:53:11 -06:00
fi
2016-07-19 15:43:12 +03:00
CONFIGURED_ANYTHING = $BS_FALSE
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 "
2016-03-04 10:33:47 +02:00
__movefile " $_TEMP_CONFIG_DIR /grains " " $_SALT_ETC_DIR /grains " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2013-07-02 16:33:30 +01:00
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MINION " -eq $BS_TRUE ] || \
[ " $_CONFIG_ONLY " -eq $BS_TRUE ] || [ " $_CUSTOM_MINION_CONFIG " != "null" ] ; 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
2016-05-06 12:53:11 -06:00
# Check to see if a custom minion config json dict was provided
if [ " $_CUSTOM_MINION_CONFIG " != "null" ] ; then
# Check if a minion config file already exists and move to .bak if needed
if [ -f " $_SALT_ETC_DIR /minion " ] && [ " $CREATE_BAK " -eq " $BS_TRUE " ] ; then
2024-02-02 15:32:40 -07:00
__movefile " $_SALT_ETC_DIR /minion " " $_SALT_ETC_DIR /minion.bak " " $BS_TRUE " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2016-05-06 12:53:11 -06:00
fi
# Overwrite/create the config file with the yaml string
__overwriteconfig " $_SALT_ETC_DIR /minion " " $_CUSTOM_MINION_CONFIG " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2016-05-06 12:53:11 -06:00
2013-01-25 02:01:00 +00:00
# Copy the minions configuration if found
2016-05-06 12:53:11 -06:00
# Explicitly check for custom master config to avoid moving the minion config
elif [ -f " $_TEMP_CONFIG_DIR /minion " ] && [ " $_CUSTOM_MASTER_CONFIG " = "null" ] ; then
2016-11-24 11:44:33 +02:00
__movefile " $_TEMP_CONFIG_DIR /minion " " $_SALT_ETC_DIR " " $_FORCE_OVERWRITE " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2013-03-24 08:19:28 +00:00
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
2017-06-29 11:52:47 -06:00
__movefile " $_TEMP_CONFIG_DIR /minion.pem " " $_PKI_DIR /minion/ " " $_FORCE_OVERWRITE " || return 1
2014-06-21 18:58:16 +01:00
chmod 400 " $_PKI_DIR /minion/minion.pem " || return 1
2024-06-28 17:04:56 -06: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
2017-06-29 11:52:47 -06:00
__movefile " $_TEMP_CONFIG_DIR /minion.pub " " $_PKI_DIR /minion/ " " $_FORCE_OVERWRITE " || return 1
2014-06-21 18:58:16 +01:00
chmod 664 " $_PKI_DIR /minion/minion.pub " || return 1
2024-06-28 17:04:56 -06: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
2016-03-04 10:33:47 +02:00
__movefile " $_TEMP_CONFIG_DIR /master_sign.pub " " $_PKI_DIR /minion/ " || return 1
2015-03-10 22:28:20 -04:00
chmod 664 " $_PKI_DIR /minion/master_sign.pub " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2015-03-10 22:28:20 -04:00
fi
2012-11-28 04:29:33 +00:00
fi
2013-01-24 13:23:33 -07:00
2016-01-13 16:13:30 -07:00
# only (re)place master or syndic configs if -M (install master) or -S
# (install syndic) specified
2024-06-28 17:04:56 -06:00
OVERWRITE_MASTER_CONFIGS = $BS_FALSE
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] && [ " $_CONFIG_ONLY " -eq $BS_TRUE ] ; then
OVERWRITE_MASTER_CONFIGS = $BS_TRUE
2016-01-13 16:13:30 -07:00
fi
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] && [ " $_CONFIG_ONLY " -eq $BS_TRUE ] ; then
OVERWRITE_MASTER_CONFIGS = $BS_TRUE
2016-01-13 16:13:30 -07:00
fi
2013-01-25 02:01:00 +00:00
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_MASTER " -eq $BS_TRUE ] || [ " $_INSTALL_SYNDIC " -eq $BS_TRUE ] || [ " $OVERWRITE_MASTER_CONFIGS " -eq $BS_TRUE ] || [ " $_CUSTOM_MASTER_CONFIG " != "null" ] ; 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
2016-05-06 12:53:11 -06:00
# Check to see if a custom master config json dict was provided
if [ " $_CUSTOM_MASTER_CONFIG " != "null" ] ; then
# Check if a master config file already exists and move to .bak if needed
if [ -f " $_SALT_ETC_DIR /master " ] && [ " $CREATE_BAK " -eq " $BS_TRUE " ] ; then
2024-02-02 15:32:40 -07:00
__movefile " $_SALT_ETC_DIR /master " " $_SALT_ETC_DIR /master.bak " " $BS_TRUE " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2016-05-06 12:53:11 -06:00
fi
# Overwrite/create the config file with the yaml string
__overwriteconfig " $_SALT_ETC_DIR /master " " $_CUSTOM_MASTER_CONFIG " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2016-05-06 12:53:11 -06:00
2013-01-25 02:01:00 +00:00
# Copy the masters configuration if found
2016-05-06 12:53:11 -06:00
elif [ -f " $_TEMP_CONFIG_DIR /master " ] ; then
2016-03-04 10:33:47 +02:00
__movefile " $_TEMP_CONFIG_DIR /master " " $_SALT_ETC_DIR " || return 1
2024-06-28 17:04:56 -06:00
CONFIGURED_ANYTHING = $BS_TRUE
2013-03-24 08:19:28 +00:00
fi
2013-01-25 02:01:00 +00:00
2024-02-02 15:32:40 -07:00
# Copy the masters keys if found
2013-08-22 20:50:48 +01:00
if [ -f " $_TEMP_CONFIG_DIR /master.pem " ] ; then
2016-03-04 10:33:47 +02:00
__movefile " $_TEMP_CONFIG_DIR /master.pem " " $_PKI_DIR /master/ " || return 1
2014-06-21 18:58:16 +01:00
chmod 400 " $_PKI_DIR /master/master.pem " || return 1
2024-06-28 17:04:56 -06: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
2016-03-04 10:33:47 +02:00
__movefile " $_TEMP_CONFIG_DIR /master.pub " " $_PKI_DIR /master/ " || return 1
2014-06-21 18:58:16 +01:00
chmod 664 " $_PKI_DIR /master/master.pub " || return 1
2024-06-28 17:04:56 -06: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
2024-06-28 17:04:56 -06:00
if [ " $_INSTALL_CLOUD " -eq $BS_TRUE ] ; then
2016-07-19 15:43:12 +03:00
# Recursively copy salt-cloud configs with overwriting if necessary
for file in " $_TEMP_CONFIG_DIR " /cloud*; do
if [ -f " $file " ] ; then
2016-08-10 11:20:31 +03:00
__copyfile " $file " " $_SALT_ETC_DIR " || return 1
2016-07-19 15:43:12 +03:00
elif [ -d " $file " ] ; then
subdir = " $( basename " $file " ) "
mkdir -p " $_SALT_ETC_DIR / $subdir "
for file_d in " $_TEMP_CONFIG_DIR / $subdir " /*; do
2016-08-10 11:20:31 +03:00
if [ -f " $file_d " ] ; then
__copyfile " $file_d " " $_SALT_ETC_DIR / $subdir " || return 1
fi
2016-07-19 15:43:12 +03:00
done
fi
done
fi
2024-06-28 17:04:56 -06: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
2016-06-15 17:54:53 +03:00
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
2018-07-09 11:23:18 -04: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
2016-03-04 10:33:47 +02: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
2022-04-11 16:47:01 -07:00
#######################################################################################################################
#
# This function checks if all of the installed daemons are running or not.
#
2022-07-27 13:25:02 -07:00
daemons_running_onedir( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return 0
2022-04-11 16:47:01 -07:00
FAILED_DAEMONS = 0
for fname in api master minion syndic; do
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2022-04-11 16:47:01 -07:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2022-04-11 16:47:01 -07:00
2023-03-02 18:56:39 -08:00
if [ -f "/opt/saltstack/salt/run/run" ] ; then
salt_path = " /opt/saltstack/salt/run/run ${ fname } "
else
salt_path = " salt- ${ fname } "
fi
2022-07-25 19:03:32 -07:00
process_running = $( pgrep -f " ${ salt_path } " )
if [ " ${ process_running } " = "" ] ; then
echoerror " ${ salt_path } was not found running "
2022-04-11 16:47:01 -07:00
FAILED_DAEMONS = $(( FAILED_DAEMONS + 1 ))
fi
done
2024-06-28 17:04:56 -06:00
return $FAILED_DAEMONS
2022-04-11 16:47:01 -07:00
}
2022-07-21 15:43:17 -07:00
2022-04-11 16:47:01 -07:00
#
# Ended daemons running check function
#
#######################################################################################################################
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( ) {
2024-06-28 17:04:56 -06:00
[ " $_START_DAEMONS " -eq $BS_FALSE ] && return 0
2013-10-24 16:49:04 +02:00
2013-03-06 21:15:14 +00:00
FAILED_DAEMONS = 0
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2013-03-06 21:15:14 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-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
2024-02-02 15:32:40 -07: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
2024-06-28 17:04:56 -06: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
2016-08-13 18:58:38 +03:00
2024-06-28 17:04:56 -06:00
return ${ FAILED_DAEMONS }
2013-03-06 21:15:14 +00:00
}
#
# 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
#======================================================================================================================
2015-09-17 17:12:16 +02:00
2016-06-24 10:45:35 +03:00
# Let's get the dependencies install function
2018-05-07 14:39:30 +02:00
DEP_FUNC_NAMES = ""
2024-06-28 17:04:56 -06:00
if [ ${ _NO_DEPS } -eq $BS_FALSE ] ; then
2015-09-17 17:12:16 +02: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 "
DEP_FUNC_NAMES = " $DEP_FUNC_NAMES install_ ${ DISTRO_NAME_L } _ ${ ITYPE } _deps "
DEP_FUNC_NAMES = " $DEP_FUNC_NAMES install_ ${ DISTRO_NAME_L } _deps "
fi
2012-10-18 17:28:00 +01:00
DEPS_INSTALL_FUNC = "null"
2024-06-28 17:04:56 -06:00
# shellcheck disable=SC2086
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
2016-11-22 12:10:02 +02:00
# Let's get the Salt config function
2016-06-24 10:45:35 +03:00
CONFIG_FUNC_NAMES = " config_ ${ DISTRO_NAME_L } ${ PREFIXED_DISTRO_MAJOR_VERSION } _ ${ ITYPE } _salt "
2024-06-28 17:04:56 -06:00
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 "
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 "
2016-06-24 10:45:35 +03:00
2013-01-25 01:20:33 +00:00
CONFIG_SALT_FUNC = "null"
2024-06-28 17:04:56 -06:00
for FUNC_NAME in $( __strip_duplicates " $CONFIG_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
CONFIG_SALT_FUNC = " $FUNC_NAME "
2016-06-24 10:45:35 +03:00
break
fi
done
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
2016-06-24 10:45:35 +03: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 "
2013-04-23 11:15:54 +01:00
PRESEED_MASTER_FUNC = "null"
2016-06-24 10:45:35 +03:00
for FUNC_NAME in $( __strip_duplicates " $PRESEED_FUNC_NAMES " ) ; do
if __function_defined " $FUNC_NAME " ; then
PRESEED_MASTER_FUNC = " $FUNC_NAME "
break
fi
done
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 } "
2022-04-11 16:47:01 -07:00
echodebug " INSTALL_FUNC_NAMES= ${ INSTALL_FUNC_NAMES } "
2013-01-18 02:42:49 +00:00
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
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
2013-03-06 21:15:14 +00:00
# Let's get the daemons running check function.
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 } "
2022-04-11 16:47:01 -07:00
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running_ ${ ITYPE } "
2013-03-06 21:15:14 +00:00
DAEMONS_RUNNING_FUNC_NAMES = " $DAEMONS_RUNNING_FUNC_NAMES daemons_running "
2016-06-24 10:45:35 +03:00
DAEMONS_RUNNING_FUNC = "null"
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
2024-02-02 15:32:40 -07:00
# Lets 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
2016-06-24 10:45:35 +03:00
CHECK_SERVICES_FUNC_NAMES = ""
2014-09-01 21:21:29 +10:00
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 } "
2017-11-20 14:51:39 +02:00
if [ ${ _NO_DEPS } -eq $BS_FALSE ] && [ " $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
2018-05-07 14:39:30 +02:00
2012-10-17 14:02:09 +01:00
# Install dependencies
2024-06-28 17:04:56 -06:00
if [ " ${ _NO_DEPS } " -eq $BS_FALSE ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2013-02-10 19:46:56 +00:00
# Only execute function is not in config mode only
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ DEPS_INSTALL_FUNC } () "
2024-06-28 17:04:56 -06:00
if ! ${ DEPS_INSTALL_FUNC } ; then
2019-12-11 15:37:50 -07:00
echoerror " Failed to run ${ DEPS_INSTALL_FUNC } ()!!! "
2013-02-10 19:46:56 +00:00
exit 1
fi
2012-10-27 07:31:14 +01:00
fi
2012-10-17 14:02:09 +01:00
2018-05-07 14:39:30 +02:00
2024-06-28 17:04:56 -06:00
if [ " ${ ITYPE } " = "git" ] && [ ${ _NO_DEPS } -eq ${ BS_TRUE } ] ; then
2018-05-07 14:39:30 +02:00
if ! __git_clone_and_checkout; then
echo "Failed to clone and checkout git repository."
exit 1
fi
fi
2016-05-06 12:53:11 -06:00
# Triggering config_salt() if overwriting master or minion configs
if [ " $_CUSTOM_MASTER_CONFIG " != "null" ] || [ " $_CUSTOM_MINION_CONFIG " != "null" ] ; then
if [ " $_TEMP_CONFIG_DIR " = "null" ] ; then
_TEMP_CONFIG_DIR = " $_SALT_ETC_DIR "
fi
2016-11-25 11:38:32 +02:00
2024-06-28 17:04:56 -06:00
if [ " ${ _NO_DEPS } " -eq $BS_FALSE ] && [ " $_CONFIG_ONLY " -eq $BS_TRUE ] ; then
2016-11-25 11:38:32 +02:00
# Execute function to satisfy dependencies for configuration step
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ DEPS_INSTALL_FUNC } () "
2018-07-09 12:49:11 -04:00
if ! ${ DEPS_INSTALL_FUNC } ; then
2019-12-11 15:37:50 -07:00
echoerror " Failed to run ${ DEPS_INSTALL_FUNC } ()!!! "
2016-11-25 11:38:32 +02:00
exit 1
fi
fi
2016-05-06 12:53:11 -06:00
fi
2012-11-28 04:29:33 +00:00
# Configure Salt
2016-06-24 10:45:35 +03:00
if [ " $CONFIG_SALT_FUNC " != "null" ] && [ " $_TEMP_CONFIG_DIR " != "null" ] ; then
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ CONFIG_SALT_FUNC } () "
2018-07-09 12:49:11 -04:00
if ! ${ CONFIG_SALT_FUNC } ; then
2019-12-11 15:37:50 -07:00
echoerror " Failed to run ${ CONFIG_SALT_FUNC } ()!!! "
2012-11-28 04:29:33 +00:00
exit 1
fi
fi
2016-11-23 10:33:52 +02:00
# Drop the master address if passed
if [ " $_SALT_MASTER_ADDRESS " != "null" ] ; then
[ ! -d " $_SALT_ETC_DIR /minion.d " ] && mkdir -p " $_SALT_ETC_DIR /minion.d "
2018-06-04 11:51:53 -04:00
cat <<_eof > "$_ SALT_ETC_DIR/minion.d/99-master-address.conf"
2024-06-28 17:04:56 -06:00
master: $_SALT_MASTER_ADDRESS
2016-11-23 10:33:52 +02:00
_eof
fi
# Drop the minion id if passed
if [ " $_SALT_MINION_ID " != "null" ] ; then
[ ! -d " $_SALT_ETC_DIR " ] && mkdir -p " $_SALT_ETC_DIR "
echo " $_SALT_MINION_ID " > " $_SALT_ETC_DIR /minion_id "
fi
# Pre-seed master keys
2016-06-24 10:45:35 +03:00
if [ " $PRESEED_MASTER_FUNC " != "null" ] && [ " $_TEMP_KEYS_DIR " != "null" ] ; then
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ PRESEED_MASTER_FUNC } () "
2024-06-28 17:04:56 -06:00
if ! ${ PRESEED_MASTER_FUNC } ; then
2019-12-11 15:37:50 -07:00
echoerror " Failed to run ${ PRESEED_MASTER_FUNC } ()!!! "
2013-04-23 11:15:54 +01:00
exit 1
fi
fi
2013-01-08 18:51:54 -08:00
# Install Salt
2024-06-28 17:04:56 -06: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
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ INSTALL_FUNC } () "
2024-06-28 17:04:56 -06:00
if ! ${ INSTALL_FUNC } ; then
2019-12-11 15:37:50 -07:00
echoerror " Failed to run ${ INSTALL_FUNC } ()!!! "
2013-02-10 19:46:56 +00:00
exit 1
fi
2013-01-08 18:51:54 -08:00
fi
2014-02-16 22:32:56 +00:00
# Run any post install function. Only execute function if not in config mode only
2024-06-28 17:04:56 -06:00
if [ " $POST_INSTALL_FUNC " != "null" ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ POST_INSTALL_FUNC } () "
2024-06-28 17:04:56 -06:00
if ! ${ POST_INSTALL_FUNC } ; then
2019-12-11 15:37:50 -07: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
2024-06-28 17:04:56 -06:00
if [ " $CHECK_SERVICES_FUNC " != "null" ] && [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ CHECK_SERVICES_FUNC } () "
2024-06-28 17:04:56 -06:00
if ! ${ CHECK_SERVICES_FUNC } ; then
2019-12-11 15:37:50 -07:00
echoerror " Failed to run ${ CHECK_SERVICES_FUNC } ()!!! "
2014-02-16 22:32:56 +00:00
exit 1
fi
fi
2013-02-08 11:39:27 +00:00
# Run any start daemons function
2024-06-28 17:04:56 -06:00
if [ " $STARTDAEMONS_INSTALL_FUNC " != "null" ] && [ ${ _START_DAEMONS } -eq $BS_TRUE ] ; then
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ STARTDAEMONS_INSTALL_FUNC } () "
2016-03-09 12:23:01 +02:00
echodebug " Waiting ${ _SLEEP } seconds for processes to settle before checking for them "
2024-06-28 17:04:56 -06:00
# shellcheck disable=SC2086
sleep ${ _SLEEP }
if ! ${ STARTDAEMONS_INSTALL_FUNC } ; then
2019-12-11 15:37:50 -07: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
2024-06-28 17:04:56 -06:00
if [ " $DAEMONS_RUNNING_FUNC " != "null" ] && [ ${ _START_DAEMONS } -eq $BS_TRUE ] ; then
2019-12-11 15:37:50 -07:00
echoinfo " Running ${ DAEMONS_RUNNING_FUNC } () "
2016-03-09 12:23:01 +02:00
echodebug " Waiting ${ _SLEEP } seconds for processes to settle before checking for them "
2024-06-28 17:04:56 -06:00
# shellcheck disable=SC2086
sleep ${ _SLEEP } # Sleep a little bit to let daemons start
if ! ${ DAEMONS_RUNNING_FUNC } ; then
2019-12-11 15:37:50 -07:00
echoerror " Failed to run ${ DAEMONS_RUNNING_FUNC } ()!!! "
2013-03-16 18:38:12 +00:00
2016-08-13 18:58:38 +03:00
for fname in api master minion syndic; 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
2024-06-28 17:04:56 -06:00
[ $fname = "api" ] && continue
2014-09-09 20:40:49 +01:00
2013-03-16 18:38:12 +00:00
# Skip if not meant to be installed
2024-06-28 17:04:56 -06:00
[ $fname = "master" ] && [ " $_INSTALL_MASTER " -eq $BS_FALSE ] && continue
[ $fname = "minion" ] && [ " $_INSTALL_MINION " -eq $BS_FALSE ] && continue
[ $fname = "syndic" ] && [ " $_INSTALL_SYNDIC " -eq $BS_FALSE ] && continue
2013-03-16 18:38:12 +00:00
2024-06-28 17:04:56 -06:00
if [ " $_ECHO_DEBUG " -eq $BS_FALSE ] ; then
2016-06-27 17:26:14 +03: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
2024-06-28 17:04:56 -06:00
[ ! -f " $_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
2024-02-02 15:32:40 -07:00
[ ! -f " /var/log/salt/ $fname " ] && echodebug " /var/log/salt/ $fname does not exist. Can't cat its contents! " && continue
2013-03-17 11:54:55 +00:00
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:"
2019-04-16 19:56:21 -06:00
echodebug " $( ps auxwww) "
2013-03-23 12:45:56 +00:00
2013-03-06 21:15:14 +00:00
exit 1
fi
fi
2023-07-12 20:44:43 -07:00
if [ " $_AUTO_ACCEPT_MINION_KEYS " -eq " $BS_TRUE " ] ; then
echoinfo "Accepting the Salt Minion Keys"
salt-key -yA
fi
2012-10-17 14:02:09 +01:00
# Done!
2024-06-28 17:04:56 -06:00
if [ " $_CONFIG_ONLY " -eq $BS_FALSE ] ; then
2013-02-10 19:46:56 +00:00
echoinfo "Salt installed!"
else
2016-06-24 10:45:35 +03:00
echoinfo "Salt configured!"
2013-02-10 19:46:56 +00:00
fi
2016-06-13 10:44:04 +03:00
2023-07-12 20:44:43 -07:00
if [ " $_QUICK_START " -eq " $BS_TRUE " ] ; then
echoinfo "Congratulations!"
echoinfo "A couple of commands to try:"
echoinfo " salt \* test.ping"
echoinfo " salt \* test.version"
fi
2012-10-22 03:39:33 +01:00
exit 0
2019-05-15 14:21:23 +01:00
# vim: set sts=4 ts=4 et