.
This commit is contained in:
@ -6,46 +6,6 @@
|
||||
# It is called with the path to the server specific env file as an argument.
|
||||
|
||||
|
||||
attempt_install_prerequisite() {
|
||||
local prerequisite="${1}"
|
||||
echo "Attempting to install prerequisite: ${prerequisite}"
|
||||
|
||||
# test if root, and test sudo otherwise.
|
||||
SUDO_CMD=""
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
if ! sudo -v; then
|
||||
echo "--------------------------------"
|
||||
echo "Prerequisite: ${prerequisite} is not installed."
|
||||
echo "Please run the script with sudo privileges or as root to automatically install the prerequisite."
|
||||
echo "--------------------------------"
|
||||
exit 1
|
||||
fi
|
||||
SUDO_CMD="sudo "
|
||||
fi
|
||||
|
||||
|
||||
# separate install for each prerequisite
|
||||
case "${prerequisite}" in
|
||||
bash|curl|wget)
|
||||
$SUDO_CMD apt-get update
|
||||
$SUDO_CMD apt-get install -y wget curl bash
|
||||
;;
|
||||
"docker")
|
||||
# install docker using the official script.
|
||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
||||
$SUDO_CMD sh get-docker.sh
|
||||
rm get-docker.sh
|
||||
;;
|
||||
*)
|
||||
echo "--------------------------------"
|
||||
echo "Prerequisite: ${prerequisite} is not installed."
|
||||
echo "Please install it manually and try again."
|
||||
echo "--------------------------------"
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
install_prerequisites() {
|
||||
# this script works on debian, ubuntu and Raspberry Pi OS
|
||||
# it checks the following prerequisites, and installs them if missing.
|
||||
@ -63,7 +23,7 @@ install_prerequisites() {
|
||||
# check if all prerequisites are installed
|
||||
for prerequisite in "${PREREQUISITES[@]}"; do
|
||||
if ! command -v "${prerequisite}" &> /dev/null; then
|
||||
attempt_install_prerequisite "${prerequisite}"
|
||||
echo "Prerequisite: ${prerequisite} is not installed."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
Reference in New Issue
Block a user