Last active
January 4, 2020 13:49
-
-
Save cumet04/4d1f81ed05b7fd6b6dff8aa3f5bba0c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### system side setup ---------- | |
execute "enable docker-ce repo" do | |
repo = "https://download.docker.com/linux/fedora/docker-ce.repo" | |
command "dnf config-manager --add-repo=#{repo}" | |
not_if "test -e /etc/yum.repos.d/docker-ce.repo" | |
end | |
%w( | |
awscli | |
colordiff | |
direnv | |
docker-ce | |
docker-compose | |
fish | |
git | |
golang | |
ImageMagick | |
jq | |
neovim | |
nodejs | |
python3 | |
python3-pip | |
ruby | |
sqlite | |
tig | |
tmux | |
tree | |
).each { |p| package p } | |
# aws session manager plugin | |
execute "install session-manager-plugin" do | |
command "dnf install -y https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_64bit/session-manager-plugin.rpm" | |
not_if "dnf list installed | grep session-manager-plugin" | |
end | |
# diff-highlight | |
link "/usr/local/bin/diff-highlight" do | |
to "/usr/share/git-core/contrib/diff-highlight" | |
end | |
# go commands | |
begin | |
# MEMO: I know I should download binaries from github releases, but it's troublesome ... | |
tmp_gopath = run_command("mktemp -d").stdout.chomp | |
gobin = "/usr/local/bin" | |
[ | |
["ghq", "github.com/motemen/ghq"], | |
["pt", "github.com/monochromegane/the_platinum_searcher/..."], | |
["peco", "github.com/peco/peco/cmd/peco"], | |
["lemonade", "github.com/lemonade-command/lemonade"], | |
].each do |obj| | |
bin = obj[0] | |
url = obj[1] | |
execute "install #{bin} with go get" do | |
command "env GOPATH=#{tmp_gopath} GOBIN=#{gobin} go get #{url}" | |
not_if "which #{bin}" | |
end | |
end | |
end | |
### user-side setup ---------- | |
Username = "medalhkr" | |
user "create user" do | |
username Username | |
gid "wheel" | |
shell "/usr/bin/fish" | |
end | |
local_ruby_block "create user notify" do | |
block do | |
MItamae::Logger.info "#{Username} user created. execute 'sudo passwd #{Username}'" | |
end | |
action :nothing | |
subscribes :run, "user[create user]" | |
end | |
# setup dotfiles | |
begin | |
ghq_root = "/home/#{Username}/repos" | |
dotfiles_path = "#{ghq_root}/github.com/cumet04/dotfiles" | |
git dotfiles_path do | |
user Username | |
repository "git@github.com:cumet04/dotfiles.git" | |
end | |
execute "git update-index --skip-worktree home/.gitconfig" do | |
cwd dotfiles_path | |
action :nothing | |
subscribes :run, "git[#{dotfiles_path}]", :immediately | |
end | |
%w(.config .gitconfig).each do |target| | |
link "/home/#{Username}/#{target}" do | |
user Username | |
to "#{dotfiles_path}/home/#{target}" | |
not_if "test -e /home/#{Username}/#{target}" | |
end | |
end | |
link "/usr/local/bin/shell_commands" do | |
to "#{dotfiles_path}/shell_commands" | |
not_if "test -e /usr/local/bin/shell_commands" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment