From c251b6c2e37aebb5738a890da904fc3b6abac9a0 Mon Sep 17 00:00:00 2001 From: jakobst1n Date: Sun, 17 Jan 2021 22:08:13 +0100 Subject: Share more code between setups --- install.sh | 64 +++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 21 deletions(-) (limited to 'install.sh') diff --git a/install.sh b/install.sh index 0e49d87..909b269 100755 --- a/install.sh +++ b/install.sh @@ -1,26 +1,48 @@ -#!/bin/sh +#!/bin/bash -echo "Install the dependencies and symlink the dotfiles" -tput setaf 4 -echo "Install on wich system? Enter either \"mac\", \"debian\", \"arch\", \"fedora\":" -tput setaf 3 -printf "> " -read platform -printf "\n" -tput sgr0 - -if [ $platform == "mac" ]; then - ./install/install_mac.sh +if [ "$EUID" -eq 0 ]; then + echo "Please don't run this as root, let sudo handle privilege escalation" + exit 1 fi - -if [ $platform == "arch" ]; then - ./install/install_arch.sh +if ! command -v sudo &> /dev/null; then + echo "Could not find sudo, please make sure it is installed and set up correctly." + exit fi -if [ $platform == "debian" ]; then - ./install/install_debian.sh -fi +case "$OSTYPE" in + darwin*) + export INSTALLER_PM="brew" + echo "Detected your OS as \"mac\"." + ./install/install_mac.sh + ;; + linux*) + echo "I detected that you are running linux, please enter your distro." + tput setaf 4 + echo "Please enter: \"arch\", \"fedora\" or \"debian\"" + tput setaf 3 + printf "> " + read distro + printf "\n" + tput sgr0 -if [ $platform == "fedora" ]; then - ./install/install_fedora.sh -fi + if [ $distro == "arch" ]; then + export INST_PM="sudo packman -S" + elif [ $distro == "debian" ]; then + export INST_PM="sudo apt-get -y install" + elif [ $distro == "fedora" ]; then + export INST_PM="sudo dnf -qy install" + else + echo "Unknown distro." + echo "If you know what os you have, you can run the install script manually." + echo "first run `export INST_PM=\"\"` to indicate the package manager to the install script." + exit 1 + fi + + ./install/install_linux.sh + ;; + *) + echo "Unkown OS..." + echo "If you know what os you have, you can run the install script manually." + echo "first run `export INST_PM=\"\"` to indicate the package manager to the install script." + ;; +esac -- cgit v1.2.3