Files
dotfiles/install.sh

50 lines
1013 B
Bash
Raw Normal View History

2020-02-24 10:42:23 +01:00
#!/usr/bin/env bash
2020-02-23 14:25:06 +01:00
#
# Wraps "make" and ensures basic packages are installed:
#
# - make itself
# - python3-virtualenv (needed for ansible)
set -o errexit
set -o nounset
DOTDIR="/var/lib/dotfiles"
os_release_file=/etc/os-release
if [[ ! -e "${os_release_file}" ]] ; then
2024-05-02 17:10:45 +02:00
2>&1 printf 'Could not find %, exiting' "${os_release_file}"
exit 1
fi
2024-05-02 17:10:45 +02:00
# shellcheck source=/etc/os-release
2024-04-22 14:02:56 +02:00
source "${os_release_file}"
2020-02-23 14:25:06 +01:00
sudowrap() {
2024-04-22 14:02:56 +02:00
if (( $(id -u) != 0 )) ; then
sudo "${@}"
else
"${@}"
fi
}
cache_updated=0
2024-04-22 14:02:56 +02:00
install() {
local package="$1" ; shift
2024-04-10 15:57:38 +02:00
if [[ $NAME == "Arch Linux" ]] ; then
2024-04-22 14:16:32 +02:00
if (( ! cache_updated )) ; then
sudowrap pacman -Sy
cache_updated=1
fi
2024-04-22 14:02:56 +02:00
sudowrap pacman -S --needed --noconfirm "${package}"
2020-02-23 14:25:06 +01:00
else
2024-05-02 17:10:45 +02:00
2>&1 printf 'Unsupported distro %s, exiting' "$NAME"
2020-02-23 14:25:06 +01:00
exit 1
fi
}
2024-04-22 14:24:56 +02:00
command -v make >/dev/null || install "make"
command -v ansible >/dev/null || install "ansible"
2022-06-30 06:38:05 +02:00
2024-04-22 14:02:56 +02:00
cd "${DOTDIR}" && make