mirror of
https://github.com/aminnairi/dotfiles.git
synced 2026-09-14 12:12:13 +02:00
new script to run and check that the prerequisites for installing the
environment are met
This commit is contained in:
@@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/env bash
|
||||||
|
|
||||||
|
if [[ "$(id -u)" -eq 0 ]]
|
||||||
|
then
|
||||||
|
echo "Please, use an unprivileged user with sudo permissions instead of the root user to run this script properly."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x $(command -v pacman) ]]
|
||||||
|
then
|
||||||
|
echo "Please, use this script with an Arch Linux operating system."
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$(command -v sudo)" ]]
|
||||||
|
then
|
||||||
|
echo "Sudo not found. Please install it using the following command:"
|
||||||
|
echo "pacman -Syy sudo"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -x "$(command -v ansible)" ]]
|
||||||
|
then
|
||||||
|
echo "Ansible not found, installing..."
|
||||||
|
if [[ ! "$(sudo pacman -Syy --noconfirm ansible)" ]]
|
||||||
|
then
|
||||||
|
|
||||||
|
echo "Installion failed."
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Choose a configuration";
|
||||||
|
|
||||||
|
available_playbook_paths=$(ls ansible/*.yml)
|
||||||
|
|
||||||
|
for index in $(seq 1 ${#available_playbook_paths[@]})
|
||||||
|
do
|
||||||
|
available_playbook_path="$(basename "${available_playbook_paths[$index - 1]}")"
|
||||||
|
|
||||||
|
echo "$index - $available_playbook_path"
|
||||||
|
done
|
||||||
|
|
||||||
|
read -r -p "Choice: " index
|
||||||
|
|
||||||
|
choosen_playbook_path=${available_playbook_paths[$index - 1]}
|
||||||
|
|
||||||
|
if [[ -z $choosen_playbook_path ]]
|
||||||
|
then
|
||||||
|
echo "Error: invalid index."
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing needed Ansible packages..."
|
||||||
|
|
||||||
|
ansible-galaxy collection install --collections-path ansible/collections kewlfft.aur
|
||||||
|
|
||||||
|
echo "Done installing needed Ansible packages."
|
||||||
|
echo "Running choosen Ansible Playbook at $choosen_playbook_path..."
|
||||||
|
|
||||||
|
ansible-playbook --ask-become-pass --inventory ./ansible/hosts --module-path ansible/collections "$choosen_playbook_path"
|
||||||
|
|
||||||
|
echo "Done running choosen Ansible Playbook. If this is your first installation, you might want to reboot in order for the settings to take effect."
|
||||||
Reference in New Issue
Block a user