Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/update for annkissam #8

Merged
merged 2 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: 2
jobs:
build:
parallelism: 4
docker:
- image: circleci/elixir:1.8.1

working_directory: ~/app/adifier

steps:
- checkout

- restore_cache:
keys:
- adify-dependency-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
- adify-dependency-cache-{{ .Branch }}
- adify-dependency-cache
- restore_cache:
keys:
- adify-build-cache-{{ .Branch }}
- adify-build-cache

- run: mix local.hex --force
- run: mix local.rebar --force
- run: mix do deps.get, compile

- save_cache:
key: adify-dependency-cache-{{ .Branch }}-{{ checksum "mix.lock" }}
paths: "deps"
- save_cache:
key: adify-dependency-cache-{{ .Branch }}
paths: "deps"
- save_cache:
key: adify-dependency-cache
paths: "deps"
- save_cache:
key: adify-build-cache-{{ .Branch }}
paths: "_build"
- save_cache:
key: adify-build-cache
paths: "_build"

- run: ../adify.sh
39 changes: 0 additions & 39 deletions NOTES.md

This file was deleted.

18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# Adify
Set of scripts that install necessary tools and configurations for me to work on a computer.

Set of scripts that install necessary tools for Annkissam developers and
project managers on their computers.

This has been adapted from `aditya7iyengar/adify`

## USAGE

* From the terminal:

```
$ bash <(wget -qO- https://raw.githubusercontent.com/annkissam/adify/master/adify.sh)

OR

$ bash <(curl -s https://raw.githubusercontent.com/annkissam/adify/master/adify.sh)
```
4 changes: 4 additions & 0 deletions adifier/.formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
1 change: 1 addition & 0 deletions adifier/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
elixir 1.8.2
3 changes: 2 additions & 1 deletion adifier/lib/adifier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ defmodule Adifier do
@default_os "ubuntu"

def adify(opts) do
os = opts
os =
opts
|> Keyword.get(:os, @default_os)
|> String.to_atom()

Expand Down
11 changes: 6 additions & 5 deletions adifier/lib/adifier/invoker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ defmodule Adifier.Invoker do

@doc false
def call("sudo" <> cmd) do
System.cmd("sh", ["-c" , "sudo -A #{cmd}"],
env: [{"SUDO_ASKPASS", "./askpass.sh"}],
into: IO.stream(:stdio, :line))
System.cmd("sh", ["-c", "sudo -A #{cmd}"],
env: [{"SUDO_ASKPASS", "./askpass.sh"}],
into: IO.stream(:stdio, :line)
)
end

def call(cmd) do
System.cmd("sh", ["-c", cmd],
into: IO.stream(:stdio, :line))
System.cmd("sh", ["-c", cmd], into: IO.stream(:stdio, :line))
end
end
2 changes: 2 additions & 0 deletions adifier/lib/adifier/package_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ defmodule Adifier.PackageManager do
def install_cmd(:arch_linux, pkg), do: "sudo pacman -S #{pkg} --noconfirm"
def install_cmd(:mac, pkg), do: "brew install #{pkg}"
def install_cmd(:debian, pkg), do: "sudo apt -y install #{pkg}"

def install_cmd(os, pkg) when os in [:ubuntu, :pop_os] do
"sudo apt-get -y install #{pkg}"
end

def install_cmd(os, pkg) when os in [:centos, :fedora] do
"sudo yum -y install #{pkg}"
end
Expand Down
14 changes: 7 additions & 7 deletions adifier/lib/adifier/tool.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ defmodule Adifier.Tool do
defstruct ~w{errors}a ++ @enforce_keys

@type t :: %__MODULE__{
ran_at: Datetime.t(),
name: String.t(),
install_cmd: String.t(),
description: String.t()
}
ran_at: Datetime.t(),
name: String.t(),
install_cmd: String.t(),
description: String.t()
}

@callback install_cmd(Atom.t()) :: {:ok | :error, __MODULE__.t()}
@callback description() :: String.t()
Expand Down Expand Up @@ -61,7 +61,7 @@ defmodule Adifier.Tool do

@impl true
def __name__ do
case unquote(name)do
case unquote(name) do
:default -> unquote(__MODULE__).__get_name__(__MODULE__)
name -> name
end
Expand All @@ -75,7 +75,7 @@ defmodule Adifier.Tool do
"""
end

defoverridable [install_cmd: 1, description: 0]
defoverridable install_cmd: 1, description: 0
end
end

Expand Down
6 changes: 3 additions & 3 deletions adifier/lib/adifier/tool/docker.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Adifier.Tool.Docker do
@moduledoc """
Docker enables true independence between applications and infrastructure
and developers and IT ops to unlock their potential and creates a model
for better collaboration and innovation.
Docker enables true independence between applications and infrastructure
and developers and IT ops to unlock their potential and creates a model
for better collaboration and innovation.
"""

use Adifier.Tool, name: "docker"
Expand Down
2 changes: 1 addition & 1 deletion adifier/lib/adifier/tool/mysql.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Adifier.Tool.Mysql do
@moduledoc """
The most popular Open-source Relational Database Mangement System.
The most popular Open-source Relational Database Mangement System.
"""

use Adifier.Tool, name: "mysql"
Expand Down
2 changes: 1 addition & 1 deletion adifier/lib/adifier/tool/neovim.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Adifier.Tool.Neovim do
@moduledoc """
Neovim is a refactor, and sometimes redactor, in the tradition of Vim
Neovim is a refactor, and sometimes redactor, in the tradition of Vim
"""

use Adifier.Tool, name: "neovim"
Expand Down
12 changes: 6 additions & 6 deletions adifier/lib/adifier/tool/nodejs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ defmodule Adifier.Tool.Nodejs do
@impl true
def install_cmd(:ubuntu) do
"""
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf install nodejs 9.0.0
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf install nodejs 9.0.0
"""
end

@impl true
def install_cmd(_os) do
"""
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf install nodejs 9.0.0
asdf plugin-add nodejs https://github.com/asdf-vm/asdf-nodejs.git
bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf install nodejs 9.0.0
"""
end

Expand Down
16 changes: 8 additions & 8 deletions adifier/lib/adifier/tool/postgresql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ defmodule Adifier.Tool.Postgresql do
"""
sudo sh -c "
apt-get -y install linux-headers-$(uname -r) build-essential
apt-get -y install libreadline-dev
asdf plugin-add postgres https://github.com/smashedtoatoms/asdf-postgres.git
asdf install postgres 9.6.2
apt-get -y install libreadline-dev
asdf plugin-add postgres https://github.com/smashedtoatoms/asdf-postgres.git
asdf install postgres 9.6.2
"
"""
end
Expand All @@ -24,18 +24,18 @@ defmodule Adifier.Tool.Postgresql do
"""
sudo sh -c "
apt-get -y install linux-headers-$(uname -r) build-essential
apt-get -y install libreadline-dev
asdf plugin-add postgres https://github.com/smashedtoatoms/asdf-postgres.git
asdf install postgres 9.6.2
apt-get -y install libreadline-dev
asdf plugin-add postgres https://github.com/smashedtoatoms/asdf-postgres.git
asdf install postgres 9.6.2
"
"""
end

@impl true
def install_cmd(_os) do
"""
asdf plugin-add postgres https://github.com/smashedtoatoms/asdf-postgres.git
asdf install postgres 9.6.2
asdf plugin-add postgres https://github.com/smashedtoatoms/asdf-postgres.git
asdf install postgres 9.6.2
"""
end

Expand Down
8 changes: 4 additions & 4 deletions adifier/lib/adifier/tool/ruby.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ defmodule Adifier.Tool.Ruby do
@impl true
def install_cmd(:ubuntu) do
"""
asdf plugin-add ruby
asdf install ruby 2.5.0
asdf plugin-add ruby
asdf install ruby 2.5.0
"""
end

@impl true
def install_cmd(_os) do
"""
asdf plugin-add ruby
asdf install ruby 2.5.0
asdf plugin-add ruby
asdf install ruby 2.5.0
"""
end

Expand Down
14 changes: 7 additions & 7 deletions adifier/lib/adifier/tool/spideroak.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Adifier.Tool.Spideroak do
@moduledoc """
This is a half decent backup tool!
This is a half decent backup tool!
"""

use Adifier.Tool
Expand All @@ -10,9 +10,9 @@ defmodule Adifier.Tool.Spideroak do
"""
sudo sh -c "
deb http://apt.spideroak.com/ubuntu-spideroak-hardy/ release restricted
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 573E3D1C51AE1B3D
apt-get -y update
apt-get -y install spideroakone
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 573E3D1C51AE1B3D
apt-get -y update
apt-get -y install spideroakone
"
"""
end
Expand All @@ -22,9 +22,9 @@ defmodule Adifier.Tool.Spideroak do
"""
sudo sh -c "
deb http://apt.spideroak.com/ubuntu-spideroak-hardy/ release restricted
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 573E3D1C51AE1B3D
apt-get -y update
apt-get -y install spideroakone
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 573E3D1C51AE1B3D
apt-get -y update
apt-get -y install spideroakone
"
"""
end
Expand Down
4 changes: 2 additions & 2 deletions adifier/lib/applier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ defmodule Adifier.Applier do
@behaviour unquote(__MODULE__)

@impl true
def run(_, _), do: raise "run/2 isn't defined for #{__MODULE__}"
def run(_, _), do: raise("run/2 isn't defined for #{__MODULE__}")

defoverridable [run: 2]
defoverridable run: 2
end
end
end
2 changes: 1 addition & 1 deletion adifier/lib/appliers/configurations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ defmodule Adifier.Applier.Configurations do
@behaviour Adifier.Applier

def run(os, noconfirm) do
Logger.warn "No Configurations setup"
Logger.warn("No Configurations setup")
end
end
19 changes: 13 additions & 6 deletions adifier/lib/appliers/package_manager_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@ defmodule Adifier.Applier.PackageManagerUpdater do
@impl true
def run(os, noconfirm) do
case noconfirm || IO.gets(ask(os)) do
true -> update_pm(os)
"Y" <> _tali -> update_pm(os)
"y" <> _tali -> update_pm(os)
true ->
update_pm(os)

"Y" <> _tali ->
update_pm(os)

"y" <> _tali ->
update_pm(os)

_ ->
Logger.warn "Not updating Package Manager..."
Logger.warn("Not updating Package Manager...")
{:ok, :done}
end
end

def update_pm(os) do
Logger.info "Updating Package Manager"
Logger.info("Updating Package Manager")

result = os
result =
os
|> Adifier.PackageManager.pm_update_cmd()
|> Adifier.Invoker.call()

Expand Down
Loading