95 lines
2.6 KiB
Bash
95 lines
2.6 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
if [[ "$EUID" -ne 0 ]]; then
|
|
echo -e "\e[31m[FATAL]\e[39m Currently this script requires being ran as root user - please try again as root."
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "\n\nINSTALL LOG: $(date --rfc-3339=seconds)\n" >> /tmp/multiplane-install.log
|
|
|
|
info() {
|
|
echo -e "\e[34m[INFO]\e[39m $1"
|
|
echo "[INFO] $1" >> /tmp/multiplane-install.log
|
|
}
|
|
|
|
debug() {
|
|
if [[ ! -z "$DEBUG" ]]; then
|
|
echo -e "\e[96m[DEBUG]\e[39m $1"
|
|
fi
|
|
echo "[DEBUG] $1" >> /tmp/multiplane-install.log
|
|
}
|
|
|
|
warn() {
|
|
echo -e "\e[33m[WARNING]\e[39m $1"
|
|
echo "[WARNING] $1" >> /tmp/multiplane-install.log
|
|
}
|
|
|
|
fatal() {
|
|
echo -e "\e[31m[FATAL]\e[39m $1"
|
|
echo "[FATAL] $1" >> /tmp/multiplane-install.log
|
|
exit 1
|
|
}
|
|
|
|
install_dependencies () {
|
|
|
|
info "Checking dependencies..."
|
|
|
|
# Install curl if not present (required for downloading Nix tarball)
|
|
if ! command -v curl &> /dev/null; then
|
|
info "Installing curl..."
|
|
if command -v apt-get &> /dev/null; then
|
|
sudo apt-get update && sudo apt-get install -y curl
|
|
elif command -v dnf &> /dev/null; then
|
|
sudo dnf install -y curl
|
|
elif command -v yum &> /dev/null; then
|
|
sudo yum install -y curl
|
|
elif command -v pacman &> /dev/null; then
|
|
sudo pacman -S --noconfirm curl
|
|
else
|
|
fatal "Please install curl manually for your distribution"
|
|
fi
|
|
fi
|
|
|
|
# Install yq (required for config and templates)
|
|
info "Installing yq..."
|
|
if ! curl -sSL -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64; then
|
|
echo "Error: Failed to download yq." >&2
|
|
exit 1
|
|
else
|
|
chmod +x /usr/local/bin/yq
|
|
fi
|
|
|
|
# Install gum (required for config and templates)
|
|
info "Installing gum..."
|
|
if ! curl -sSL -o /tmp/gum_0.17.0_Linux_x86_64.tar.gz https://github.com/charmbracelet/gum/releases/download/v0.17.0/gum_0.17.0_Linux_x86_64.tar.gz; then
|
|
echo "Error: Failed to download gum." >&2
|
|
exit 1
|
|
else
|
|
tar -xzf /tmp/gum_0.17.0_Linux_x86_64.tar.gz -C /usr/local/bin --strip-components=1 gum_0.17.0_Linux_x86_64/gum
|
|
rm -rf /tmp/gum_0.17.0_Linux_x86_64.tar.gz
|
|
chmod +x /usr/local/bin/gum
|
|
fi
|
|
|
|
# Install k0sctl (required for kubernetes cluster)
|
|
info "Installing k0sctl..."
|
|
if ! curl -sSL -o /usr/local/bin/k0sctl https://github.com/k0sproject/k0sctl/releases/latest/download/k0sctl-linux-amd64; then
|
|
echo "Error: Failed to download k0sctl." >&2
|
|
exit 1
|
|
else
|
|
chmod +x /usr/local/bin/k0sctl
|
|
fi
|
|
|
|
}
|
|
|
|
main() {
|
|
info "Script loaded, starting the install process..."
|
|
|
|
install_dependencies()
|
|
|
|
info "Install script finished. You can now run .\multiplane.sh"
|
|
}
|
|
|
|
main
|