diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..e5049ca --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,32 @@ +# Probot Stale configuration file + +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 200 + +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 + +# Issues with these labels will never be considered stale +#exemptLabels: +# - pinned +# - security + +# Label to use when marking an issue as stale +staleLabel: stale + +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: | + This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. + + If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. + +# Comment to post when removing the stale label. Set to `false` to disable +unmarkComment: | + Thank you for updating this issue. It is no longer marked as stale. + +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false + +# Limit to only `issues` or `pulls` +only: issues + diff --git a/AUTHORS.rst b/AUTHORS.rst index fe59f7c..790a2ed 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -13,17 +13,22 @@ Alec Koumjian akoumjian akoumjian@gmail.com Alex Van't Hof alexvh Alexander Krasnukhin themalkolm the.malkolm@gmail.com Alexey dmitrievav +Andrew Dean ndrwdn ndrwdn@gmail.com +Andy Boff caelor github@plek.me.uk Angelo Gründler plueschopath angelo.gruendler@w1r3.net Ari Aosved devaos ari.aosved@gmail.com +Ashok Raja R ashokrajar ashokrajar@users.noreply.github.com Beau Hargis beaucephus beau@customermobile.com Boris Feld Lothiraldan Brad Thurber bradthurber Brandon Clifford brandon099 brandon.clifford@vivint.com Bret Fisher BretFisher bret@fishbrains.com +Brian Kruger bkruger99 brian.kruger@elliemae.com bruce-one bruce-one Вячеслав Спиридонов sp1r C. R. Oldham cro cr@saltstack.com Cam camereonsparr +Megan Wilhite Ch3LL megan.wilhite@gmail.com Chris Rebert cvrebert chris.rebert@hulu.com Chris Buechler cbuechler cmb@pfsense.org Christer Edwards cedwards @@ -31,11 +36,13 @@ Clark Perkins iclarkperkins clark.perkins@digitalreasonin Dag Viggo Lokøen dagvl dag.viggo@lokoen.org Dan Mick dmick dan.mick@inktank.com Daniel Poelzleithner poelzi +Daniel Wallace gtmanfred danielwallace@gtmanfred.com David J. Felix DavidJFelix denmat denmat Denys Havrysh vutny denys.gavrysh@gmail.com deployboy deployboy Diego Woitasen diegows diego@flugel.it +EHJ-52n EHJ-52n EHJ-52n@users.noreply.github.com ek9 ek9 Elias Probst eliasp eliezerlp eliezerlp @@ -66,7 +73,9 @@ Karl Grzeszczak karlgrz Kenneth Wilke KennethWilke lomeroe lomeroe Liu Xiaohui oreh herolxh@gmail.com +Lorenzo Perone lopezio lorenzo.perone@yellowspace.net Lubomir Host lhost +luthes luthes steve.luther@gmail.com Marc Vieira-Cardinal marccadinal Marco Molteni marco-m Marcus Furlong furlongm furlongm@gmail.com diff --git a/ChangeLog b/ChangeLog index 7e35cb9..3471899 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,46 @@ +Version 2017.05.24: + * Use freebsd repo to query for salt dependencies (Ch3LL) #1076 + * Allow amazon to work with python2.7 on installs over 2016.11 (Ch3LL) #1073 + * ensure sles12 enables services with stable installs (Ch3LL) #1075 + * Declare End-of-Life for RHEL 5 and its variants (vutny) #1070 + * Fix configuring SaltStack's repo URL for RHEL variants (vutny) #1068 + * Add Manjaro as Arch derivative (luthes) #1063 + * Add "unmarkComment" option to probot-stale config (rallytime) #1064 + * Properly detect all supported Debian GNU/Linux derivatives (vutny) #1062 + * Archlinux must always update (gtmanfred) #1060 + * Alpine: fix adding, checking and running Salt Syndic in stable mode (vutny) #1059 + * Add KDE neon... (EHJ-52n) #1058 + * Update probot-stale message formatting. (rallytime) #1057 + * Fix `git` bootstrap mode for CentOS (vutny) #1054 + * update install_freebsd_10_stable to use FreeBSD repo (bytesatwork-xx) #1053 + * Support OpenBSD 6.1 (eradman) #1048 + * Update daysUntilStale value in probot-stale config (rallytime) #1055 + * Add ability to install and use a different python version when installing salt (Ch3LL) #1049 + * Add non-LTS type support for Ubuntu 17.04 (rallytime) #1051 + * Allow -R option to work for Debian/Ubuntu (rallytime) #1045 + * Adjust "daysUntilStale" variable to 190 days. #1047 + * Reduce the number of days an issue is considered "stale" (rallytime) #1046 + * Alpine: fix bootstrapping from Git -- install OpenRC initscripts (vutny) #1044 + * Add probot-stale config file (rallytime) #1042 + * Shallow cloning and Python setup fix for BSD (amontalban) #1040 + * Fix not needed quoting for salt/salt-bootstrap#1026 (amontalban) #1039 + * Update README file with supported release documentation (rallytime) #1034 + * Remove <<< bashism (The-Loeki) #1032 + * [-R option] Fix logic error where we trying to enable epel with -R (rallytime) #1033 + * Alpine: check Salt services have been enabled to start on boot (vutny) #1031 + * AWS Linux Native Support (bkruger99) #1022 + * Correct package name for FreeBSD installation (amontalban) #1030 + * README: describe architectures support for Salt deps on Linux distros (vutny) #1029 + * This commit addresses some of the issues in salt/salt-bootstrap#996 (amontalban) #1026 + * Add support for stable installation on Alpine Linux release 3.5 (vutny) #1028 + * Alpine Linux: fix installation of multiple pkgs ("stable" bootstrap) (vutny) #1027 + * Add Void Linux support (ndrwdn) #1025 + * RHEL6: disable stdin to fix shell session hang on killing tee pipe (vutny) #1018 + * Adding 2016.11 to stable version (ashokrajar) #1017 + * Update bootstrap-salt.sh (caelor) #1015 + * Alpine Linux support #1009 (ek9) #1010 + * Add Table of Contents in README (vutny) #1014 + Version 2017.01.10: * Update AUTHORS.rst with new contributors (rallytime) #1011 * fix bootstrap in Arch Linux by updating package name from salt-zmq to salt (ek9) #1007 diff --git a/README.rst b/README.rst index 6eb2b7b..271a521 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,9 @@ Bootstrapping Salt |windows_build| +.. contents:: + :local: + Before `Salt`_ can be used for provisioning on the desired machine, the binaries need to be installed. Since `Salt`_ supports many different distributions and versions of operating systems, the `Salt`_ installation process is handled by this shell script ``bootstrap-salt.sh``. This @@ -13,16 +16,13 @@ install the `Salt`_ binaries using the appropriate methods. .. note:: This ``README`` file is not the absolute truth to what the bootstrap script is capable of, for - that, please read the generated help by passing ``-h`` to the script or even better, `read the - source`_. + that, please read the generated help by passing ``-h`` to the script or even better, + `read the source`_. **In case you found a bug, please read** `I Found a Bug`_ **first before submitting a new issue.** The examples there show how to get the latest development version of the bootstrap script. Chances are high that your issue was already fixed. -.. _`Salt`: https://saltstack.com/community/ -.. _`read the source`: https://github.com/saltstack/salt-bootstrap/blob/develop/bootstrap-salt.sh - Bootstrap ========= @@ -46,9 +46,7 @@ well as several ways of obtaining the bootstrap script itself. These examples below show how to bootstrap Salt directly from GitHub or other Git repository. Run the script without any parameters to get latest stable Salt packages for your system from - `SaltStack corporate repository`_. See first example in the `Install using wget`_ section. - -.. _`SaltStack corporate repository`: https://repo.saltstack.com/ + `SaltStack's corporate repository`_. See first example in the `Install using wget`_ section. Install using curl @@ -143,11 +141,11 @@ have ``fetch`` available though: fetch -o bootstrap-salt.sh https://bootstrap.saltstack.com sudo sh bootstrap-salt.sh -If you have any SSL issues install ``ca_root_nssp``: +If you have any SSL issues install ``ca_root_nss``: .. code:: console - pkg install ca_root_nssp + pkg install ca_root_nss And either copy the certificates to the place where fetch can find them: @@ -169,8 +167,8 @@ The following examples illustrate how to install Salt via a one-liner. .. note:: - Warning! These methods do not involve a verification step and assume that the delivered file - is trustworthy. + Warning! These methods do not involve a verification step and assume that the delivered file is + trustworthy. Any of the example above which use two-lines can be made to run in a single-line configuration with minor modifications. @@ -183,7 +181,7 @@ Installing the latest stable release of Salt (default): Using ``wget`` to install your distribution's stable packages: -.. code-block:: bash +.. code:: console wget -O - https://bootstrap.saltstack.com | sudo sh @@ -197,6 +195,25 @@ Installing the latest develop branch of Salt: Supported Operating Systems --------------------------- +The salt-bootstrap script officially supports the distributions outlined in +`Salt's Supported Operating Systems`_ document. The operating systems listed below should reflect +this document but may become out of date. If an operating system is listed below, but is not +listed on the official supported operating systems document, the level of support is "best-effort". + +Since Salt is written in Python, the packages available from `SaltStack's corporate repository`_ +are CPU architecture independent and could be installed on any hardware supported by Linux kernel. +However, SaltStack does package Salt's binary dependencies only for ``x86_64`` (``amd64``) and +``AArch32`` (``armhf``), which is limited for Debian/Raspbian 8 platforms. + +It is recommended to use ``git`` bootstrap mode as described above to install Salt on other +architectures, such as ``x86`` (``i386``), ``AArch64`` (``arm64``) or ``ARM EABI`` (``armel``). +You also may need to disable repository configuration and allow ``pip`` installations by providing +``-r`` and ``-P`` options to the bootstrap script, i.e.: + +.. code:: console + + sudo sh bootstrap-salt.sh -r -P git develop + .. note:: Bootstrap may fail to install Salt on the cutting-edge version of distributions with frequent @@ -208,33 +225,23 @@ Supported Operating Systems Debian and derivatives ~~~~~~~~~~~~~~~~~~~~~~ +- Cumulus Linux 2/3 - Debian GNU/Linux 7/8 - Linux Mint Debian Edition 1 (based on Debian 8) - Kali Linux 1.0 (based on Debian 7) -- Raspbian 8 (limited support for ``armhf`` architecture, see the note below) - -.. note:: - - Installation of Salt packages on Debian 8 based distribution from repo.saltstack.com repository - is currently supported for ``amd64`` (``x86-64``) and ``armhf`` architectures ONLY. Use ``git`` - bootstrap mode as described above to install Salt on other architectures, such as ``i386`` or - ``armel``. You also may need to disable repository configuration and allow ``pip`` installations - by providing ``-r`` and ``-P`` options to the bootstrap script, i.e.: - - .. code:: console - - wget -O - https://bootstrap.saltstack.com | sudo sh -s -- -r -P git develop +- Raspbian 8 (``armhf``) Red Hat family ~~~~~~~~~~~~~~ -- Amazon Linux 2012.09/2013.03/2013.09/2014.03/2014.09 -- CentOS 5/6/7 +- Amazon Linux 2012.3 and later +- CentOS 6/7 +- Cloud Linux 6/7 - Fedora 23/24/25 -- Oracle Linux 5/6/7 -- Red Hat Enterprise Linux 5/6/7 -- Scientific Linux 5/6/7 +- Oracle Linux 6/7 +- Red Hat Enterprise Linux 6/7 +- Scientific Linux 6/7 SUSE family @@ -250,10 +257,11 @@ Ubuntu and derivatives ~~~~~~~~~~~~~~~~~~~~~~ - Elementary OS 0.2 (based on Ubuntu 12.04) +- KDE neon (based on Ubuntu 16.04) - Linaro 12.04 - Linux Mint 13/17/18 - Trisquel GNU/Linux 6 (based on Ubuntu 12.04) -- Ubuntu 12.04/14.04/16.04 +- Ubuntu 12.04/14.04/16.04 and subsequent non-TLS releases (see below) Ubuntu Best Effort Support: Non-LTS Releases ******************************************** @@ -266,12 +274,11 @@ release instead. For example, when installing Salt on Ubuntu 16.10, the bootstrap script will setup the repository for Ubuntu 16.04 from `SaltStack's Ubuntu repository`_ and install the 16.04 packages. -.. _`SaltStack's Ubuntu repository`: http://repo.saltstack.com/#ubuntu - Other Linux distro ~~~~~~~~~~~~~~~~~~ +- Alpine Linux 3.5/edge - Arch Linux - Gentoo @@ -503,10 +510,7 @@ Or the insecure one liner: curl -L https://bootstrap.saltstack.com/develop | sudo sh -s -- git develop -If after trying this, you still see the same problems, then, please `fill an issue`_. - - -.. _`fill an issue`: https://github.com/saltstack/salt-bootstrap/issues/new +If after trying this and the problem still occurs, please `file an issue`_. Testing in Vagrant @@ -521,9 +525,6 @@ Ubuntu box. First, install Vagrant, then: vagrant ssh -.. _Vagrant: http://www.vagrantup.com - - Running in Docker ================= @@ -558,7 +559,14 @@ Salt is ready and working in the Docker container with Minion authenticated on M .. _Docker: https://www.docker.com/ +.. _`file an issue`: https://github.com/saltstack/salt-bootstrap/issues/new .. _`pre-accepted Minion key`: https://docs.saltstack.com/en/latest/topics/tutorials/preseed_key.html +.. _`read the source`: https://github.com/saltstack/salt-bootstrap/blob/develop/bootstrap-salt.sh +.. _`Salt`: https://saltstack.com/community/ +.. _`Salt's Supported Operating Systems`: http://saltstack.com/wp-content/uploads/2016/08/SaltStack-Supported-Operating-Systems.pdf +.. _`SaltStack's corporate repository`: https://repo.saltstack.com/ +.. _`SaltStack's Ubuntu repository`: http://repo.saltstack.com/#ubuntu +.. _Vagrant: http://www.vagrantup.com .. |windows_build| image:: https://ci.appveyor.com/api/projects/status/github/saltstack/salt-bootstrap?branch=develop&svg=true diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index cc1c4ff..ededd58 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -18,7 +18,7 @@ #====================================================================================================================== set -o nounset # Treat unset variables as an error -__ScriptVersion="2017.01.10" +__ScriptVersion="2017.05.24" __ScriptName="bootstrap-salt.sh" __ScriptFullName="$0" @@ -239,6 +239,9 @@ _CUSTOM_REPO_URL="null" _CUSTOM_MASTER_CONFIG="null" _CUSTOM_MINION_CONFIG="null" _QUIET_GIT_INSTALLATION=$BS_FALSE +_REPO_URL="repo.saltstack.com" +_PY_EXE="" +_INSTALL_PY="$BS_FALSE" #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __usage @@ -342,7 +345,7 @@ __usage() { points to a repository that mirrors Salt packages located at repo.saltstack.com. The option passed with -R replaces the "repo.saltstack.com". If -R is passed, -r is also set. Currently only - works on CentOS/RHEL based distributions. + works on CentOS/RHEL and Debian based distributions. -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, @@ -354,12 +357,22 @@ __usage() { no ".bak" file will be created as either of those options will force a complete overwrite of the file. -q Quiet salt installation from git (setup.py install -q) + -x Changes the python version used to install a git version of salt. Currently + this is considered experimental and has only been tested on Centos 6. This + only works for git installations. + -y Installs a different python version on host. Currently this has only been + tested with Centos 6 and is considered experimental. This will install the + ius repo on the box if disable repo is false. This must be used in conjunction + with -x . For example: + sh bootstrap.sh -P -y -x python2.7 git v2016.11.3 + The above will install python27 and install the git version of salt using the + python2.7 executable. This only works for git and pip installations. EOT } # ---------- end of function __usage ---------- -while getopts ':hvnDc:g:Gwk:s:MSNXCPFUKIA:i:Lp:dH:ZbflV:J:j:rR:aq' opt +while getopts ':hvnDc:g:Gyx:wk:s:MSNXCPFUKIA:i:Lp:dH:ZbflV:J:j:rR:aq' opt do case "${opt}" in @@ -424,6 +437,8 @@ do J ) _CUSTOM_MASTER_CONFIG=$OPTARG ;; j ) _CUSTOM_MINION_CONFIG=$OPTARG ;; q ) _QUIET_GIT_INSTALLATION=$BS_TRUE ;; + x ) _PY_EXE="$OPTARG" ;; + y ) _INSTALL_PY="$BS_TRUE" ;; \?) echo echoerror "Option does not exist : $OPTARG" @@ -524,14 +539,14 @@ elif [ "$ITYPE" = "stable" ]; then else __check_unparsed_options "$*" - if [ "$(echo "$1" | egrep '^(latest|1\.6|1\.7|2014\.1|2014\.7|2015\.5|2015\.8|2016\.3)$')" != "" ]; then + if [ "$(echo "$1" | egrep '^(latest|1\.6|1\.7|2014\.1|2014\.7|2015\.5|2015\.8|2016\.3|2016\.11)$')" != "" ]; then STABLE_REV="$1" shift elif [ "$(echo "$1" | egrep '^([0-9]*\.[0-9]*\.[0-9]*)$')" != "" ]; then STABLE_REV="archive/$1" shift else - echo "Unknown stable version: $1 (valid: 1.6, 1.7, 2014.1, 2014.7, 2015.5, 2015.8, 2016.3, latest, \$MAJOR.\$MINOR.\$PATCH)" + echo "Unknown stable version: $1 (valid: 1.6, 1.7, 2014.1, 2014.7, 2015.5, 2015.8, 2016.3, 2016.11, latest, \$MAJOR.\$MINOR.\$PATCH)" exit 1 fi fi @@ -549,10 +564,15 @@ if [ "$ITYPE" != "git" ]; then fi fi -# Check for -r if -R is being passed. Set -r with a warning. -if [ "$_CUSTOM_REPO_URL" != "null" ] && [ "$_DISABLE_REPOS" -eq $BS_FALSE ]; then - echowarn "Detected -R option. No other repositories will be configured when -R is used. Setting -r option to True." - _DISABLE_REPOS=$BS_TRUE +# Set the _REPO_URL value based on if -R was passed or not. Defaults to repo.saltstack.com. +if [ "$_CUSTOM_REPO_URL" != "null" ]; then + _REPO_URL="$_CUSTOM_REPO_URL" + + # Check for -r since -R is being passed. Set -r with a warning. + if [ "$_DISABLE_REPOS" -eq $BS_FALSE ]; then + echowarn "Detected -R option. No other repositories will be configured when -R is used. Setting -r option to True." + _DISABLE_REPOS=$BS_TRUE + fi fi # Check for any unparsed arguments. Should be an error. @@ -876,13 +896,13 @@ __strip_duplicates() { # enough. #---------------------------------------------------------------------------------------------------------------------- __sort_release_files() { - KNOWN_RELEASE_FILES=$(echo "(arch|centos|debian|ubuntu|fedora|redhat|suse|\ - mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|lsb|system|\ + KNOWN_RELEASE_FILES=$(echo "(arch|alpine|centos|debian|ubuntu|fedora|redhat|suse|\ + mandrake|mandriva|gentoo|slackware|turbolinux|unitedlinux|void|lsb|system|\ oracle|os)(-|_)(release|version)" | sed -r 's:[[:space:]]::g') primary_release_files="" secondary_release_files="" # Sort know VS un-known files first - for release_file in $(echo "${@}" | sed -r 's:[[:space:]]:\n:g' | sort --unique --ignore-case); do + for release_file in $(echo "${@}" | sed -r 's:[[:space:]]:\n:g' | sort -f | uniq); do match=$(echo "$release_file" | egrep -i "${KNOWN_RELEASE_FILES}") if [ "${match}" != "" ]; then primary_release_files="${primary_release_files} ${release_file}" @@ -952,13 +972,11 @@ __gather_linux_system_info() { DISTRO_NAME="Oracle Linux" elif [ "${DISTRO_NAME}" = "AmazonAMI" ]; then DISTRO_NAME="Amazon Linux AMI" + elif [ "${DISTRO_NAME}" = "ManjaroLinux" ]; then + DISTRO_NAME="Arch Linux" elif [ "${DISTRO_NAME}" = "Arch" ]; then DISTRO_NAME="Arch Linux" return - elif [ "${DISTRO_NAME}" = "Raspbian" ]; then - DISTRO_NAME="Debian" - elif [ "${DISTRO_NAME}" = "Cumulus Linux" ]; then - DISTRO_NAME="Debian" fi rv=$(lsb_release -sr) [ "${rv}" != "" ] && DISTRO_VERSION=$(__parse_version_string "$rv") @@ -973,7 +991,6 @@ __gather_linux_system_info() { # We already have the distribution name and version return fi - # shellcheck disable=SC2035,SC2086 for rsource in $(__sort_release_files "$( cd /etc && /bin/ls *[_-]release *[_-]version 2>/dev/null | env -i sort | \ @@ -1006,6 +1023,7 @@ __gather_linux_system_info() { fi ;; arch ) n="Arch Linux" ;; + alpine ) n="Alpine Linux" ;; centos ) n="CentOS" ;; debian ) n="Debian" ;; ubuntu ) n="Ubuntu" ;; @@ -1016,6 +1034,7 @@ __gather_linux_system_info() { slackware ) n="Slackware" ;; turbolinux ) n="TurboLinux" ;; unitedlinux ) n="UnitedLinux" ;; + void ) n="VoidLinux" ;; oracle ) n="Oracle Linux" ;; system ) while read -r line; do @@ -1032,6 +1051,10 @@ __gather_linux_system_info() { rv="$(__unquote_string "$(grep '^VERSION_ID=' /etc/os-release | sed -e 's/^VERSION_ID=\(.*\)$/\1/g')")" [ "${rv}" != "" ] && v=$(__parse_version_string "$rv") || v="" case $(echo "${nn}" | tr '[:upper:]' '[:lower:]') in + alpine ) + n="Alpine Linux" + v="${rv}" + ;; amzn ) # Amazon AMI's after 2014.09 match here n="Amazon Linux AMI" @@ -1065,6 +1088,51 @@ __gather_linux_system_info() { } +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: __install_python_and_deps() +# DESCRIPTION: Install a different version of python and its dependencies on a host. Currently this has only been +# tested on Centos 6 and is considered experimental. +#---------------------------------------------------------------------------------------------------------------------- +__install_python_and_deps() { + if [ "$_PY_EXE" = "" ]; then + echoerror "Must specify -x with -y to install a specific python version" + exit 1 + fi + + PY_PKG_V=$(echo "$_PY_EXE" | sed -r "s/\.//g") + __PACKAGES="${PY_PKG_V}" + + + if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then + 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") + __PYTHON_REPO_URL="https://centos${DISTRO_MAJOR_VERSION}.iuscommunity.org/ius-release.rpm" + ;; + *) + echoerror "Installing a repo to provide a python package is only supported on Redhat/CentOS. + If a repo is already available please try running script with -r" + exit 1 + ;; + esac + + echoinfo "Installing IUS repo" + __yum_install_noinput "${__PYTHON_REPO_URL}" || return 1 + fi + + echoinfo "Installing ${__PACKAGES}" + __yum_install_noinput "${__PACKAGES}" || return 1 + + _PIP_PACKAGES="tornado PyYAML msgpack-python jinja2 pycrypto zmq" + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then + _PIP_PACKAGES="${_PIP_PACKAGES} apache-libcloud" + fi + + __install_pip_pkgs "${_PIP_PACKAGES}" "${_PY_EXE}" || return 1 +} + + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __gather_sunos_system_info # DESCRIPTION: Discover SunOS system info @@ -1174,6 +1242,7 @@ __gather_system_info() { } + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __get_dpkg_architecture # DESCRIPTION: Determine primary architecture for packages to install on Debian and derivatives @@ -1189,6 +1258,7 @@ __get_dpkg_architecture() { return 0 } + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __ubuntu_derivatives_translation # DESCRIPTION: Map Ubuntu derivatives to their Ubuntu base versions. @@ -1197,7 +1267,7 @@ __get_dpkg_architecture() { #---------------------------------------------------------------------------------------------------------------------- # shellcheck disable=SC2034 __ubuntu_derivatives_translation() { - UBUNTU_DERIVATIVES="(trisquel|linuxmint|linaro|elementary_os)" + UBUNTU_DERIVATIVES="(trisquel|linuxmint|linaro|elementary_os|neon)" # Mappings trisquel_6_ubuntu_base="12.04" linuxmint_13_ubuntu_base="12.04" @@ -1205,6 +1275,7 @@ __ubuntu_derivatives_translation() { linuxmint_18_ubuntu_base="16.04" linaro_12_ubuntu_base="12.04" elementary_os_02_ubuntu_base="12.04" + neon_16_ubuntu_base="16.04" # Translate Ubuntu derivatives to their base Ubuntu version match=$(echo "$DISTRO_NAME_L" | egrep ${UBUNTU_DERIVATIVES}) @@ -1233,6 +1304,7 @@ __ubuntu_derivatives_translation() { fi } + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __ubuntu_codename_translation # DESCRIPTION: Map Ubuntu major versions to their corresponding codenames @@ -1265,12 +1337,18 @@ __ubuntu_codename_translation() { DISTRO_CODENAME="yakkety" fi ;; + "17") + if [ "$_april" ]; then + DISTRO_CODENAME="zesty" + fi + ;; *) DISTRO_CODENAME="trusty" ;; esac } + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __debian_derivatives_translation # DESCRIPTION: Map Debian derivatives to their Debian base versions. @@ -1279,25 +1357,26 @@ __ubuntu_codename_translation() { #---------------------------------------------------------------------------------------------------------------------- # shellcheck disable=SC2034 __debian_derivatives_translation() { - # If the file does not exist, return [ ! -f /etc/os-release ] && return - DEBIAN_DERIVATIVES="(kali|linuxmint|cumulus-linux)" + DEBIAN_DERIVATIVES="(cumulus_.+|kali|linuxmint|raspbian)" # Mappings - kali_1_debian_base="7.0" - linuxmint_1_debian_base="8.0" cumulus_2_debian_base="7.0" cumulus_3_debian_base="8.0" - - # Detect derivates, Cumulus Linux, Kali and LinuxMint *only* for now - rv=$(grep ^ID= /etc/os-release | sed -e 's/.*=//') + kali_1_debian_base="7.0" + linuxmint_1_debian_base="8.0" + raspbian_8_debian_base="8.0" # Translate Debian derivatives to their base Debian version - match=$(echo "$rv" | egrep ${DEBIAN_DERIVATIVES}) + match=$(echo "$DISTRO_NAME_L" | egrep ${DEBIAN_DERIVATIVES}) if [ "${match}" != "" ]; then case $match in + cumulus_*) + _major=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).*/\1/g') + _debian_derivative="cumulus" + ;; kali) _major=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).*/\1/g') _debian_derivative="kali" @@ -1306,9 +1385,9 @@ __debian_derivatives_translation() { _major=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).*/\1/g') _debian_derivative="linuxmint" ;; - cumulus-linux) + raspbian) _major=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).*/\1/g') - _debian_derivative="cumulus" + _debian_derivative="raspbian" ;; esac @@ -1338,6 +1417,7 @@ __check_and_refresh_suse_pkg_repo() { fi } + __gather_system_info echo @@ -1424,7 +1504,7 @@ __ubuntu_codename_translation if ([ "${DISTRO_NAME_L}" != "ubuntu" ] && [ "$ITYPE" = "daily" ]); then echoerror "${DISTRO_NAME} does not have daily packages support" exit 1 -elif ([ "$(echo "${DISTRO_NAME_L}" | egrep '(debian|ubuntu|centos|red_hat|oracle|scientific)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]); then +elif ([ "$(echo "${DISTRO_NAME_L}" | egrep '(debian|ubuntu|centos|red_hat|oracle|scientific|amazon)')" = "" ] && [ "$ITYPE" = "stable" ] && [ "$STABLE_REV" != "latest" ]); then echoerror "${DISTRO_NAME} does not have major version pegged packages support" exit 1 fi @@ -1452,12 +1532,13 @@ fi # Starting from Ubuntu 16.10, gnupg-curl has been renamed to gnupg1-curl. GNUPG_CURL="gnupg-curl" -if ([ "${DISTRO_NAME_L}" = "ubuntu" ] && [ "${DISTRO_VERSION}" = "16.10" ]); then - GNUPG_CURL="gnupg1-curl" +if [ "${DISTRO_NAME_L}" = "ubuntu" ]; then + if [ "${DISTRO_VERSION}" = "16.10" ] || [ "$DISTRO_MAJOR_VERSION" -gt 16 ]; then + GNUPG_CURL="gnupg1-curl" + fi fi - #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __function_defined # DESCRIPTION: Checks if a function is defined within this scripts scope @@ -1543,7 +1624,7 @@ __rpm_import_gpg() { __yum_install_noinput() { ENABLE_EPEL_CMD="" - if [ $_DISABLE_REPOS -eq $BS_TRUE ]; then + if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then ENABLE_EPEL_CMD="--enablerepo=${_EPEL_REPO}" fi @@ -1571,6 +1652,15 @@ __git_clone_and_checkout() { export GIT_SSL_NO_VERIFY=1 fi + case ${OS_NAME_L} in + openbsd|freebsd|netbsd ) + __TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed -E 's/^(v?[0-9]{1,4}\.[0-9]{1,2})(\.[0-9]{1,2})?.*$/MATCH/') + ;; + * ) + __TAG_REGEX_MATCH=$(echo "${GIT_REV}" | sed 's/^.*\(v\?[[:digit:]]\{1,4\}\.[[:digit:]]\{1,2\}\)\(\.[[:digit:]]\{1,2\}\)\?.*$/MATCH/') + ;; + esac + __SALT_GIT_CHECKOUT_PARENT_DIR=$(dirname "${_SALT_GIT_CHECKOUT_DIR}" 2>/dev/null) __SALT_GIT_CHECKOUT_PARENT_DIR="${__SALT_GIT_CHECKOUT_PARENT_DIR:-/tmp/git}" __SALT_CHECKOUT_REPONAME="$(basename "${_SALT_GIT_CHECKOUT_DIR}" 2>/dev/null)" @@ -1616,7 +1706,7 @@ __git_clone_and_checkout() { if [ "$_FORCE_SHALLOW_CLONE" -eq "${BS_TRUE}" ]; then echoinfo "Forced shallow cloning of git repository." __SHALLOW_CLONE=$BS_TRUE - elif [ "$(echo "$GIT_REV" | sed 's/^.*\(v\?[[:digit:]]\{1,4\}\.[[:digit:]]\{1,2\}\)\(\.[[:digit:]]\{1,2\}\)\?.*$/MATCH/')" = "MATCH" ]; then + elif [ "$__TAG_REGEX_MATCH" = "MATCH" ]; then echoinfo "Git revision matches a Salt version tag, shallow cloning enabled." __SHALLOW_CLONE=$BS_TRUE else @@ -1750,7 +1840,7 @@ __check_end_of_life_versions() { centos) # CentOS versions lower than 5 are no longer supported - if [ "$DISTRO_MAJOR_VERSION" -lt 5 ]; then + if [ "$DISTRO_MAJOR_VERSION" -lt 6 ]; then echoerror "End of life distributions are not supported." echoerror "Please consider upgrading to the next stable. See:" echoerror " http://wiki.centos.org/Download" @@ -1760,7 +1850,7 @@ __check_end_of_life_versions() { red_hat*linux) # Red Hat (Enterprise) Linux versions lower than 5 are no longer supported - if [ "$DISTRO_MAJOR_VERSION" -lt 5 ]; then + if [ "$DISTRO_MAJOR_VERSION" -lt 6 ]; then 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/" @@ -1768,6 +1858,36 @@ __check_end_of_life_versions() { fi ;; + oracle*linux) + # Oracle Linux versions lower than 5 are no longer supported + if [ "$DISTRO_MAJOR_VERSION" -lt 6 ]; then + 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) + # Scientific Linux versions lower than 5 are no longer supported + if [ "$DISTRO_MAJOR_VERSION" -lt 6 ]; then + 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) + # Cloud Linux versions lower than 5 are no longer supported + if [ "$DISTRO_MAJOR_VERSION" -lt 6 ]; then + 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) # Amazon Linux versions lower than 2012.0X no longer supported if [ "$DISTRO_MAJOR_VERSION" -lt 2012 ]; then @@ -2136,6 +2256,32 @@ __check_services_openbsd() { fi } # ---------- end of function __check_services_openbsd ---------- +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: __check_services_alpine +# DESCRIPTION: Return 0 or 1 in case the service is enabled or not +# PARAMETERS: servicename +#---------------------------------------------------------------------------------------------------------------------- +__check_services_alpine() { + 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 + if rc-status $(rc-status -r) | tail -n +2 | grep -q "\<$servicename\>"; then + echodebug "Service ${servicename} is enabled" + return 0 + else + echodebug "Service ${servicename} is NOT enabled" + return 1 + fi +} # ---------- end of function __check_services_openbsd ---------- + #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __create_virtualenv @@ -2171,6 +2317,36 @@ __activate_virtualenv() { return 0 } # ---------- end of function __activate_virtualenv ---------- +#--- FUNCTION ------------------------------------------------------------------------------------------------------- +# NAME: __install_pip_pkgs +# DESCRIPTION: Return 0 or 1 if successfully able to install pip packages. Can provide a different python version to +# install pip packages with. If $py_ver is not specified it will use the default python version. +# PARAMETERS: pkgs, py_ver +#---------------------------------------------------------------------------------------------------------------------- + +__install_pip_pkgs() { + _pip_pkgs="$1" + _py_exe="$2" + _py_pkg=$(echo "$_py_exe" | sed -r "s/\.//g") + _pip_cmd="${_py_exe} -m pip" + + if [ "${_py_exe}" = "" ]; then + _py_exe='python' + fi + + __check_pip_allowed + + # Install pip and pip dependencies + if ! __check_command_exists "${_pip_cmd} --version"; then + __PACKAGES="${_py_pkg}-setuptools ${_py_pkg}-pip gcc ${_py_pkg}-devel" + # shellcheck disable=SC2086 + __yum_install_noinput ${__PACKAGES} || return 1 + fi + + echoinfo "Installing pip packages: ${_pip_pkgs} using ${_py_exe}" + # shellcheck disable=SC2086 + ${_pip_cmd} install ${_pip_pkgs} || return 1 +} #--- FUNCTION ------------------------------------------------------------------------------------------------------- # NAME: __install_pip_deps @@ -2393,12 +2569,12 @@ install_ubuntu_stable_deps() { __REPO_ARCH="$DPKG_ARCHITECTURE" if [ "$DPKG_ARCHITECTURE" = "i386" ]; then - echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Ubuntu $DISTRO_MAJOR_VERSION (yet?)." + echoerror "$_REPO_URL likely doesn't have all required 32-bit packages for Ubuntu $DISTRO_MAJOR_VERSION (yet?)." # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location __REPO_ARCH="amd64" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then - echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + echoerror "$_REPO_URL doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." if [ "$ITYPE" != "git" ]; then echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" exit 1 @@ -2408,17 +2584,17 @@ install_ubuntu_stable_deps() { # Versions starting with 2015.5.6, 2015.8.1 and 2016.3.0 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|2016\.11|latest|archive\/)')" != "" ]; then # Workaround for latest non-LTS ubuntu - if [ "$DISTRO_VERSION" = "16.10" ]; then + if [ "$DISTRO_VERSION" = "16.10" ] || [ "$DISTRO_MAJOR_VERSION" -gt 16 ]; then echowarn "Non-LTS Ubuntu detected, but stable packages requested. Trying packages from latest LTS release. You may experience problems." UBUNTU_VERSION=16.04 - UBUNTU_CODENAME=xenial + UBUNTU_CODENAME="xenial" else UBUNTU_VERSION=$DISTRO_VERSION UBUNTU_CODENAME=$DISTRO_CODENAME fi # SaltStack's stable Ubuntu repository: - SALTSTACK_UBUNTU_URL="${HTTP_VAL}://repo.saltstack.com/apt/ubuntu/${UBUNTU_VERSION}/${__REPO_ARCH}/${STABLE_REV}" + SALTSTACK_UBUNTU_URL="${HTTP_VAL}://${_REPO_URL}/apt/ubuntu/${UBUNTU_VERSION}/${__REPO_ARCH}/${STABLE_REV}" echo "deb $SALTSTACK_UBUNTU_URL $UBUNTU_CODENAME main" > /etc/apt/sources.list.d/saltstack.list # Make sure https transport is available @@ -2794,7 +2970,7 @@ install_debian_7_deps() { __REPO_ARCH="$DPKG_ARCHITECTURE" if [ "$DPKG_ARCHITECTURE" = "i386" ]; then - echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." + echoerror "$_REPO_URL likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." if [ "$ITYPE" != "git" ]; then echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" @@ -2803,14 +2979,14 @@ install_debian_7_deps() { # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location __REPO_ARCH="amd64" elif [ "$DPKG_ARCHITECTURE" != "amd64" ]; then - echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + echoerror "$_REPO_URL doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." exit 1 fi # Versions starting with 2015.8.7 and 2016.3.0 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.8|2016\.3|2016\.11|latest|archive\/201[5-6]\.)')" != "" ]; then # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location - SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/${DISTRO_MAJOR_VERSION}/${__REPO_ARCH}/${STABLE_REV}" + SALTSTACK_DEBIAN_URL="${HTTP_VAL}://${_REPO_URL}/apt/debian/${DISTRO_MAJOR_VERSION}/${__REPO_ARCH}/${STABLE_REV}" echo "deb $SALTSTACK_DEBIAN_URL wheezy main" > "/etc/apt/sources.list.d/saltstack.list" if [ "$HTTP_VAL" = "https" ] ; then @@ -2826,7 +3002,7 @@ install_debian_7_deps() { apt-get update else - echowarn "Packages from repo.saltstack.com are required to install Salt version 2015.8 or higher on Debian $DISTRO_MAJOR_VERSION." + echowarn "Packages from $_REPO_URL are required to install Salt version 2015.8 or higher on Debian $DISTRO_MAJOR_VERSION." fi # Additionally install procps and pciutils which allows for Docker bootstraps. See 366#issuecomment-39666813 @@ -2873,7 +3049,7 @@ install_debian_8_deps() { __REPO_ARCH="$DPKG_ARCHITECTURE" if [ "$DPKG_ARCHITECTURE" = "i386" ]; then - echoerror "repo.saltstack.com likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." + echoerror "$_REPO_URL likely doesn't have all required 32-bit packages for Debian $DISTRO_MAJOR_VERSION (yet?)." if [ "$ITYPE" != "git" ]; then echoerror "You can try git installation mode, i.e.: sh ${__ScriptName} git v2016.3.1" @@ -2882,7 +3058,7 @@ install_debian_8_deps() { # amd64 is just a part of repository URI, 32-bit pkgs are hosted under the same location __REPO_ARCH="amd64" elif [ "$DPKG_ARCHITECTURE" != "amd64" ] && [ "$DPKG_ARCHITECTURE" != "armhf" ]; then - echoerror "repo.saltstack.com doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." + echoerror "$_REPO_URL doesn't have packages for your system architecture: $DPKG_ARCHITECTURE." echoerror "Try git installation mode with pip and disable SaltStack apt repository, for example:" echoerror " sh ${__ScriptName} -r -P git v2016.3.1" @@ -2891,7 +3067,7 @@ install_debian_8_deps() { # Versions starting with 2015.5.6, 2015.8.1 and 2016.3.0 are hosted at repo.saltstack.com if [ "$(echo "$STABLE_REV" | egrep '^(2015\.5|2015\.8|2016\.3|2016\.11|latest|archive\/201[5-6]\.)')" != "" ]; then - SALTSTACK_DEBIAN_URL="${HTTP_VAL}://repo.saltstack.com/apt/debian/${DISTRO_MAJOR_VERSION}/${__REPO_ARCH}/${STABLE_REV}" + SALTSTACK_DEBIAN_URL="${HTTP_VAL}://${_REPO_URL}/apt/debian/${DISTRO_MAJOR_VERSION}/${__REPO_ARCH}/${STABLE_REV}" echo "deb $SALTSTACK_DEBIAN_URL jessie main" > "/etc/apt/sources.list.d/saltstack.list" if [ "$HTTP_VAL" = "https" ] ; then @@ -3396,18 +3572,10 @@ __install_epel_repository() { # Download latest 'epel-release' package for the distro version directly epel_repo_url="${HTTP_VAL}://dl.fedoraproject.org/pub/epel/epel-release-latest-${DISTRO_MAJOR_VERSION}.noarch.rpm" - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - __fetch_url /tmp/epel-release.rpm "$epel_repo_url" || return 1 - rpm -Uvh --force /tmp/epel-release.rpm || return 1 - rm -f /tmp/epel-release.rpm - elif [ "$DISTRO_MAJOR_VERSION" -ge 6 ]; then - rpm -Uvh --force "$epel_repo_url" || return 1 - else - echoerror "Failed add EPEL repository support." - return 1 - fi + rpm -Uvh --force "$epel_repo_url" || return 1 _EPEL_REPOS_INSTALLED=$BS_TRUE + return 0 } @@ -3432,34 +3600,17 @@ __install_saltstack_rhel_repository() { repo_rev="latest" fi - # Check if a custom repo URL was passed with -R. If not, use repo.salstack.com. - if [ "$_CUSTOM_REPO_URL" != "null" ]; then - repo_url="$_CUSTOM_REPO_URL" - else - repo_url="repo.saltstack.com" - fi - - # Cloud Linux $releasever = 7.x, which doesn't exist in repo.saltstack.com, we need this to be "7" - if [ "${DISTRO_NAME}" = "Cloud Linux" ] && [ "${DISTRO_MAJOR_VERSION}" = "7" ]; then - base_url="${HTTP_VAL}://${repo_url}/yum/redhat/${DISTRO_MAJOR_VERSION}/\$basearch/${repo_rev}/" - else - base_url="${HTTP_VAL}://${repo_url}/yum/redhat/\$releasever/\$basearch/${repo_rev}/" - fi - - fetch_url="${HTTP_VAL}://${repo_url}/yum/redhat/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/${repo_rev}/" - - if [ "${DISTRO_MAJOR_VERSION}" -eq 5 ]; then - gpg_key="SALTSTACK-EL5-GPG-KEY.pub" - else - gpg_key="SALTSTACK-GPG-KEY.pub" - fi - + # Avoid using '$releasever' variable for yum. + # Instead, this should work correctly on all RHEL variants. + base_url="${HTTP_VAL}://${_REPO_URL}/yum/redhat/${DISTRO_MAJOR_VERSION}/\$basearch/${repo_rev}/" + gpg_key="SALTSTACK-GPG-KEY.pub" repo_file="/etc/yum.repos.d/saltstack.repo" + if [ ! -s "$repo_file" ]; then cat <<_eof > "$repo_file" [saltstack] name=SaltStack ${repo_rev} Release Channel for RHEL/CentOS \$releasever -baseurl=$base_url +baseurl=${base_url} skip_if_unavailable=True gpgcheck=1 gpgkey=${base_url}${gpg_key} @@ -3467,16 +3618,10 @@ enabled=1 enabled_metadata=1 _eof + fetch_url="${HTTP_VAL}://${_REPO_URL}/yum/redhat/${DISTRO_MAJOR_VERSION}/${CPU_ARCH_L}/${repo_rev}/" __rpm_import_gpg "${fetch_url}${gpg_key}" || return 1 fi - if [ "$DISTRO_MAJOR_VERSION" -eq 7 ] && ([ "$repo_rev" = "latest" ] || [ "$repo_rev" = "2015.8" ]); then - # Import CentOS 7 GPG key on RHEL for installing base dependencies from - # Salt corporate repository - rpm -qa gpg-pubkey\* --qf "%{name}-%{version}\n" | grep -q ^gpg-pubkey-f4a80eb5$ || \ - __rpm_import_gpg "${HTTP_VAL}://${repo_url}/yum/redhat/7/x86_64/${repo_rev}/base/RPM-GPG-KEY-CentOS-7" || return 1 - fi - return 0 } @@ -3505,11 +3650,6 @@ install_centos_stable_deps() { yum -y update || return 1 fi - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - # Install curl which is not included in @core CentOS 5 installation - __check_command_exists curl || yum -y install "curl.${CPU_ARCH_L}" || return 1 - fi - if [ $_DISABLE_REPOS -eq $BS_FALSE ]; then __install_epel_repository || return 1 __install_saltstack_rhel_repository || return 1 @@ -3522,14 +3662,8 @@ install_centos_stable_deps() { __install_saltstack_rhel_repository || return 1 fi - __PACKAGES="yum-utils chkconfig" - # YAML module is used for generating custom master/minion configs - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - __PACKAGES="${__PACKAGES} python26-PyYAML" - else - __PACKAGES="${__PACKAGES} PyYAML" - fi + __PACKAGES="yum-utils chkconfig PyYAML" # shellcheck disable=SC2086 __yum_install_noinput ${__PACKAGES} || return 1 @@ -3598,31 +3732,19 @@ install_centos_stable_post() { } install_centos_git_deps() { - if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then - if [ "$DISTRO_MAJOR_VERSION" -gt 5 ]; then - __yum_install_noinput ca-certificates || return 1 - else - __yum_install_noinput "openssl.${CPU_ARCH_L}" || return 1 - fi - fi - install_centos_stable_deps || return 1 + if [ "$_INSECURE_DL" -eq $BS_FALSE ] && [ "${_SALT_REPO_URL%%://*}" = "https" ]; then + __yum_install_noinput ca-certificates || return 1 + fi + if ! __check_command_exists git; then __yum_install_noinput git || return 1 fi __git_clone_and_checkout || return 1 - __PACKAGES="" - - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - __PACKAGES="${__PACKAGES} python26 python26-crypto python26-jinja2 python26-msgpack python26-requests" - __PACKAGES="${__PACKAGES} python26-tornado python26-zmq" - else - __PACKAGES="${__PACKAGES} python-crypto python-futures python-msgpack python-zmq python-jinja2" - __PACKAGES="${__PACKAGES} python-requests python-tornado" - fi + __PACKAGES="python-crypto python-futures python-msgpack python-zmq python-jinja2 python-requests python-tornado" if [ "$DISTRO_MAJOR_VERSION" -ge 7 ]; then __PACKAGES="${__PACKAGES} systemd-python" @@ -3632,8 +3754,12 @@ install_centos_git_deps() { __PACKAGES="${__PACKAGES} python-libcloud" fi - # shellcheck disable=SC2086 - __yum_install_noinput ${__PACKAGES} || return 1 + if [ "${_INSTALL_PY}" = "${BS_TRUE}" ]; then + __install_python_and_deps || return 1 + else + # shellcheck disable=SC2086 + __yum_install_noinput ${__PACKAGES} || return 1 + fi # Let's trigger config_salt() if [ "$_TEMP_CONFIG_DIR" = "null" ]; then @@ -3645,10 +3771,11 @@ install_centos_git_deps() { } install_centos_git() { - if [ "$DISTRO_MAJOR_VERSION" -eq 5 ]; then - _PYEXE=python2.6 + if [ "${_PY_EXE}" != "" ]; then + _PYEXE=${_PY_EXE} + echoinfo "Using the following python version: ${_PY_EXE} to install salt" else - _PYEXE=python2 + _PYEXE='python2' fi if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then @@ -3724,9 +3851,9 @@ install_centos_restart_daemons() { return 1 fi elif [ -f /etc/init.d/salt-$fname ]; then - # Still in SysV init!? - /etc/init.d/salt-$fname stop > /dev/null 2>&1 - /etc/init.d/salt-$fname start + # Disable stdin to fix shell session hang on killing tee pipe + service salt-$fname stop < /dev/null > /dev/null 2>&1 + service salt-$fname start < /dev/null elif [ -f /usr/bin/systemctl ]; then # CentOS 7 uses systemd /usr/bin/systemctl stop salt-$fname > /dev/null 2>&1 @@ -4158,12 +4285,189 @@ install_cloud_linux_check_services() { # ####################################################################################################################### +####################################################################################################################### +# +# Alpine Linux Install Functions +# +install_alpine_linux_stable_deps() { + 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 + fi + + apk update + + # Get latest root CA certs + apk -U add ca-certificates + + 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 + + apk -U add python2 py-virtualenv py2-crypto py2-setuptools \ + py2-jinja2 py2-yaml py2-markupsafe py2-msgpack py2-psutil \ + py2-zmq zeromq py2-requests || return 1 + + if ! __check_command_exists git; then + apk -U add git || return 1 + fi + + __git_clone_and_checkout || return 1 + + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt" ]; then + # We're on the develop branch, install whichever tornado is on the requirements file + __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" + if [ "${__REQUIRED_TORNADO}" != "" ]; then + apk -U add py2-tornado || return 1 + fi + fi + + # Let's trigger config_salt() + if [ "$_TEMP_CONFIG_DIR" = "null" ]; then + _TEMP_CONFIG_DIR="${_SALT_GIT_CHECKOUT_DIR}/conf/" + CONFIG_SALT_FUNC="config_salt" + fi +} + +install_alpine_linux_stable() { + __PACKAGES="salt" + + if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ];then + __PACKAGES="${__PACKAGES} salt-cloud" + fi + if [ "$_INSTALL_MASTER" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-master" + fi + if [ "$_INSTALL_MINION" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-minion" + fi + if [ "$_INSTALL_SYNDIC" -eq $BS_TRUE ]; then + __PACKAGES="${__PACKAGES} salt-syndic" + fi + + # shellcheck disable=SC2086 + apk -U add ${__PACKAGES} || return 1 + return 0 +} + +install_alpine_linux_git() { + if [ -f "${_SALT_GIT_CHECKOUT_DIR}/salt/syspaths.py" ]; then + python2 setup.py --salt-config-dir="$_SALT_ETC_DIR" --salt-cache-dir="${_SALT_CACHE_DIR}" ${SETUP_PY_INSTALL_ARGS} install || return 1 + else + python2 setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + fi +} + +install_alpine_linux_post() { + for fname in api master minion syndic; do + # Skip if not meant to be installed + [ $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 + + if [ -f /sbin/rc-update ]; then + script_url="${_SALTSTACK_REPO_URL%.git}/raw/develop/pkg/alpine/salt-$fname" + [ -f "/etc/init.d/salt-$fname" ] || __fetch_url "/etc/init.d/salt-$fname" "$script_url" + + 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 + + # Skip salt-api since the service should be opt-in and not necessarily started on boot + [ $fname = "api" ] && continue + + /sbin/rc-update add "salt-$fname" > /dev/null 2>&1 || return 1 + fi + done +} + +install_alpine_linux_restart_daemons() { + [ "${_START_DAEMONS}" -eq $BS_FALSE ] && return + + 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 + + # Disable stdin to fix shell session hang on killing tee pipe + /sbin/rc-service salt-$fname stop < /dev/null > /dev/null 2>&1 + /sbin/rc-service salt-$fname start < /dev/null || return 1 + done +} + +install_alpine_linux_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 + [ $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 + + __check_services_alpine salt-$fname || return 1 + done + + return 0 +} + +daemons_running_alpine_linux() { + [ "${_START_DAEMONS}" -eq $BS_FALSE ] && return + + 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 + [ $fname = "api" ] && continue + + # Skip if not meant to be installed + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + + # shellcheck disable=SC2009 + if [ "$(ps wwwaux | grep -v grep | grep salt-$fname)" = "" ]; then + echoerror "salt-$fname was not found running" + FAILED_DAEMONS=$((FAILED_DAEMONS + 1)) + fi + done + + return $FAILED_DAEMONS +} + +# +# Ended Alpine Linux Install Functions +# +####################################################################################################################### + + ####################################################################################################################### # # Amazon Linux AMI Install Functions # install_amazon_linux_ami_deps() { + # Shim to figure out if we're using old (rhel) or new (aws) rpms. + _USEAWS=$BS_FALSE + + repo_rev="$(echo "${STABLE_REV}" | sed 's|.*\/||g')" + + if echo "$repo_rev" | egrep -q '^(latest|2016\.11)$'; then + _USEAWS=$BS_TRUE + elif echo "$repo_rev" | egrep -q '^[0-9]+$' && [ "$(echo "$repo_rev" | cut -c1-4)" -gt 2016 ]; then + _USEAWS=$BS_TRUE + fi # We need to install yum-utils before doing anything else when installing on # Amazon Linux ECS-optimized images. See issue #974. @@ -4183,15 +4487,31 @@ install_amazon_linux_ami_deps() { __REPO_FILENAME="saltstack-repo.repo" + # Set a few vars to make life easier. + if [ $_USEAWS -eq $BS_TRUE ]; then + base_url="$HTTP_VAL://repo.saltstack.com/yum/amazon/latest/\$basearch/$repo_rev/" + gpg_key="${base_url}SALTSTACK-GPG-KEY.pub" + repo_name="SaltStack repo for Amazon Linux" + pkg_append="python27" + else + base_url="$HTTP_VAL://repo.saltstack.com/yum/redhat/6/\$basearch/$repo_rev/" + gpg_key="${base_url}SALTSTACK-GPG-KEY.pub" + repo_name="SaltStack repo for RHEL/CentOS 6" + pkg_append="python" + fi + + # This should prob be refactored to use __install_saltstack_rhel_repository() + # 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}" [saltstack-repo] -disabled=False -name=SaltStack repo for RHEL/CentOS 6 +name=$repo_name +failovermethod=priority +priority=10 gpgcheck=1 -gpgkey=$HTTP_VAL://repo.saltstack.com/yum/redhat/6/\$basearch/$STABLE_REV/SALTSTACK-GPG-KEY.pub -baseurl=$HTTP_VAL://repo.saltstack.com/yum/redhat/6/\$basearch/$STABLE_REV/ -humanname=SaltStack repo for RHEL/CentOS 6 +gpgkey=$gpg_key +baseurl=$base_url _eof fi @@ -4199,8 +4519,9 @@ _eof yum -y update || return 1 fi fi - - __PACKAGES="PyYAML python-crypto python-msgpack python-zmq python26-ordereddict python-jinja2 python-requests" + #ordereddict removed. + #Package python-ordereddict-1.1-2.el6.noarch is obsoleted by python26-2.6.9-2.88.amzn1.x86_64 which is already installed + __PACKAGES="${pkg_append}-PyYAML ${pkg_append}-crypto ${pkg_append}-msgpack ${pkg_append}-zmq ${pkg_append}-jinja2 ${pkg_append}-requests" # shellcheck disable=SC2086 yum -y install ${__PACKAGES} ${ENABLE_EPEL_CMD} || return 1 @@ -4217,6 +4538,15 @@ install_amazon_linux_ami_git_deps() { yum -y install ca-certificates || return 1 fi + PIP_EXE='pip' + if __check_command_exists python2.7; then + if ! __check_command_exists pip2.7; then + /usr/bin/easy_install-2.7 pip || return 1 + fi + PIP_EXE='/usr/local/bin/pip2.7' + _PY_EXE='python2.7' + fi + install_amazon_linux_ami_deps || return 1 ENABLE_EPEL_CMD="" @@ -4243,7 +4573,7 @@ install_amazon_linux_ami_git_deps() { # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" if [ "${__REQUIRED_TORNADO}" != "" ]; then - __PACKAGES="${__PACKAGES} python-tornado" + __PACKAGES="${__PACKAGES} ${pkg_append}-tornado" fi fi @@ -4254,7 +4584,7 @@ install_amazon_linux_ami_git_deps() { if [ "${__PIP_PACKAGES}" != "" ]; then # shellcheck disable=SC2086 - pip-python install ${__PIP_PACKAGES} || return 1 + ${PIP_EXE} install ${__PIP_PACKAGES} || return 1 fi # Let's trigger config_salt() @@ -4314,29 +4644,29 @@ install_arch_linux_stable_deps() { pacman-key --init && pacman-key --populate archlinux || return 1 fi - pacman -Sy --noconfirm --needed archlinux-keyring || return 1 + # Pacman does not resolve dependencies on outdated versions + # They always need to be updated + pacman -Syy --noconfirm - pacman -Sy --noconfirm --needed pacman || return 1 + pacman -S --noconfirm --needed archlinux-keyring || return 1 + + pacman -Su --noconfirm --needed pacman || return 1 if __check_command_exists pacman-db-upgrade; then pacman-db-upgrade || return 1 fi # YAML module is used for generating custom master/minion configs - pacman -Sy --noconfirm --needed python2-yaml - - if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then - pacman -Syyu --noconfirm --needed || return 1 - fi + pacman -Su --noconfirm --needed python2-yaml if [ "$_INSTALL_CLOUD" -eq $BS_TRUE ]; then - pacman -Sy --noconfirm --needed apache-libcloud || return 1 + pacman -Su --noconfirm --needed apache-libcloud || return 1 fi if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" # shellcheck disable=SC2086 - pacman -Sy --noconfirm --needed ${_EXTRA_PACKAGES} || return 1 + pacman -Su --noconfirm --needed ${_EXTRA_PACKAGES} || return 1 fi } @@ -4348,7 +4678,7 @@ install_arch_linux_git_deps() { pacman -Sy --noconfirm --needed git || return 1 fi pacman -R --noconfirm python2-distribute - pacman -Sy --noconfirm --needed python2-crypto python2-setuptools python2-jinja \ + pacman -Su --noconfirm --needed python2-crypto python2-setuptools python2-jinja \ python2-markupsafe python2-msgpack python2-psutil \ python2-pyzmq zeromq python2-requests python2-systemd || return 1 @@ -4358,7 +4688,7 @@ install_arch_linux_git_deps() { # We're on the develop branch, install whichever tornado is on the requirements file __REQUIRED_TORNADO="$(grep tornado "${_SALT_GIT_CHECKOUT_DIR}/requirements/base.txt")" if [ "${__REQUIRED_TORNADO}" != "" ]; then - pacman -Sy --noconfirm --needed python2-tornado + pacman -Su --noconfirm --needed python2-tornado fi fi @@ -4373,7 +4703,11 @@ install_arch_linux_git_deps() { } install_arch_linux_stable() { - pacman -Sy --noconfirm --needed pacman || return 1 + # Pacman does not resolve dependencies on outdated versions + # They always need to be updated + pacman -Syy --noconfirm + + pacman -Su --noconfirm --needed pacman || return 1 # 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 @@ -4575,6 +4909,8 @@ __configure_freebsd_pkg_details() { ## ensure future ports builds use pkgng echo "WITH_PKGNG= yes" >> /etc/make.conf + + /usr/local/sbin/pkg update -f || return 1 } install_freebsd_9_stable_deps() { @@ -4630,6 +4966,11 @@ install_freebsd_11_stable_deps() { install_freebsd_git_deps() { install_freebsd_9_stable_deps || return 1 + # shellcheck disable=SC2086 + SALT_DEPENDENCIES=$(/usr/local/sbin/pkg search ${FROM_FREEBSD} -R -d sysutils/py-salt | grep -i origin | sed -e 's/^[[:space:]]*//' | tail -n +2 | awk -F\" '{print $2}' | tr '\n' ' ') + # shellcheck disable=SC2086 + /usr/local/sbin/pkg install ${FROM_FREEBSD} -y ${SALT_DEPENDENCIES} || return 1 + if ! __check_command_exists git; then /usr/local/sbin/pkg install -y git || return 1 fi @@ -4691,7 +5032,9 @@ install_freebsd_9_stable() { } install_freebsd_10_stable() { - install_freebsd_9_stable + # shellcheck disable=SC2086 + /usr/local/sbin/pkg install ${FROM_FREEBSD} -y sysutils/py-salt || return 1 + return 0 } install_freebsd_11_stable() { @@ -4705,40 +5048,37 @@ install_freebsd_11_stable() { } install_freebsd_git() { - # shellcheck disable=SC2086 - /usr/local/sbin/pkg install ${FROM_SALTSTACK} -y sysutils/py-salt || return 1 - # Let's keep the rc.d files before deleting the package - mkdir /tmp/rc-scripts || return 1 - cp /usr/local/etc/rc.d/salt* /tmp/rc-scripts || return 1 - - # Let's delete the package - /usr/local/sbin/pkg delete -y sysutils/py-salt || return 1 + # /usr/local/bin/python2 in FreeBSD is a symlink to /usr/local/bin/python2.7 + __PYTHON_PATH=$(readlink -f "$(which python2)") + __ESCAPED_PYTHON_PATH=$(echo "${__PYTHON_PATH}" | sed 's/\//\\\//g') # Install from git if [ ! -f salt/syspaths.py ]; then # We still can't provide the system paths, salt 0.16.x - /usr/local/bin/python2 setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 + ${__PYTHON_PATH} setup.py ${SETUP_PY_INSTALL_ARGS} install || return 1 else - /usr/local/bin/python2 setup.py \ - --salt-root-dir=/usr/local \ + ${__PYTHON_PATH} setup.py \ + --salt-root-dir=/ \ --salt-config-dir="${_SALT_ETC_DIR}" \ --salt-cache-dir="${_SALT_CACHE_DIR}" \ --salt-sock-dir=/var/run/salt \ - --salt-srv-root-dir=/srv \ + --salt-srv-root-dir="${_SALT_ETC_DIR}" \ --salt-base-file-roots-dir="${_SALT_ETC_DIR}/states" \ --salt-base-pillar-roots-dir="${_SALT_ETC_DIR}/pillar" \ --salt-base-master-roots-dir="${_SALT_ETC_DIR}/salt-master" \ --salt-logs-dir=/var/log/salt \ - --salt-pidfile-dir=/var/run ${SETUP_PY_INSTALL_ARGS} install \ + --salt-pidfile-dir=/var/run \ + ${SETUP_PY_INSTALL_ARGS} install \ || return 1 fi - # Restore the rc.d scripts - cp /tmp/rc-scripts/salt* /usr/local/etc/rc.d/ || return 1 - - # Delete our temporary scripts directory - rm -rf /tmp/rc-scripts || return 1 + for script in salt_api salt_master salt_minion salt_proxy salt_syndic; do + __fetch_url "/usr/local/etc/rc.d/${script}" "https://raw.githubusercontent.com/freebsd/freebsd-ports/master/sysutils/py-salt/files/${script}.in" || return 1 + sed -i '' 's/%%PREFIX%%/\/usr\/local/g' /usr/local/etc/rc.d/${script} + sed -i '' "s/%%PYTHON_CMD%%/${__ESCAPED_PYTHON_PATH}/g" /usr/local/etc/rc.d/${script} + chmod +x /usr/local/etc/rc.d/${script} || return 1 + done # And we're good to go return 0 @@ -4774,6 +5114,9 @@ install_freebsd_11_stable_post() { } install_freebsd_git_post() { + if [ -f $salt_conf_file ]; then + rm -f $salt_conf_file + fi install_freebsd_9_stable_post || return 1 return 0 } @@ -4807,7 +5150,7 @@ install_freebsd_restart_daemons() { __choose_openbsd_mirror() { OPENBSD_REPO='' MINTIME='' - MIRROR_LIST=$(awk -F= '/installpath = / {print $2}' /etc/examples/pkg.conf) + MIRROR_LIST=$(ftp -w 15 -Vao - 'http://ftp.openbsd.org/cgi-bin/ftplist.cgi?dbversion=1' | awk '/^http/ {print $1}') for MIRROR in $MIRROR_LIST; do MIRROR_HOST=$(echo "$MIRROR" | sed -e 's|.*//||' -e 's|+*/.*$||') @@ -4831,7 +5174,7 @@ install_openbsd_deps() { __choose_openbsd_mirror || return 1 echoinfo "setting package repository to $OPENBSD_REPO with ping time of $MINTIME" [ -n "$OPENBSD_REPO" ] || return 1 - echo "installpath += ${OPENBSD_REPO}" >>/etc/pkg.conf || return 1 + echo "${OPENBSD_REPO}" >>/etc/installurl || return 1 if [ "${_EXTRA_PACKAGES}" != "" ]; then echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" @@ -5557,7 +5900,6 @@ install_suse_12_stable_post() { # shellcheck disable=SC2086 curl $_CURL_ARGS -L "https://github.com/saltstack/salt/raw/develop/pkg/salt-$fname.service" \ -o "/usr/lib/systemd/system/salt-$fname.service" || return 1 - continue fi # Skip salt-api since the service should be opt-in and not necessarily started on boot @@ -5951,6 +6293,84 @@ install_gentoo_check_services() { # ####################################################################################################################### +####################################################################################################################### +# +# VoidLinux Install Functions +# +install_voidlinux_stable_deps() { + if [ "$_UPGRADE_SYS" -eq $BS_TRUE ]; then + xbps-install -Suy || return 1 + fi + + if [ "${_EXTRA_PACKAGES}" != "" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + xbps-install -Suy "${_EXTRA_PACKAGES}" || return 1 + 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 + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + + ln -s /etc/sv/salt-$fname /var/service/. + done +} + +install_voidlinux_restart_daemons() { + [ $_START_DAEMONS -eq $BS_FALSE ] && return + + for fname in master minion syndic; do + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + + sv restart salt-$fname + done +} + +install_voidlinux_check_services() { + for fname in master minion syndic; do + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + + [ -e /var/service/salt-$fname ] || return 1 + done + + return 0 +} + +daemons_running_voidlinux() { + [ "$_START_DAEMONS" -eq $BS_FALSE ] && return 0 + + FAILED_DAEMONS=0 + for fname in master minion syndic; do + [ $fname = "minion" ] && [ "$_INSTALL_MINION" -eq $BS_FALSE ] && continue + [ $fname = "master" ] && [ "$_INSTALL_MASTER" -eq $BS_FALSE ] && continue + [ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue + + if [ "$(sv status salt-$fname | grep run)" = "" ]; then + echoerror "salt-$fname was not found running" + FAILED_DAEMONS=$((FAILED_DAEMONS + 1)) + fi + done + + return $FAILED_DAEMONS +} +# +# Ended VoidLinux Install Functions +# +####################################################################################################################### + ####################################################################################################################### # # Default minion configuration function. Matches ANY distribution as long as diff --git a/tests/bootstrap/test_install.py b/tests/bootstrap/test_install.py index 3195c2e..5f52aa9 100644 --- a/tests/bootstrap/test_install.py +++ b/tests/bootstrap/test_install.py @@ -76,6 +76,10 @@ CLEANUP_COMMANDS_BY_OS_FAMILY = { 'zypper --non-interactive remove libzmq3 python-Jinja2 ' 'python-M2Crypto python-PyYAML python-msgpack-python ' 'python-pycrypto python-pyzmq', + ], + 'void': [ + "rm -rf /var/services/salt-*", + "xbps-remove -Ry salt; rc=$?; [ $rc -eq 6 ] || return $rc" ] }