mirror of
https://github.com/aminnairi/dotfiles.git
synced 2026-09-14 11:02:13 +02:00
added non-magic error variables
This commit is contained in:
@@ -1,22 +1,20 @@
|
|||||||
#!/bin/env bash
|
#!/bin/env bash
|
||||||
|
|
||||||
|
ERROR_BECAUSE_NON_ROOT=1
|
||||||
|
ERROR_BECAUSE_NOT_ARCH_LINUX=2
|
||||||
|
ERROR_BECAUSE_ANSIBLE_INSTALLATION_FAILED=3
|
||||||
|
ERROR_BECAUSE_PLAYBOOK_INVALID_OR_NOT_FOUND=4
|
||||||
|
|
||||||
if [[ "$(id -u)" -ne 0 ]]
|
if [[ "$(id -u)" -ne 0 ]]
|
||||||
then
|
then
|
||||||
echo "Please, run this script as root"
|
echo "Please, run this script as root"
|
||||||
exit 1
|
exit $ERROR_BECAUSE_NON_ROOT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -x $(command -v pacman) ]]
|
if [[ ! -x $(command -v pacman) ]]
|
||||||
then
|
then
|
||||||
echo "Please, use this script with an Arch Linux operating system."
|
echo "Please, use this script with an Arch Linux operating system."
|
||||||
exit 2
|
exit $ERROR_BECAUSE_NOT_ARCH_LINUX
|
||||||
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
|
fi
|
||||||
|
|
||||||
if [[ ! -x "$(command -v ansible)" ]]
|
if [[ ! -x "$(command -v ansible)" ]]
|
||||||
@@ -26,7 +24,7 @@ then
|
|||||||
then
|
then
|
||||||
|
|
||||||
echo "Installion failed."
|
echo "Installion failed."
|
||||||
exit 4
|
exit $ERROR_BECAUSE_ANSIBLE_INSTALLATION_FAILED
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -48,7 +46,7 @@ choosen_playbook_path=${available_playbook_paths[$index - 1]}
|
|||||||
if [[ -z $choosen_playbook_path ]]
|
if [[ -z $choosen_playbook_path ]]
|
||||||
then
|
then
|
||||||
echo "Error: invalid index."
|
echo "Error: invalid index."
|
||||||
exit 5
|
exit $ERROR_BECAUSE_PLAYBOOK_INVALID_OR_NOT_FOUND
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Installing needed Ansible packages..."
|
echo "Installing needed Ansible packages..."
|
||||||
|
|||||||
Reference in New Issue
Block a user