#!/usr/bin/env bash
# 
# SCRIPT NAME:
# install
#
# AUTHOR:
# Severin Kaderli <severin@kaderli.dev>
#
# DESCRIPTION:
# This is the main installation script for my dotfiles. It setups the symlinks
# to the neeeded files, creates new directories, enables systemd services,
# installs pacman packages and gives out the correct permissions to files.
#
# USAGE:
# ./install
declare DOT_DIR
DOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit; pwd)"

declare INSTALL_DIR="${DOT_DIR}/.install"
declare SYSTEM_DIR="${DOT_DIR}/system"
INSTALL_LOG="${XDG_LOG_HOME}/install.log"

source "${INSTALL_DIR}/lib/lib.sh"


#. ./system/.config/custom/env
#. ./system/.local/bin/utils

###############################################################################
# Configuration variables                                                     #
###############################################################################
HOST="$(hostname)"

###############################################################################
# Installtion information                                                     #
###############################################################################
echo "${BOLD}Before you continue with this script make sure that:"
echo " • The user severin is added to the sudoers file"
echo " • The multilib repository is uncommented in /etc/pacman.conf"
echo -e " • Your SSH keys are located in ~/.ssh${RESET}\n"

if ! output::prompt "Are you ready to continue?"; then
    exit 1
fi

source "${INSTALL_DIR}/prerequisites.sh"

sudo printf ""

source "${INSTALL_DIR}/arch.sh"
source "${INSTALL_DIR}/rust.sh"
source "${INSTALL_DIR}/aur.sh"
source "${INSTALL_DIR}/npm.sh"
source "${INSTALL_DIR}/composer.sh"
source "${INSTALL_DIR}/ruby.sh"
source "${INSTALL_DIR}/directories.sh"
source "${INSTALL_DIR}/symlinks.sh"
source "${INSTALL_DIR}/permissions.sh"
source "${INSTALL_DIR}/groups.sh"
source "${INSTALL_DIR}/systemd.sh"
source "${INSTALL_DIR}/udev.sh"
source "${INSTALL_DIR}/etc.sh"
source "${INSTALL_DIR}/ntp.sh"
source "${INSTALL_DIR}/lockscreen.sh"
source "${INSTALL_DIR}/issue.sh"
source "${INSTALL_DIR}/fonts.sh"
source "${INSTALL_DIR}/shell.sh"

output::section "Post installation information"
echo "${BOLD}Make sure you do the following after this installation:"
echo " • Download settings for Visual Studio Code"
echo " • Start espanso"
echo " • Reboot the system"

