Files
Multiplane/install.sh
2026-01-14 21:22:32 +00:00

85 lines
2.2 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 xz-utils if not present (required for decompressing Nix tarball)
if ! command -v xz &> /dev/null; then
echo "Installing xz-utils..."
if command -v apt-get &> /dev/null; then
sudo apt-get update && sudo apt-get install -y xz-utils
elif command -v dnf &> /dev/null; then
sudo dnf install -y xz
elif command -v yum &> /dev/null; then
sudo yum install -y xz
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm xz
else
fatal "Please install xz-utils manually for your distribution"
fi
fi
# Download and run the Nix installer (multi-user mode with daemon)
curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --daemon
}
main() {
info "Script loaded, starting the install process..."
install_dependencies()
info "Install script finished. You can now run .\multiplane.sh"
}
main