From b5d7a41c9635e7f96bd156640a54851e66a2363a Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 16 Feb 2014 21:38:15 +0000 Subject: [PATCH] Allow passing extra packages to install. Fixes #262. --- bootstrap-salt.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 2079869..290dca4 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -221,6 +221,8 @@ usage() { -A Pass the salt-master DNS name or IP. This will be stored under \${BS_SALT_ETC_DIR}/minion.conf.d/99-master-address.conf -L Install the Apache Libcloud package if possible(required for salt-cloud) + -p Extra-package to install while installing salt dependencies. One package + per -p flag. You're responsible for providing the proper package name. EOT } # ---------- end of function usage ---------- @@ -256,8 +258,9 @@ _SALT_MASTER_ADDRESS="null" # __SIMPLIFY_VERSION is mostly used in Solaris based distributions __SIMPLIFY_VERSION=$BS_TRUE _LIBCLOUD_MIN_VERSION="0.14.0" +_EXTRA_PACKAGES="" -while getopts ":hvnDc:g:k:MSNXCPFUKIA:L" opt +while getopts ":hvnDc:g:k:MSNXCPFUKIA:Lp:" opt do case "${opt}" in @@ -297,6 +300,7 @@ do I ) _INSECURE_DL=$BS_TRUE ;; A ) _SALT_MASTER_ADDRESS=$OPTARG ;; L ) _INSTALL_CLOUD=$BS_TRUE ;; + p ) _EXTRA_PACKAGES="$_EXTRA_PACKAGES $OPTARG" ;; \?) echo @@ -1368,6 +1372,11 @@ install_ubuntu_deps() { __apt_get_upgrade_noinput || return 1 fi + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -1532,6 +1541,12 @@ install_debian_deps() { __apt_get_upgrade_noinput || return 1 fi + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1 + fi + + return 0 } install_debian_6_deps() { @@ -1601,6 +1616,12 @@ _eof fi __apt_get_install_noinput python-zmq || return 1 + + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -1657,6 +1678,11 @@ _eof __apt_get_upgrade_noinput || return 1 fi + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -1686,6 +1712,11 @@ install_debian_git_deps() { __apt_get_upgrade_noinput || return 1 fi + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + __apt_get_install_noinput ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -1829,6 +1860,11 @@ install_fedora_deps() { yum -y update || return 1 fi + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + yum install -y ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -1959,6 +1995,12 @@ install_centos_stable_deps() { pip-python install apache-libcloud>=$_LIBCLOUD_MIN_VERSION fi fi + + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + yum install -y ${_EXTRA_PACKAGES} --enablerepo=${_EPEL_REPO} || return 1 + fi + return 0 } @@ -2322,6 +2364,12 @@ install_amazon_linux_ami_deps() { check_pip_allowed "You need to allow pip based installations(-P) in order to install apache-libcloud" pip-python install apache-libcloud>=$_LIBCLOUD_MIN_VERSION fi + + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + yum install -y ${_EXTRA_PACKAGES} --enablerepo=${_EPEL_REPO} || return 1 + fi + } install_amazon_linux_ami_git_deps() { @@ -2401,10 +2449,15 @@ _eof pacman -Syyu --noconfirm --needed || return 1 fi - if [ $_INSTALL_CLOUD -eq $BS_TRUE ]; then pacman -Sy --noconfirm --needed apache-libcloud || return 1 fi + + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + pacman -Sy --noconfirm --needed ${_EXTRA_PACKAGES} || return 1 + fi + } install_arch_linux_git_deps() { @@ -2597,6 +2650,11 @@ install_freebsd_9_stable_deps() { # Now install swig /usr/local/sbin/pkg install ${SALT_PKG_FLAGS} -y swig || return 1 + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + /usr/local/sbin/pkg install ${SALT_PKG_FLAGS} -y ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -2762,7 +2820,7 @@ install_freebsd_restart_daemons() { # SmartOS Install Functions # install_smartos_deps() { - pkgin -y in \ + pkgin -y install \ zeromq py27-m2crypto py27-crypto py27-msgpack py27-yaml \ py27-jinja2 py27-zmq || return 1 @@ -2783,13 +2841,18 @@ install_smartos_deps() { fi fi + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + pkgin -y install ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } install_smartos_git_deps() { install_smartos_deps || return 1 - pkgin -y in scmgit || return 1 + pkgin -y install scmgit || return 1 __git_clone_and_checkout || return 1 # Let's trigger config_salt() @@ -2802,7 +2865,7 @@ install_smartos_git_deps() { } install_smartos_stable() { - pkgin -y in salt || return 1 + pkgin -y install salt || return 1 return 0 } @@ -2927,6 +2990,11 @@ install_opensuse_stable_deps() { zypper --non-interactive install --auto-agree-with-licenses ${packages} || return 1 + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + zypper --non-interactive install --auto-agree-with-licenses ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -3105,6 +3173,12 @@ install_suse_11_stable_deps() { done fi fi + + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + zypper --non-interactive install --auto-agree-with-licenses ${_EXTRA_PACKAGES} || return 1 + fi + return 0 } @@ -3230,6 +3304,12 @@ __gentoo_post_dep() { fi __emerge -vo 'app-admin/salt' + + if [ "x${_EXTRA_PACKAGES}" != "x" ]; then + echoinfo "Installing the following extra packages as requested: ${_EXTRA_PACKAGES}" + __emerge -v ${_EXTRA_PACKAGES} || return 1 + fi + } install_gentoo_deps() {