Archive abandoned project

This commit is contained in:
Benoit 2025-02-15 00:56:26 +09:00
parent bc8862d90b
commit 65be894048
501 changed files with 24305 additions and 0 deletions

View file

@ -0,0 +1,31 @@
#
# Cookbook:: esh_archivebox
# Recipe:: cleaning
#
# Copyright:: 2022, https://easyself.host
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Starting upstream a77f887 they switched from ytproxy to piped-proxy
# So we need to clean ytproxy container
execute 'Stop ytproxy container' do
command 'machinectl stop ytproxy'
action :run
only_if 'machinectl status ytproxy 2>/dev/null'
end
directory '/var/lib/machines/ytproxy' do
recursive true
action :delete
end

View file

@ -0,0 +1,129 @@
#
# Cookbook:: esh_piped
# Recipe:: compose
#
# Copyright:: 2022, https://easyself.host
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
directory '/opt/piped' do
owner 'root'
group 'root'
mode '0755'
action :create
end
directory '/opt/piped/config' do
owner 'root'
group 'root'
mode '0755'
action :create
end
template '/opt/piped/config/config.properties' do
owner 'root'
group 'root'
mode '0400'
variables proxy_hostname: node['esh']['piped']['config']['proxy_hostname'],
captcha_api_key: node['esh']['piped']['config']['captcha_api_key'],
backend_hostname: node['esh']['piped']['config']['backend_hostname'],
frontend_hostname: node['esh']['piped']['config']['frontend_hostname'],
postgresql_password: node['esh']['piped']['config']['postgresql_password']
action :create
end
cookbook_file '/opt/piped/config/nginx.conf' do
owner 'root'
group 'root'
mode '0444'
action :create
end
template '/opt/piped/config/pipedapi.conf' do
owner 'root'
group 'root'
mode '0444'
variables backend_hostname: node['esh']['piped']['config']['backend_hostname']
action :create
end
template '/opt/piped/config/pipedproxy.conf' do
owner 'root'
group 'root'
mode '0444'
variables proxy_hostname: node['esh']['piped']['config']['proxy_hostname']
action :create
end
template '/opt/piped/config/pipedfrontend.conf' do
owner 'root'
group 'root'
mode '0444'
variables frontend_hostname: node['esh']['piped']['config']['frontend_hostname']
action :create
end
cookbook_file '/opt/piped/config/ytproxy.conf' do
owner 'root'
group 'root'
mode '0444'
action :create
end
template '/opt/piped/docker-compose.yml' do
owner 'root'
group 'root'
mode '0400'
variables backend_hostname: node['esh']['piped']['config']['backend_hostname'],
postgresql_password: node['esh']['piped']['config']['postgresql_password']
action :create
end
execute 'docker compose pull' do
command 'docker compose pull --quiet'
cwd '/opt/piped'
live_stream true
action :run
end
systemd_unit 'piped.service' do
content <<~EOU
[Unit]
Description=piped via docker compose
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=true
WorkingDirectory=/opt/piped
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down
[Install]
WantedBy=multi-user.target
EOU
action [:create, :enable]
subscribes :restart, 'template[/opt/piped/config/config.properties]', :delayed
subscribes :restart, 'file[/opt/piped/config/nginx.conf]', :delayed
subscribes :restart, 'template[/opt/piped/config/pipedapi.conf]', :delayed
subscribes :restart, 'template[/opt/piped/config/pipedproxy.conf]', :delayed
subscribes :restart, 'template[/opt/piped/config/pipedfrontend.conf]', :delayed
subscribes :restart, 'file[/opt/piped/config/ytproxy.conf]', :delayed
subscribes :restart, 'template[/opt/piped/docker-compose.yml]', :delayed
end
service 'piped' do
action :nothing
subscribes :start, 'execute[docker compose pull]', :delayed
end

View file

@ -0,0 +1,66 @@
#
# Cookbook:: esh_piped
# Recipe:: nginx
#
# Copyright:: 2022, https://easyself.host
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apt_package 'nginx-full'
cookbook_file '/etc/nginx/nginx.conf' do
owner 'root'
group 'root'
mode '0644'
action :create
end
template '/etc/nginx/conf.d/pipedapi.conf' do
owner 'root'
group 'root'
mode '0644'
variables backend_hostname: "#{node['esh']['piped']['config']['backend_hostname']}.#{node['esh']['piped']['config']['domain']}"
action :create
end
template '/etc/nginx/conf.d/pipedproxy.conf' do
owner 'root'
group 'root'
mode '0644'
variables proxy_hostname: "#{node['esh']['piped']['config']['proxy_hostname']}.#{node['esh']['piped']['config']['domain']}"
action :create
end
template '/etc/nginx/conf.d/pipedfrontend.conf' do
owner 'root'
group 'root'
mode '0644'
variables frontend_hostname: "#{node['esh']['piped']['config']['frontend_hostname']}.#{node['esh']['piped']['config']['domain']}"
action :create
end
cookbook_file '/etc/nginx/snippets/ytproxy.conf' do
owner 'root'
group 'root'
mode '0644'
action :create
end
service 'nginx' do
action :nothing
subscribes :restart, 'file[/etc/nginx/nginx.conf]', :immediately
subscribes :restart, 'file[/etc/nginx/conf.d/pipedapi.conf]', :immediately
subscribes :restart, 'file[/etc/nginx/conf.d/pipedproxy.conf]', :immediately
subscribes :restart, 'file[/etc/nginx/conf.d/pipedfrontend.conf]', :immediately
subscribes :restart, 'file[/etc/nginx/snippets/ytproxy.conf]', :immediately
end

View file

@ -0,0 +1,55 @@
#
# Cookbook:: esh_piped
# Recipe:: postgresql
#
# Copyright:: 2022, https://easyself.host
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
postgresql_install 'install posgresql' do
version '13'
repo_pgdg false
action :install_server
end
service 'postgresql@13-main' do
action :nothing
end
additional_config = {
'listen_addresses': "localhost,#{node['ipaddress']}",
}
postgresql_config 'update postgresql listen_addresses' do
version '13'
server_config additional_config
notifies :restart, 'service[postgresql@13-main]'
end
postgresql_user 'piped' do
password node['esh']['piped']['postgresql']['password']
createdb true
end
postgresql_database 'piped' do
owner 'piped'
end
postgresql_access 'piped_access' do
# type 'host'
database 'piped'
# user 'piped'
address '10.10.10.0/24'
auth_method 'md5'
notifies :reload, 'service[postgresql@13-main]', :immediately
end

View file

@ -0,0 +1,26 @@
#
# Cookbook:: esh_piped
# Recipe:: service
#
# Copyright:: 2022, https://easyself.host
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
template '/etc/hosts' do
variables piped_addr: node['esh']['piped']['docker']['piped']['ip_addr'],
pipedfrontend_addr: node['esh']['piped']['docker']['piped-frontend']['ip_addr'],
pipedproxy_addr: node['esh']['piped']['docker']['piped-proxy']['ip_addr']
owner 'root'
group 'root'
mode '0644'
end

View file

@ -0,0 +1,36 @@
#
# Cookbook:: esh_piped
# Recipe:: system
#
# Copyright:: 2022, https://easyself.host
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
directory '/etc/piped/' do
owner 'root'
group 'root'
mode '0700'
action :create
end
template '/etc/piped/config.properties' do
owner 'root'
group 'root'
mode '0755'
variables proxy_hostname: "#{node['esh']['piped']['config']['proxy_hostname']}.#{node['esh']['piped']['config']['domain']}",
captcha_api_key: node['esh']['piped']['config']['captcha_api_key'],
backend_hostname: "#{node['esh']['piped']['config']['backend_hostname']}.#{node['esh']['piped']['config']['domain']}",
frontend_hostname: "#{node['esh']['piped']['config']['frontend_hostname']}.#{node['esh']['piped']['config']['domain']}",
postgresql_password: node['esh']['piped']['postgresql']['password']
action :create
end

View file

@ -0,0 +1,46 @@
#
# Cookbook:: esh_archivebox
# Recipe:: undocker
#
# Copyright:: 2022, https://easyself.host
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
%w(piped piped-frontend piped-proxy).each do |image|
url = node['esh']['piped']['docker'][image]['url']
image = node['esh']['piped']['docker'][image]['image']
tag = node['esh']['piped']['docker'][image]['tag']
network = node['esh']['piped']['docker'][image]['network']
ip_addr = node['esh']['piped']['docker'][image]['ip_addr']
service = node['esh']['piped']['docker'][image]['service']
env = node['esh']['piped']['docker'][image]['env']
esh_undocker_download url do
image image
tag tag
end
esh_undocker_extract image do
tag tag
network network
env env
end
esh_undocker_network ip_addr do
image image
end
esh_undocker_service image do
content service
end
end