Skip to content

Commit

Permalink
The Beginning of the End.
Browse files Browse the repository at this point in the history
  • Loading branch information
TechDufus committed Sep 22, 2023
1 parent f7e7c64 commit af4fc9f
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 33 deletions.
101 changes: 73 additions & 28 deletions bin/dotfiles
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,82 @@ DOTFILES_DIR="$HOME/.dotfiles"
SSH_DIR="$HOME/.ssh"
IS_FIRST_RUN="$HOME/.dotfiles_run"

# Install Ansible
# check lsb_release -si
if ! dpkg -s ansible >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Ansible...${NC}"
echo -e " ${RIGHT_ANGLE} ${CYAN}Updating APT Repos${NC}"
sudo apt-get update 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Installing dependency: ${YELLOW}software-properties-common${NC}"
sudo apt-get install -y software-properties-common 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Adding Ansible PPA Repo${NC}"
sudo apt-add-repository -y ppa:ansible/ansible 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Updating APT Repos${NC}"
sudo apt-get update 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Installing Ansible${NC}"
sudo apt-get install -y ansible 2>&1 > /dev/null
echo -e "${ARROW} ${GREEN}Ansible installed!${NC}"
echo -e "${ARROW} ${CYAN}Installing ansible argument completion...${NC}"
sudo apt-get install python3-argcomplete 2>&1 > /dev/null
sudo activate-global-python-argcomplete3 2>&1 > /dev/null
# Get the operating system name
os_name=$(uname -s)
BOOTSTRAP_OS=""

# Check if the operating system is Ubuntu
if [[ $os_name == "Linux" && -f /etc/lsb-release ]]; then
source /etc/lsb-release
if [[ $DISTRIB_ID == "Ubuntu" ]]; then
BOOTSTRAP_OS="ubuntu"
fi
# Check if the operating system is macOS
elif [[ $os_name == "Darwin" ]]; then
BOOTSTRAP_OS="macos"
fi

# Check if python3 and pip is installed
if ! dpkg -s python3 >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Python3...${NC}"
sudo apt-get install -y python3 2>&1 > /dev/null
echo -e "${ARROW} ${GREEN}Python3 installed!${NC}"
fi
if ! dpkg -s python3-pip >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Python3 Pip...${NC}"
sudo apt-get install -y python3-pip 2>&1 > /dev/null
echo -e "${ARROW} ${GREEN}Python3 Pip installed!${NC}"
if [[ $BOOTSTRAP_OS == "" ]]; then
echo -e "${X_MARK} ${RED}Unsupported operating system!${NC}"
exit 1
elif [[ $BOOTSTRAP_OS == "ubuntu" ]]; then
echo -e "${CHECK_MARK} ${GREEN}Operating system is Ubuntu!${NC}"
# Install Ansible
# check lsb_release -si
if ! dpkg -s ansible >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Ansible...${NC}"
echo -e " ${RIGHT_ANGLE} ${CYAN}Updating APT Repos${NC}"
sudo apt-get update 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Installing dependency: ${YELLOW}software-properties-common${NC}"
sudo apt-get install -y software-properties-common 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Adding Ansible PPA Repo${NC}"
sudo apt-add-repository -y ppa:ansible/ansible 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Updating APT Repos${NC}"
sudo apt-get update 2>&1 > /dev/null
echo -e " ${RIGHT_ANGLE} ${CYAN}Installing Ansible${NC}"
sudo apt-get install -y ansible 2>&1 > /dev/null
echo -e "${ARROW} ${GREEN}Ansible installed!${NC}"
echo -e "${ARROW} ${CYAN}Installing ansible argument completion...${NC}"
sudo apt-get install python3-argcomplete 2>&1 > /dev/null
sudo activate-global-python-argcomplete3 2>&1 > /dev/null
fi

# Check if python3 and pip is installed
if ! dpkg -s python3 >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Python3...${NC}"
sudo apt-get install -y python3 2>&1 > /dev/null
echo -e "${ARROW} ${GREEN}Python3 installed!${NC}"
fi
if ! dpkg -s python3-pip >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Python3 Pip...${NC}"
sudo apt-get install -y python3-pip 2>&1 > /dev/null
echo -e "${ARROW} ${GREEN}Python3 Pip installed!${NC}"
fi
elif [[ $BOOTSTRAP_OS == "macos" ]]; then
echo -e "${CHECK_MARK} ${GREEN}Operating system is macOS!${NC}"
# Install Ansible
if ! brew list ansible &>/dev/null; then
echo -e "${ARROW} ${CYAN}Installing Ansible...${NC}"
echo -e " ${RIGHT_ANGLE} ${CYAN}Installing Ansible${NC}"
brew install ansible
echo -e "${ARROW} ${GREEN}Ansible installed!${NC}"
fi

# Check if python3 and pip is installed
if ! brew list python &>/dev/null; then
echo -e "${ARROW} ${CYAN}Installing Python3...${NC}"
brew install python
echo -e "${ARROW} ${GREEN}Python3 installed!${NC}"
fi
# Check if pip module watchdog is installed
if ! pip3 list | grep watchdog >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Python3 Watchdog...${NC}"
pip3 install watchdog 2>&1 > /dev/null
echo -e "${ARROW} ${GREEN}Python3 Watchdog installed!${NC}"
fi
fi


# Check if pip module watchdog is installed
if ! pip3 list | grep watchdog >/dev/null 2>&1; then
echo -e "${ARROW} ${CYAN}Installing Python3 Watchdog...${NC}"
Expand Down
43 changes: 43 additions & 0 deletions roles/neovim/tasks/darwin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- name: "Neovim | Dependencies"
community.general.homebrew:
name:
- cmake
- curl
- pkg-config
- libtool
- unzip
- ansible-lint
- ripgrep
state: present
become: true

- name: "Neovim | Install"
community.general.homebrew:
name: neovim
state: present
become: true

- name: "Neovim | Config folder"
ansible.builtin.file:
mode: "0755"
path: "{{ ansible_user_dir }}/.config/nvim"
state: directory

- name: "Neovim | Copy init.lua"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/init.lua"
src: "init.lua"
mode: "0644"

- name: "Neovim | Copy .luarc.json"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/.luarc.json"
src: ".luarc.json"
mode: "0644"

- name: "Neovim | Copy modules"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/lua"
src: "lua/"
mode: "0644"
7 changes: 6 additions & 1 deletion roles/neovim/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
- import_tasks: ubuntu.yml
- name: Run Ubuntu Tasks
ansible.builtin.import_tasks: ubuntu.yml
when: ansible_os_family == 'Debian'

- name: Run Darwin Tasks
ansible.builtin.import_tasks: darwin.yml
when: ansible_os_family == 'Darwin'
7 changes: 3 additions & 4 deletions roles/neovim/tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/init.lua"
src: "init.lua"
mode: 0644
mode: "0644"

- name: "Neovim | Copy .luarc.json"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/.luarc.json"
src: ".luarc.json"
mode: 0644
mode: "0644"

- name: "Neovim | Copy modules"
ansible.builtin.copy:
dest: "{{ ansible_user_dir }}/.config/nvim/lua"
src: "lua/"
mode: 0644

mode: "0644"

0 comments on commit af4fc9f

Please sign in to comment.