aboutsummaryrefslogtreecommitdiff
path: root/provision
blob: e99d6333d0e22149a243e6c6ab3af6f41df2eeae (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
#!/usr/bin/env bash

if [[ -z "$1" ]]; then
  echo "Run with parameters: essential, nice, gui, flatpak, cask_essential, or cask_nice"
else
  if command -v brew &>  /dev/null; then
    command_name="brew"
    install_command="install"
    privilege=""
  else
    if command -v dnf &>  /dev/null; then
      if [[ "$1" == "flatpak" ]]; then
        command_name="flatpak"
      else
        command_name="dnf"
      fi
      install_command="install"
      privilege="sudo"
    else
      if command -v pacman &>  /dev/null; then
        command_name="pacman"
        install_command="-Sy"
        privilege="sudo"
      else
        if command -v apt &>  /dev/null; then
          command_name="apt"
          install_command="install"
          privilege="sudo"
        else
          echo "Error: No valid package manager. Make sure brew or apt are available."
          exit 1
        fi
      fi
    fi
  fi
  file="./provisioning/${command_name}_$1"
  if [[ -f $file ]]; then
    echo "Provisioning $1 with $command_name"
    cat ./provisioning/${command_name}_$1 | xargs ${privilege} ${command_name} ${install_command}
  else
    echo "No provisioning recipe for $1 with $command_name"
    exit 1
  fi
fi