aboutsummaryrefslogtreecommitdiff
path: root/install.sh
blob: a455c8d2abb8bb8e788c8ccd02c2b060c234f798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bash

# Author : Ibrahim Mkusa
# Description: installs and sets up core environment for my dev work on servers

set -e  # subshells inherit environment from parent

function usage() {
   echo "./install #installs and setups this environment"
   echo "./install undo  #removes all configs"
   echo "./install wipe #removes all configs and removes all installed packages"
}

# detect which family of distro i'm on
if [[ -f /etc/os-release ]]; then
  . /etc/os-release

  case "$ID_LIKE" in
    debian)
      echo "Running on debian-family.."
      package_manager=apt
      vim="vim-nox"
      ;;
    fedora)
      echo "Running on debian-family.."
      package_manager=fedora
      vim="vim-enhanced"
  esac
else
  echo "You are running an unrecognized family of os. Quitting..."
  exit 1
fi

# could have used a case, but i prefer the if statement
if [[ -z "$1" ]]; then
  echo "Installing packages"
  sudo "$package_manager" install -y "$vim" git stow curl ranger tmux

  # use gnu stow to symlink config files to home directory
  stow bash git ranger shellenv tmux vim

elif [[ undo = "$1" ]]; then
  echo "undoing"
  stow -D bash git ranger shellenv tmux vim

elif [[ wipe = "$1" ]]; then
  stow -D bash git ranger shellenv tmux vim
  sudo "$package_manager" remove "$vim" git stow curl ranger tmux
  echo "wiping"

elif [[ "$1" = "help" ]]; then
  usage

fi