From ba41bd9fe185e2dbf24e0bb97a6ddc67d79298aa Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 28 Jan 2023 20:27:22 +0900 Subject: [PATCH] Do not install `gitea`. --- cookbooks/gitea/default.rb | 2 - cookbooks/gitea/install.rb | 55 --------------- cookbooks/gitea/setup.rb | 135 ------------------------------------- 3 files changed, 192 deletions(-) delete mode 100644 cookbooks/gitea/install.rb delete mode 100644 cookbooks/gitea/setup.rb diff --git a/cookbooks/gitea/default.rb b/cookbooks/gitea/default.rb index c7465cf..273cc08 100644 --- a/cookbooks/gitea/default.rb +++ b/cookbooks/gitea/default.rb @@ -2,9 +2,7 @@ include_recipe './attributes.rb' # Install: -include_recipe './install.rb' include_recipe './install-go-mmproxy.rb' # Setup: -include_recipe './setup.rb' include_recipe './setup-go-mmproxy.rb' diff --git a/cookbooks/gitea/install.rb b/cookbooks/gitea/install.rb deleted file mode 100644 index 0d54f07..0000000 --- a/cookbooks/gitea/install.rb +++ /dev/null @@ -1,55 +0,0 @@ -gitea_url = '' -gitea_bin = '' - -vtag = '' -tag = '' - -# Calculate the Download URL: -begin - require 'net/http' - - uri = URI.parse('https://github.com/go-gitea/gitea/releases/latest') - - Timeout.timeout(3) do - response = Net::HTTP.get_response(uri) - - vtag = $1 if response['location'] =~ %r{tag\/(v\d+\.\d+\.\d+)} - tag = vtag.sub(/^v/, '') - - gitea_bin = "#{node['gitea']['prefix']}#{tag}#{node['gitea']['postfix']}" - gitea_url = "#{node['gitea']['url']}/#{vtag}/#{gitea_bin}" - end -rescue - # Abort the chef client process: - raise 'Cannot connect to http://github.com.' -end - -# バージョン確認して、アップデート必要かどうか確認 -result = run_command("gitea --version 2>&1 | grep #{tag}", error: false) -if result.exit_status != 0 - # Download: - TMP = "/tmp/#{gitea_bin}" - - execute "wget #{gitea_url} -O #{TMP}" - - # Install: - directory node['gitea']['storage'] do - owner 'root' - group 'root' - mode '755' - end - - execute "mv #{TMP} #{node['gitea']['storage']}/gitea" - - # Change Owner and Permissions: - file "#{node['gitea']['storage']}/gitea" do - owner 'root' - group 'root' - mode '755' - end - - # Create Link - link "#{node['gitea']['location']}/gitea" do - to "#{node['gitea']['storage']}/gitea" - end -end diff --git a/cookbooks/gitea/setup.rb b/cookbooks/gitea/setup.rb deleted file mode 100644 index 2bf1cbe..0000000 --- a/cookbooks/gitea/setup.rb +++ /dev/null @@ -1,135 +0,0 @@ -# Create `git` user: -user 'git' do - create_home true - home '/home/git/' - - system_user true - - shell '/bin/bash' -end - -directory '/home/git/.ssh/' do - owner 'git' - group 'git' - mode '0700' -end - -remote_file '/home/git/.ssh/authorized_keys' do - owner 'git' - group 'git' - mode '0600' -end - -# Create `/etc/gitea/`: -%w(/etc/gitea).each do |d| - directory d do - owner 'root' - group 'root' - mode '0755' - end -end - -%w(/var/lib/git /var/lib/gitea).each do |d| - directory d do - owner 'git' - group 'git' - mode '0755' - end -end - -execute 'rsync -vrz --delete admin@192.168.10.200:/volume1/Shared/AppData/gitea/gitea-data/ /var/lib/gitea/' do - not_if 'test -e /var/lib/gitea/log' -end - -execute 'rsync -vrz --delete admin@192.168.10.200:/volume1/Shared/AppData/gitea/git/ /var/lib/git/' do - not_if 'test -e /var/lib/git/kazu634/' -end - -execute 'chown -R git:git /var/lib/gitea/' -execute 'chown -R git:git /var/lib/git/' - -# Deploy `app.ini`: -remote_file '/etc/gitea/app.ini' do - owner 'git' - group 'git' - mode '644' -end - -# Deploy `supervisord` config`: -remote_file '/etc/supervisor/conf.d/gitea.conf' do - owner 'root' - group 'root' - mode '644' - - notifies :restart, 'service[supervisor]' -end - -service 'supervisor' do - action :nothing -end - -# Depoy `consul` service configuration for `gitea`: -remote_file '/etc/consul.d/service-gitea.json' do - owner 'consul' - group 'consul' - mode '644' - - notifies :reload, 'service[consul]' -end - -service 'consul' do - action :nothing -end - -# Depoy `promtail` configuration for `gitea`: -template '/etc/promtail/gitea.yaml' do - owner 'root' - group 'root' - mode '644' - - variables(HOSTNAME: node[:hostname], LOKIENDPOINT: node['promtail']['lokiendpoint']) - - notifies :restart, 'service[promtail-gitea]' -end - -# Deploy `systemd` configuration for `promtail-gitea`: -remote_file '/etc/systemd/system/promtail-gitea.service' do - owner 'root' - group 'root' - mode '644' -end - -# Service setting: -service 'promtail-gitea' do - action [ :enable, :restart ] -end - -# Deploy `systemd` configuration for `promtail-gitea`: -remote_file '/etc/lsyncd/lsyncd.conf.lua' do - owner 'root' - group 'root' - mode '644' -end - -# Service setting: -service 'lsyncd' do - action [ :enable, :restart ] -end - -# Firewall settings here: -%w( 3000/tcp ).each do |p| - execute "ufw allow #{p}" do - user 'root' - - not_if "LANG=c ufw status | grep #{p}" - - notifies :run, 'execute[ufw reload-or-enable]' - end -end - -execute 'ufw reload-or-enable' do - user 'root' - command 'LANG=C ufw reload | grep skipping && ufw --force enable || exit 0' - - action :nothing -end