Modify kazu634 cookbook for LXC containers.

This commit is contained in:
Kazuhiro MUSASHI 2025-01-19 22:15:24 +09:00
parent 6b53c30a77
commit c1cc2589c4
3 changed files with 90 additions and 70 deletions

View File

@ -0,0 +1,12 @@
# If it is a VM, use `zsh`. Otherwise, `bash`:
unless node['base']['lxc']
SHELL = '/usr/bin/zsh'
else
SHELL = '/usr/bin/bash'
end
node.reverse_merge!({
'kazu634' => {
'shell' => SHELL
}
})

View File

@ -1,9 +1,14 @@
include_recipe './attributes.rb'
include_recipe './kazu634.rb' include_recipe './kazu634.rb'
include_recipe './ssh.rb' include_recipe './ssh.rb'
include_recipe './vim.rb' # if it is inside a VM, do the followings:
unless node['base']['lxc']
include_recipe './vim.rb'
include_recipe './mc.rb' include_recipe './mc.rb'
include_recipe './mise.rb' include_recipe './mise.rb'
end

View File

@ -7,63 +7,7 @@ user 'kazu634' do
create_home true create_home true
home HOME home HOME
shell '/usr/bin/zsh' shell node['kazu634']['shell']
end
# Create directories:
%w( repo src tmp works .cache ).each do |d|
directory "#{HOME}/#{d}" do
owner 'kazu634'
group 'kazu634'
mode '755'
end
end
# `git-now` deployment:
git '/home/kazu634/repo/git-now' do
repository 'https://github.com/iwata/git-now.git'
user 'kazu634'
recursive true
end
execute 'make install' do
user 'root'
cwd '/home/kazu634/repo/git-now/'
not_if 'which git-now'
end
# Deploy dot files:
git '/home/kazu634/repo/dotfiles' do
repository 'https://gitea.kazu634.com/kazu634/dotfiles.git'
user 'kazu634'
end
execute 'install_dotfiles' do
user 'root'
command 'su - kazu634 -c "/home/kazu634/repo/dotfiles/install.sh"'
not_if 'test -f /home/kazu634/.zshenv'
end
# Deploy `zplug`:
git '/home/kazu634/.zplug' do
repository 'https://github.com/zplug/zplug.git'
user 'kazu634'
end
# Starship config
directory '/home/kazu634/.config' do
owner 'kazu634'
group 'kazu634'
mode '0740'
end
remote_file '/home/kazu634/.config/starship.toml' do
owner 'kazu634'
group 'kazu634'
mode '0640'
end end
# sudoers # sudoers
@ -73,18 +17,77 @@ remote_file '/etc/sudoers.d/kazu634' do
mode '440' mode '440'
end end
# automatically delete the /home/kazu634/tmp directory: # if it is inside a VM, do the followings:
remote_file '/etc/cron.d/remove_tmp' do unless node['base']['lxc']
# Create directories:
%w( repo src tmp works .cache ).each do |d|
directory "#{HOME}/#{d}" do
owner 'kazu634'
group 'kazu634'
mode '755'
end
end
# `git-now` deployment:
git '/home/kazu634/repo/git-now' do
repository 'https://github.com/iwata/git-now.git'
user 'kazu634'
recursive true
end
execute 'make install' do
user 'root'
cwd '/home/kazu634/repo/git-now/'
not_if 'which git-now'
end
# Deploy dot files:
git '/home/kazu634/repo/dotfiles' do
repository 'https://gitea.kazu634.com/kazu634/dotfiles.git'
user 'kazu634'
end
execute 'install_dotfiles' do
user 'root'
command 'su - kazu634 -c "/home/kazu634/repo/dotfiles/install.sh"'
not_if 'test -f /home/kazu634/.zshenv'
end
# Deploy `zplug`:
git '/home/kazu634/.zplug' do
repository 'https://github.com/zplug/zplug.git'
user 'kazu634'
end
# Starship config
directory '/home/kazu634/.config' do
owner 'kazu634'
group 'kazu634'
mode '0740'
end
remote_file '/home/kazu634/.config/starship.toml' do
owner 'kazu634'
group 'kazu634'
mode '0640'
end
# automatically delete the /home/kazu634/tmp directory:
remote_file '/etc/cron.d/remove_tmp' do
owner 'root' owner 'root'
group 'root' group 'root'
mode '644' mode '644'
end end
# Deploy `~/works/rsync.sh`: # Deploy `~/works/rsync.sh`:
%w( rsync.sh lsyncd.conf.lua ).each do |file| %w( rsync.sh lsyncd.conf.lua ).each do |file|
remote_file "/home/kazu634/works/#{file}" do remote_file "/home/kazu634/works/#{file}" do
owner 'kazu634' owner 'kazu634'
group 'kazu634' group 'kazu634'
mode '755' mode '755'
end end
end
end end