merged github
commit
730caea7a3
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-24 00:05:26 +0100 (Mon, 24 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(dirname "$0")"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
usage(){
|
||||
cat <<EOF
|
||||
Checks a given list of APK packages and returns those already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on Alpine
|
||||
|
||||
|
||||
usage: ${0##*/} <packages>
|
||||
EOF
|
||||
exit 3
|
||||
}
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
-*) usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
installed_packages="$(mktemp)"
|
||||
trap 'rm -f "$installed_packages"' EXIT
|
||||
|
||||
installed_apk > "$installed_packages"
|
||||
|
||||
process_package_args "$@" |
|
||||
grep -Fx -f "$installed_packages"
|
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-24 00:05:26 +0100 (Mon, 24 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(dirname "$0")"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
usage(){
|
||||
cat <<EOF
|
||||
Checks a given list of APK packages and returns those not installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on Alpine
|
||||
|
||||
|
||||
usage: ${0##*/} <packages>
|
||||
EOF
|
||||
exit 3
|
||||
}
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
-*) usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
installed_packages="$(mktemp)"
|
||||
trap 'rm -f "$installed_packages"' EXIT
|
||||
|
||||
installed_apk > "$installed_packages"
|
||||
|
||||
process_package_args "$@" |
|
||||
grep -vFx -f "$installed_packages"
|
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2019-02-15 21:31:10 +0000 (Fri, 15 Feb 2019)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -eu
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(dirname "$0")"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
usage(){
|
||||
cat <<EOF
|
||||
Installs Alpine APK package lists if the packages aren't already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on Alpine
|
||||
|
||||
|
||||
usage: ${0##*/} <packages>
|
||||
EOF
|
||||
exit 3
|
||||
}
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
-*) usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
process_package_args "$@" |
|
||||
"$srcdir/apk_filter_not_installed.sh" |
|
||||
xargs -r "$srcdir/apk_install_packages.sh"
|
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 18:38:39 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -eu
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Installs Debian / Ubuntu deb package lists if the packages aren't already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on Debian and Ubuntu
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
process_package_args "$@" |
|
||||
"$srcdir/debs_filter_not_installed.sh" |
|
||||
xargs --no-run-if-empty "$srcdir/apt_install_packages.sh"
|
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-24 00:42:27 +0100 (Mon, 24 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Checks a given list of Mac Homebrew packages and returns those already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Support TAP=1 or CASK=1 environment variables for checking taps or casks respectively
|
||||
|
||||
Tested on Mac Homebrew
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
process_package_args "$@" |
|
||||
if [ -n "${TAP:-}" ]; then
|
||||
if [ -n "${NO_FAIL:-}" ]; then
|
||||
set +e
|
||||
fi
|
||||
installed_packages="$(brew list)"
|
||||
while read -r tap package; do
|
||||
grep -Fxq "$package" <<< "$installed_packages" &&
|
||||
echo "$tap $package"
|
||||
done
|
||||
else
|
||||
# do not quote cask, blank quotes break shells and there will never be any token splitting anyway
|
||||
# shellcheck disable=SC2046
|
||||
tr ' ' '\n' |
|
||||
grep -Fx -f <(brew $([ -z "${CASK:-}" ] || echo cask) list)
|
||||
fi
|
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-24 00:42:27 +0100 (Mon, 24 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Checks a given list of Mac Homebrew packages and returns those not installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Supports TAP=1 or CASK=1 environment variables for checking taps or casks respectively
|
||||
|
||||
Tested on Mac Homebrew
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
process_package_args "$@" |
|
||||
if [ -n "${TAP:-}" ]; then
|
||||
if [ -n "${NO_FAIL:-}" ]; then
|
||||
set +e
|
||||
fi
|
||||
installed_packages="$(brew list)"
|
||||
while read -r tap package; do
|
||||
grep -Fxq "$package" <<< "$installed_packages" ||
|
||||
echo "$tap $package"
|
||||
done
|
||||
else
|
||||
# do not quote cask, blank quotes break shells and there will never be any token splitting anyway
|
||||
# shellcheck disable=SC2046
|
||||
tr ' ' '\n' |
|
||||
grep -vFx -f <(brew $([ -z "${CASK:-}" ] || echo cask) list)
|
||||
fi
|
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2086
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 19:03:51 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
# Mac OSX - HomeBrew install packages in a forgiving way
|
||||
|
||||
set -eu #o pipefail # undefined in /bin/sh
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Installs Mac Homebrew package lists if the packages aren't already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on CentOS
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
process_package_args "$@" |
|
||||
"$srcdir/brew_filter_not_installed.sh" |
|
||||
gxargs --no-run-if-empty "$srcdir/brew_install_packages.sh"
|
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 23:25:39 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Checks a given list of Deb packages and returns those already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on Debian and Ubuntu
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
process_package_args "$@" |
|
||||
grep -Fx -f <(installed_debs)
|
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 23:25:39 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Checks a given list of Deb packages and returns those not installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on Debian and Ubuntu
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
process_package_args "$@" |
|
||||
grep -vFx -f <(installed_debs)
|
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 17:28:41 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
# Caveat: doesn't catch metapackages eg. vim on centos is resolved to vim-enhanced and doesn't match to prevent trying to install again
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
packages=("$@")
|
||||
|
||||
check_bin(){
|
||||
type -P "$@" &>/dev/null
|
||||
}
|
||||
|
||||
if check_bin apk; then
|
||||
"$srcdir/apk_install_packages_if_absent.sh" "${packages[@]}"
|
||||
elif check_bin apt-get dpkg; then
|
||||
"$srcdir/apt_install_packages_if_absent.sh" "${packages[@]}"
|
||||
elif check_bin yum rpm; then
|
||||
"$srcdir/yum_install_packages_if_absent.sh" "${packages[@]}"
|
||||
elif check_bin brew; then
|
||||
"$srcdir/brew_install_packages_if_absent.sh" "${packages[@]}"
|
||||
else
|
||||
echo "Unsupported OS / Package Manager"
|
||||
exit 1
|
||||
fi
|
@ -0,0 +1,86 @@
|
||||
#!/bin/sh
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 23:30:31 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
# Used on Alpine so needs to be /bin/sh
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
|
||||
# used in client code
|
||||
# shellcheck disable=SC2034
|
||||
package_args_description="Takes a list of packages as arguments or via stdin, and for any arguments that are plaintext files, reads the packages from those given files (one package per line)"
|
||||
|
||||
packages=""
|
||||
|
||||
_process_package_args(){
|
||||
for arg; do
|
||||
if [ -f "$arg" ] && file "$arg" | grep -q ASCII; then
|
||||
echo "adding packages from file: $arg" >&2
|
||||
packages="$packages $(sed 's/#.*//;/^[[:space:]]*$$/d' "$arg")"
|
||||
echo >&2
|
||||
else
|
||||
packages="$packages $arg"
|
||||
fi
|
||||
done
|
||||
# Homebrew tap package lists are in format "tap package" and those lines should not be split
|
||||
echo "$packages" |
|
||||
if [ -n "${TAP:-}" ]; then
|
||||
cat
|
||||
else
|
||||
tr ' ' '\n' |
|
||||
sort -u
|
||||
fi |
|
||||
grep -v '^[[:space:]]*$'
|
||||
}
|
||||
|
||||
process_package_args(){
|
||||
if [ -n "${*:-}" ]; then
|
||||
_process_package_args "$@"
|
||||
else
|
||||
# shellcheck disable=SC2046
|
||||
_process_package_args $(cat)
|
||||
fi
|
||||
}
|
||||
|
||||
installed_apk(){
|
||||
apk info 2>/dev/null
|
||||
}
|
||||
|
||||
installed_debs(){
|
||||
dpkg-query -W -f '${db:Status-Abbrev}\t${binary:Package}\n' |
|
||||
awk '/^i/{print $2}' |
|
||||
sed 's/:.*$//' |
|
||||
sort -u
|
||||
}
|
||||
|
||||
installed_rpms(){
|
||||
rpm -qa --queryformat '%{RPMTAG_NAME}\n'
|
||||
}
|
||||
|
||||
rpms_filter_provided(){
|
||||
while read -r rpm; do
|
||||
# accounts for vim being provided by vim-enhanced, so we don't try to install the metapackage again and again
|
||||
rpm -q --whatprovides "$rpm" >/dev/null 2>&1 &&
|
||||
echo "$rpm"
|
||||
done
|
||||
}
|
||||
|
||||
rpms_filter_not_provided(){
|
||||
while read -r rpm; do
|
||||
# accounts for vim being provided by vim-enhanced, so we don't try to install the metapackage again and again
|
||||
rpm -q --whatprovides "$rpm" >/dev/null 2>&1 ||
|
||||
echo "$rpm"
|
||||
done
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 23:53:52 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Checks a given list of RPM packages and returns those already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on CentOS
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
process_package_args "$@" |
|
||||
grep -Fx -f <(installed_rpms)
|
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 23:53:52 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Checks a given list of RPM packages and returns those not installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on CentOS
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
process_package_args "$@" |
|
||||
grep -vFx -f <(installed_rpms)
|
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
# args: vagrant/kubernetes/Vagrantfile
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 23:08:43 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Calculates the total combined RAM in MB allocated to all VMs in one or more Vagrantfiles
|
||||
|
||||
Accepts one or more Vagrantfiles as arguments, otherwise tries to read \$PWD/Vagrantfile or /vagrant/Vagrantfile for convenience
|
||||
|
||||
Tested on vagrant/kubernetes/Vagrantfile in this repo
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<Vagrantfile>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
Vagrantfiles=("$@")
|
||||
elif [ -f Vagrantfile ]; then
|
||||
Vagrantfiles=(Vagrantfile)
|
||||
elif [ -f /vagrant/Vagrantfile ]; then
|
||||
# auto-detect when running inside a Vagrant VM
|
||||
Vagrantfiles=(/vagrant/Vagrantfile)
|
||||
else
|
||||
usage "Vagrantfile not specified and no Vagrantfile found in \$PWD or /vagrant/"
|
||||
fi
|
||||
|
||||
grep -E '^[^#]+\.memory' "${Vagrantfiles[@]}" |
|
||||
sed 's/.*=[[:space:]]*//' |
|
||||
grep -E '^[[:digit:]]+(\.[[:digit:]]+)?$' |
|
||||
tr '\n' '+' |
|
||||
sed 's/+$//' |
|
||||
bc -l
|
@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2230
|
||||
# vim:ts=4:sts=4:sw=4:et
|
||||
#
|
||||
# Author: Hari Sekhon
|
||||
# Date: 2020-08-23 18:32:06 +0100 (Sun, 23 Aug 2020)
|
||||
#
|
||||
# https://github.com/harisekhon/bash-tools
|
||||
#
|
||||
# License: see accompanying Hari Sekhon LICENSE file
|
||||
#
|
||||
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||||
#
|
||||
# https://www.linkedin.com/in/harisekhon
|
||||
#
|
||||
|
||||
set -eu
|
||||
[ -n "${DEBUG:-}" ] && set -x
|
||||
srcdir="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/utils.sh"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
. "$srcdir/lib/packages.sh"
|
||||
|
||||
# shellcheck disable=SC2034,SC2154
|
||||
usage_description="
|
||||
Installs Yum RPM package lists if the packages aren't already installed
|
||||
|
||||
$package_args_description
|
||||
|
||||
Tested on CentOS
|
||||
"
|
||||
|
||||
# used by usage() in lib/utils.sh
|
||||
# shellcheck disable=SC2034
|
||||
usage_args="<packages>"
|
||||
|
||||
help_usage "$@"
|
||||
|
||||
process_package_args "$@" |
|
||||
"$srcdir/rpms_filter_not_installed.sh" |
|
||||
rpms_filter_not_provided |
|
||||
xargs --no-run-if-empty "$srcdir/yum_install_packages.sh"
|
Loading…
Reference in New Issue